Script per la disabilitazione dell'UAC da remoto

Script per la disabilitazione dell’UAC da remoto

scrivere nel file lista_host.txt gli ip o l’hostname delle macchine su cui disabilitare l’uac

$credential = Import-CliXml -Path "e:\script\cred_symantec_ad.xml"
$files = Get-Content -Path .\lista_host.txt


foreach ($host_item in $files) {
    Invoke-Command -Credential $Credential -ComputerName $host_item -ScriptBlock {
    $path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    $filter="ConsentPromptBehaviorAdmin|PromptOnSecureDesktop"
    Write-Host "PRIMA DELLA MODIFICA UAC:" -BackgroundColor green
        (Get-ItemProperty $path).psobject.properties | where {$_.name -match $filter} | select name,value

    Set-ItemProperty -Path $path -Name "ConsentPromptBehaviorAdmin" -Value "0"
    Set-ItemProperty -Path $path -Name "PromptOnSecureDesktop" -Value "0"
    Write-Host "DOPO LA MODIFICA UAC:" -BackgroundColor green
        (Get-ItemProperty $path).psobject.properties | where {$_.name -match $filter} | select name,value
    }
}