There seems to be times and reasons why running a powershell command or script on a remote computer as a scheduled job is a neccesity. I have been trying to come up with a way to do this on all my servers, most are powershell v2. I want it to run right away, here I am tying to have it start in 1 minute.
This is what I have come up with so far, but it doesn't work yet.
# getservices.ps1 contents:Get-service > C:\services.txt
$computer = "$env:computername"
$command = "powershell.exe -executionpolicy unrestricted -noprofile -file C:\getservices.ps1"
$startTime = (Get-Date).AddMinutes(1)
$sJob = [wmiclass]"\\$computer\root\cimv2:win32_scheduledjob"
$startTime = $sJob.ConvertFromDateTime($startTime)
$errRTN = $sJob.Create($command,$startTime)