我需要在卸载赛门铁克之前重新启动远程计算机

时间:2021-02-19 10:03:39

标签: powershell

脚本卸载程序,但它们需要很多时间,而且不要重新启动系统,我是PowerShell AD的初学者

#winrm quickconfig

winrm set winrm/config/client '@{TrustedHosts="192.168.0.*"}'

$app = Test-Path "\\$wks\c$\Program Files (x86)\Symantec\Symantec Endpoint Protection"
$wks = Get-Content \\192.168.0.15\Public\Informatica\192.168.0.237.txt
$cred = Get-Credential fre\sgraca

ForEach ($computer in $wks)

{
 
    if ( $computer -eq '192.168.0.237')
    
    {
           
               #$nic= gwmi win32_networkadapter -filter "netenabled = 'true'" -cn $Computer -cred $cred
              if ( Test-connection -ComputerName $computer -count 1 -quiet)

              {
                    write-host $computer " esta activo"
                
                    if ( Invoke-Command -Credential $cred -ScriptBlock {[Environment]::Is64BitOperatingSystem}  $Computer )

                    {
                        write-host $computer + " es de 64 Bits"
                        }
                    else
                    {
                        write-host $computer + " es de 32 Bits"
                        }

           If ($app -eq $true) 
    
    {
    
        
        write-host $computer + " O symantec está instalado! Desinstalando agora!"
        $ap = Get-WmiObject win32_Product -ComputerName $computer | where { $_.name -like "Symantec Endpoint Protection" }
        $ap.Uninstall()
        Restart-Computer -ComputerName $computer -Force
        write-host $computer + " Desisntalado Symantec e sistema reiniciado!"
   
    
    }
    else{ 
        write-host $computer + " O symantec não está instalado!" }

      
                }

    }
}

0 个答案:

没有答案
相关问题