Just add your script inside the Command block:
$Computername = 'ExampleComputerName'
$Command = {
cd 'C:\Program Files (x86)\Trend Micro\OfficeScan Client\'
.\PccNTMon.exe -n '+++exit+++'
(Get-Service tmlisten).WaitForStatus('Stopped','00:05:00')
Stop-service winmgmt -Force
(Get-Service winmgmt).WaitForStatus('Stopped','00:05:00')
$sysroot = $env:SystemRoot
Rename-Item 'c:\windows\system32\wbem\repository' 'c:\windows\system32\wbem\repository.old'
#rd -recurse -force repository
regsvr32 /s $sysroot\system32\scecli.dll
regsvr32 /s $sysroot\system32\userenv.dll
gci -filter *.dll | % {regsvr32 /s $_.Name}
gci | where {'.mof', 'mfl' -contains $_.Extension}| % {mofcomp $_.Name}
mofcomp -n:root\cimv2\applications\exchange wbemcons.mof
mofcomp -n:root\cimv2\applications\exchange smtpcons.mof
}
$CommandSession = New-PSSession -ComputerName $Computername -Authentication Kerberos -UseSSL
Invoke-Command -Session $CommandSession -ScriptBlock $Command
No comments:
Post a Comment