Hi All,
I need help in fixing my script which is getting information from local machine from which i am running the script but not the remote servers results. Attaching my script.
Also need script to add and also to remove local admin Groups from remote servers.
-----------------------------------------------------
Clear
$c=Get-Credential ABC-domain\AB12345
$ServerList = Get-Content "H:\My Documents\My Powershell\serverlist.txt"
foreach ($computer in $ServerList) {
$Opt = New-CimSessionOption -Protocol Dcom
$Session = New-CimSession -ComputerName $computer -Credential $c -SessionOption $Opt
$AV=Invoke-Command -ScriptBlock {(get-ItemProperty 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate' -Name LatestVirusDefsDate -ea 0).LatestVirusDefsDate }
$pv=Invoke-Command -ScriptBlock {(get-ItemProperty 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\Symantec Endpoint Protection\CurrentVersion\public-opstate' -Name LatestVirusDefsRevision -ea 0).LatestVirusDefsRevision }
$date =$AV1
$AV=Get-Date $date -Format 'dd/MM/yyyy'
Write-Host "for server $computer AV date is $av/Rev is $pv"
}
-----------------------------------------------------------
Thank you,
Bala MS.