first version

This commit is contained in:
2022-10-26 17:19:55 +02:00
commit ac1d79c2fa
2 changed files with 49 additions and 0 deletions

6
folder.csv Normal file
View File

@@ -0,0 +1,6 @@
Path,
test2,
test3,
test4,
einordner\test,
test1,
1 Path
2 test2
3 test3
4 test4
5 einordner\test
6 test1

43
start.ps1 Normal file
View File

@@ -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