PowerShell script exchange
Post Reply
JLatimer
Lurker
Posts: 2
Liked: 1 time
Joined: Feb 01, 2012 1:50 pm
Full Name: Jeff Latimer
Contact:

Post Job Activity Powershell with Invoke-Command

Post by JLatimer »

I am struggling with a script that works when I run it Interactively, but dies when it is ran as a post job activity.

Post Job Activity is set to run powershell "C:\Scripts\TargetCopy.ps1 JOBNAME"
Post job runs a script that runs mostly correctly. It passes the JOBNAME parameter on and executes all of the script commands until it gets to an Invoke-Command statement that starts a script that runs on the repository.

The Invoke-Command statement is:
Invoke-Command -ComputerName IPADDRESS -Credential $mycred -FilePath $jobnamescript -ArgumentList $latestfile, $jobnamearg

When I run it through a command prompt (logged on as .\Administrator) as: powershell "C:\Scripts\TargetCopy.ps1 JOBNAME" it works fine. It is simply as a post job activity (Veeam Backup Service runs as .\Administrator) that it fails.

Any ideas? What am I missing?
JLatimer
Lurker
Posts: 2
Liked: 1 time
Joined: Feb 01, 2012 1:50 pm
Full Name: Jeff Latimer
Contact:

Re: Post Job Activity Powershell with Invoke-Command

Post by JLatimer » 1 person likes this post

I answered my own question with my own dumb mistake.

Apparently "Run as Administrator" when logged in as user is not the same as logging in as Administrator and running a script. The problem lies with Credentials that needed to be set for the remoting portion of my script that are unique to the logged in user. All my testing was done as a user logged in but "Run as Administrator". I logged in as Administrator and set a new credentials file and Boom! it works.
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests