invoke-command -ComputerName $server -Credential $cred
-ScriptBlock{param($server,$UserName,$serverpass,$starttime,$startdate)
$hotfix_setup = schtasks /query |select-string "hotfix_setup" -quiet
If
($hotfix_setup -eq "true")
{schtasks /delete /tn "hotfix_setup" /f
|out-null}
schtasks /create /tn "hotfix_setup" /sc once /ru $UserName /rp
$serverpass /st $starttime /sd $startdate /tr
D:\Hotfix\Hotfix_Win2003\2014-04\hotfix_setup.bat
} -ArgumentList
$server,$UserName,$serverpass,$starttime,$startdate
原文地址:http://www.cnblogs.com/dreamer-fish/p/3716236.html