I have an xml file based on which I'm trying to create a scheduled task. I copied the file onto a remote host.
For the task to be created locally I run
Register-ScheduledTask -xml (Get-Content c:\task.xml | out-string) -TaskName "MyTask" -TaskPath "Event Log Task" -Force
this works fine but when I try adding
invoke-command -Computername "RemotePC" -ScriptBlock {here goes the above Register-ScheduledTask ... } -credentials domain\username
I get
The user name or password is incorrect.
+ CategoryInfo : AuthenticationError: (PS_ScheduledTask:Root/Microsoft/...S_ScheduledTask) [Register-ScheduledTask], CimException
+ FullyQualifiedErrorId : HRESULT 0x8007052e,Register-ScheduledTask
I'm certain the credentials are correct as if I try Enter-PSSession with the credentials I connect just fine. Only when I run the Register-ScheduledTask commandlet I get the same error