I have this code:
$uname = (Get-WMIObject -class Win32_ComputerSystem).username
$pcname = read-host "Enter computer name"
$i = Get-WmiObject -Class CCM_Program -Namespace "root\ccm\clientsdk" | Where-Object { $_.Name -like "*Capture USMT Settings z*" }
Invoke-WmiMethod -class CCM_ProgramsManager -Namespace "root\ccm\clientsdk" -Name ExecutePrograms -argumentlist $i -ComputerName "$pcname" -Credentials "$uname"
This will execute a Configuration Manager 2012 task sequence on a remote machine. It works but only if I am logged onto the remote machine. I run it from my workstation and if I am also logged onto the target machine it works. But if you're logged onto the remote machine as a Domain\TestUser it does not run.
How come?