ciao
ho scritto questo script
e ho eseguito con il comandocodice:param($RemovedSID,$RemAccNameDel) # Funzione che analizza alcune chiavi numeriche del registro relative al servizio Windows Search ed elimina le chiavi superflue che hanno il valore delle # loro voci "URL" o "Path" pari ad una directory che include ancora il SID orfano dell'account rimosso o il nome di questo account. function WindowsSearchKeysDeleted ($StartKey) { Get-ChildItem $StartKey -Recurse | ForEach-Object { # Verifica URL $ShouldRemove = @(Get-ItemProperty $_ URL | Where-Object { $_.URL -eq $RemovedSID or $RemAccNameDel}).Count -gt 0 # Verifica Path $ShouldRemove = $ShouldRemove -or (@(Get-ItemProperty $_ Path | Where-Object { $_.Path -eq $RemovedSID or $RemAccNameDel}).Count -gt 0 # Rimozione chiave corrente e sottochiavi if ($shouldRemove) { $_ | Remove-Item -Recurse -whatif } } } # Funzione che rimuove le chiavi o le voci del registro contenenti ancora il SID orfano dell'account rimosso. function KeyAndItemDeleted ($StartKey) { if ($StartKey -eq 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff') { set-Location '$StartKey' Remove-ItemProperty '$RemovedSID' -whatif } else { Set-Location '$StartKey' Remove-Item '$RemovedSID' -whatif } } # Rimuove le eventuali chiavi numeriche del registro relative a Windows Search che hanno il valore delle loro voci "URL" o "Path" pari ad una directory che # include ancora il SID orfano dell'account rimosso o il nome di questo account. WindowsSearchKeysDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\DefaultRules' WindowsSearchKeysDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager\Windows\SystemIndex\WorkingSetRules' if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager_Previous_Version\Windows\SystemIndex\DefaultRules") { WindowsSearchKeysDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Search\CrawlScopeManager_Previous_Version\Windows\SystemIndex\DefaultRules' } if (Test-Path "HKLM:SOFTWARE\Microsoft\Windows Search\CrawlScopeManager_Previous_Version\Windows\SystemIndex\WorkingSetRules") { WindowsSearchKeysDeleted -StartKey 'HKLM:SOFTWARE\Microsoft\Windows Search\CrawlScopeManager_Previous_Version\Windows\SystemIndex\WorkingSetRules' } WindowsSearchKeysDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Search\Gather\Windows\SystemIndex\Sites\LocalHost\Paths' # Rimuove le eventuali chiavi del registro che hanno, come valore, il SID orfano dell'account rimosso. KeyAndItemDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Media Player NSS\3.0\MAC Access Control' KeyAndItemDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows Media Player NSS\3.0\Server Settings' if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList") { KeyAndItemDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' } if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff") { KeyAndItemDeleted -StartKey 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NetCache\PurgeAtNextLogoff' }
powershell.exe -ExecutionPolicy Unrestricted -file "D:\Users\xxx\Documents\a.ps1" "S-1-5-21-152799110-1058532297-3105840818-1000" "AccountEliminare"
ma mi da questo errore
come mai?codice:Token 'or' imprevisto nell'espressione o nell'istruzione. In D:\Users\xxx\Documents\a.ps1:13 car:101 + $ShouldRemove = @(Get-ItemProperty $_ URL | Where-Object { $_ .URL -eq $RemovedSID or <<<< $RemAccNameDel}).Count -gt 0 + CategoryInfo : ParserError: (or:String) [], ParentContainsError RecordException + FullyQualifiedErrorId : UnexpectedToken
grazie
ciao

Rispondi quotando