Indice del forum Olimpo Informatico
I Forum di Zeus News
Leggi la newsletter gratuita - Attiva il Menu compatto
 
 FAQFAQ   CercaCerca   Lista utentiLista utenti   GruppiGruppi   RegistratiRegistrati 
 ProfiloProfilo   Messaggi privatiMessaggi privati   Log inLog in 

    Newsletter RSS Facebook Twitter Contatti Ricerca
[PS] Operatore OR che non funziona
Nuovo argomento   Rispondi    Indice del forum -> Programmazione
Precedente :: Successivo  
Autore Messaggio
balubeto
Dio minore
Dio minore


Registrato: 19/05/06 09:22
Messaggi: 757

MessaggioInviato: 03 Lug 2010 20:48    Oggetto: [PS] Operatore OR che non funziona Rispondi

ciao

ho scritto questo script

Codice:

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'
}


e ho eseguito con il comando

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

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


come mai?

grazie

ciao
Top
Profilo Invia messaggio privato
Mostra prima i messaggi di:   
Nuovo argomento   Rispondi    Indice del forum -> Programmazione Tutti i fusi orari sono GMT + 2 ore
Pagina 1 di 1

 
Vai a:  
Non puoi inserire nuovi argomenti
Non puoi rispondere a nessun argomento
Non puoi modificare i tuoi messaggi
Non puoi cancellare i tuoi messaggi
Non puoi votare nei sondaggi