Run Powershell Script Remotely...
#############################################################################################################
#
# report.ps1
#
# run a powershell script on a remote computer and copy a result file for viewing locally
#
$computer = "GPM"
"Run GPO Report"
"Executing remotely from $computer"
$username = read-host "Username"
$pw = read-host -AsSecureString "Password"
$pass = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($pw))
$cmd = "c:\util\psexec.exe /acceptEula \\$computer -u $username -p $pass -w c:\dev c:\dev\run-report.bat"
invoke-expression $cmd
$file = "\\" + $computer + "\c$\dev\gpostatus.html"
copy $file c:\util
c:\util\gpostatus.html
No comments:
Post a Comment