PowerShell script exchange
Manfriday
Influencer
Posts: 20 Liked: 1 time
Joined: Sep 15, 2009 6:03 pm
Full Name: Jason Morris
Contact:
Post
by Manfriday » Jul 22, 2020 2:27 pm
this post
Hi!
I am seeing warnings from my backup copy job that runs a powershell script on job completion.
its a pretty simple job:
Code: Select all
if ( (Get-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue) -eq $null )
{Add-PsSnapin VeeamPSSnapIn}
[string]$veeamServer = "myserver"
# create a credential for the service account
[string]$UserName = "username"
[string]$passwordText = Get-Content "path-to-secure-file"
[SecureString]$securePwd = $passwordText | ConvertTo-SecureString
[pscredential]$credOject = New-Object System.Management.Automation.PSCredential ($UserName, $securePwd)
#connect to Veeam Server
$vbrobject = Connect-VBRServer -Server $veeamServer -Credential $credOject
#execute the repository rescan
Get-VBRBackupRepository -Name "Repository" | Sync-VBRBackupRepository | Out-Null
#disconnect from VBR server
Disconnect-VBRServer | Out-Null
Exit(0)
When I run the script at a command line I dont see any output to the screen, but when the script runs from the job I get the Exit Code 1.
The script DOES execute properly, so I'm not sure where this exit code is coming from.
Manfriday
Influencer
Posts: 20 Liked: 1 time
Joined: Sep 15, 2009 6:03 pm
Full Name: Jason Morris
Contact:
Post
by Manfriday » Jul 22, 2020 6:26 pm
this post
When I run my script from the console and I follow up with a
$LASTEXITCODE
I can confirm that I get a 0.
Not sure where Veeam is getting the 1?
oleg.feoktistov
Veeam Software
Posts: 2041 Liked: 684 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:
Post
by oleg.feoktistov » Jul 24, 2020 12:37 pm
this post
Hi Jason,
I tried it on a backup copy job in my lab and no warnings rendered so far. The post-job script completes successfully.
What do you get in the job log file located here?
Code: Select all
C:\ProgramData\Veeam\Backup\<BackupCopyJobName>\Job.<Name>.BackupSync.log
Thanks,
Oleg
Manfriday
Influencer
Posts: 20 Liked: 1 time
Joined: Sep 15, 2009 6:03 pm
Full Name: Jason Morris
Contact:
Post
by Manfriday » Jul 30, 2020 2:15 pm
this post
Yes! Thanks so much Chris. That was the issue. Once I created my password file in a PowerShell window run as the service account that veeam uses, my script worked great.
chris.arceneaux
VeeaMVP
Posts: 726 Liked: 386 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:
Post
by chris.arceneaux » Jul 30, 2020 5:56 pm
this post
Glad to hear! Thanks for letting us know you got things working!
Users browsing this forum: Baidu [Spider] , jsobell and 4 guests