commit ac1d79c2fa59d4d28f1bafcc12769c0d5325e5ea Author: jonnybravo Date: Wed Oct 26 17:19:55 2022 +0200 first version diff --git a/folder.csv b/folder.csv new file mode 100644 index 0000000..5c38b04 --- /dev/null +++ b/folder.csv @@ -0,0 +1,6 @@ +Path, +test2, +test3, +test4, +einordner\test, +test1, \ No newline at end of file diff --git a/start.ps1 b/start.ps1 new file mode 100644 index 0000000..43d17c0 --- /dev/null +++ b/start.ps1 @@ -0,0 +1,43 @@ +####Dieses Skript ließt eine csv aus und stelllt alle Verzeichnis in der csv auf hidden +###vars +$ROOTFolder = "C:" +$LogFolder = "$ROOTFolder\hidden_folder.log" +$CSV_Read = "$PSScriptRoot\folder.csv" +$User_Folder = "$ROOTFolder\Users\*" + +### +### funktion + +function create_hidden_folder($hidden_folder){ + if (-not (Test-Path -Path "$hidden_folder" -PathType Container)) { + $output_return_not_exist = "Error: $(Get-Date) - Das Verzeichnis $hidden_folder existiert nicht !!!" + return "$output_return_not_exist" + } else { + Get-Item "$hidden_folder" -Force |foreach { + $_.Attributes = "Hidden" + } + $output_retunr_works = "Info: $(Get-Date) - Das Verzeichnis $hidden_folder wurde versteckt. " + return "$output_retunr_works" + } +} + + + +####Main### +$CSV_File = Import-Csv -Path "$CSV_Read" +foreach ($csv_out in $CSV_File) +{ + Get-Item "$User_Folder" |foreach { + $full_path = "$($_.FullName)\$($csv_out.Path)" + write-host "$full_path" + create_hidden_folder($full_path)|Out-File -FilePath $LogFolder -Append + } + + +} + + + + + +#create_hidden_folder("C:\test5")|Out-File -FilePath $LogFolder -Append \ No newline at end of file