How do I search a specific folder name (or part of a folder name) in each existing profile using PowerShell? C:\Users\xyz…
$wantedfolder = "xyz"
# Iterate through all users of the PC
foreach ($user in (Get-ChildItem "C:\Users\" -Directory)) {
# Pfad zum bestimmten Ordner des Benutzers
$ProfilePath = "$($user.FullName)\AppData\xxx"
# Iterate through all subfolders of the profile path
foreach ($folder in (Get-ChildItem $ProfilePath -Directory)) {
# Check if the folder name contains "$wanted folder".t
if ($folder.Name -like "*$wantedfolder*") {
# tu etwas...
}
}
}
Stay blogged. 😎
Dein Matthias Düsi