Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Registering scheduled task on remote machine

$
0
0

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

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles