From 161fa4a333ed116e75ba01742121df3d004224e4 Mon Sep 17 00:00:00 2001 From: hubster-bot Date: Wed, 10 Jul 2024 11:38:21 +0100 Subject: [PATCH] Main --- functions/private/Get-WinUtilToggleStatus.ps1 | 11 ++++++ .../private/Invoke-WinUtilHiddenFiles.ps1 | 34 +++++++++++++++++++ functions/public/Invoke-WPFToggle.ps1 | 1 + 3 files changed, 46 insertions(+) create mode 100644 functions/private/Invoke-WinUtilHiddenFiles.ps1 diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 05db4d43..01a1b273 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -125,6 +125,17 @@ Function Get-WinUtilToggleStatus { return $true } } + + if ($ToggleSwitch -eq "WPFToggleHiddenFiles") { + $HiddenFiles = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').Hidden + if($HiddenFiles -eq 1){ + return $false + } + else{ + return $true + } + } + if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") { $TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa if($TaskbarWidgets -eq 0) { diff --git a/functions/private/Invoke-WinUtilHiddenFiles.ps1 b/functions/private/Invoke-WinUtilHiddenFiles.ps1 new file mode 100644 index 00000000..ddb0051f --- /dev/null +++ b/functions/private/Invoke-WinUtilHiddenFiles.ps1 @@ -0,0 +1,34 @@ +function Invoke-WinUtilHiddenFiles { + <# + + .SYNOPSIS + Enable/Disable Hidden Files + + .PARAMETER Enabled + Indicates whether to enable or disable Hidden Files + + #> + Param($Enabled) + Try{ + if ($Enabled -eq $false){ + Write-Host "Enabling Hidden Files" + $value = 1 + } + else { + Write-Host "Disabling Hidden Files" + $value = 2 + } + $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + Set-ItemProperty -Path $Path -Name Hidden -Value $value + } + Catch [System.Security.SecurityException] { + Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" + } + Catch [System.Management.Automation.ItemNotFoundException] { + Write-Warning $psitem.Exception.ErrorRecord + } + Catch{ + Write-Warning "Unable to set $Name due to unhandled exception" + Write-Warning $psitem.Exception.StackTrace + } +} diff --git a/functions/public/Invoke-WPFToggle.ps1 b/functions/public/Invoke-WPFToggle.ps1 index 9d923edb..4bb4caa4 100644 --- a/functions/public/Invoke-WPFToggle.ps1 +++ b/functions/public/Invoke-WPFToggle.ps1 @@ -30,5 +30,6 @@ function Invoke-WPFToggle { "WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $(Get-WinUtilToggleStatus WPFToggleTaskbarWidgets)} "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $(Get-WinUtilToggleStatus WPFToggleTaskbarSearch)} "WPFToggleTaskView" {Invoke-WinUtilTaskView $(Get-WinUtilToggleStatus WPFToggleTaskView)} + "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $(Get-WinUtilToggleStatus WPFToggleHiddenFiles)} } }