Author Posts

April 8, 2016 at 4:36 am

Hi, I have been struggling with a PS script where I am trying to execute a batch job on a remote computer. The batch job resides on a network share, so I will be using a UNC path.
In the script, the user name, password, and computer name are queried.
Besides trying various scheduled tasks, etc, I am now to the point of using invoke-command (I seem to remember Don says never to use that 🙂 ) ....

Here is my command:

Invoke-Command -ComputerName name -ScriptBlock { Start-Process "\\path\pleasehelpimgoingcrazy.cms" -verb runAs }

I am getting an access denied error. I am using my account with the highest privileges. Can someone help?

Thanks!

April 8, 2016 at 4:40 am

This is the "second hop" problem of PowerShell remoting. If you search for that term you'll find tons of results, but the short answer is that you need to use either Kerberos delegation (in an AD environment where this is possible) or CredSSP.

April 8, 2016 at 4:57 am

Thanks Dave. Would it be easier to use a scheduled task then? I have had my issues with that as well, using an XML file for the task.
If you were to use a scheduled task, which method would you use to set it up? Besides using schtasks.exe (always some issue with that 🙁 ) ... and I have tried New-Object -ComObject("Schedule.Service") .... but I seem to always have issues with permissions also.
Which poison would you pick? 🙂
Thanks!

April 8, 2016 at 5:29 am

On 2008, I always used schtasks.exe.

April 8, 2016 at 5:58 am

For using credssp, you can check my post here how to do it trough a GPO. Not the safest thing, but it works nevertheless. 🙂 https://powershell.org/2015/06/18/quick-tip-enable-credssp-trough-gpos/

April 12, 2016 at 5:58 am

Thanks Dave and Richard 🙂