|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Sep 2004
Messaggi: 1009
|
[PS] due funzioni nello stesso script
ciao
come si fa ad inserire due funzioni nello stesso script in quanto ho provato a scrivere cio` nell` editor di PowerShell : Codice:
# 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 $RemovedAccountNameDeleted}).Count -gt 0)
# Verifica Path
$ShouldRemove = $ShouldRemove -or (@(Get-ItemProperty $_ Path | Where-Object { $_.Path -eq $RemovedSID or $RemovedAccountNameDeleted}).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'
}
else {
Set-Location '$StartKey'
Remove-Item '$RemovedSID'
}
}
grazie ciao |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:24.



















