Ideally, the Replication job would be disabled when the Backup job starts and then not enabled until the Backup job has completed. The Veeam powershell commands Disable-VBRJob and Enable-VBRjob achieve this, so as a test on the DR site I did the following:
Created a secret file so that the password is not saved in clear text
Code: Select all
[i]Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -Server "DR-site" -User "domain.local\backupadmin" -Password "???????????"
$encPassFileName = 'C:\Users\backupadmin\Documents\veeam-ps-secret'
(Get-Credential).Password | ConvertFrom-SecureString | Set-Content $encPassFileName
Disconnect-VBRServer[/i]
PS to login and run command
Code: Select all
[i]Add-PSSnapin VeeamPSSnapin
$encPassFileName = 'C:\Users\backupadmin\Documents\veeam-ps-secret'
$username = "domain.local\backupadmin"
$password = Get-Content $encPassFileName | ConvertTo-SecureString
$psCredential = New-Object System.Management.Automation.PsCredential($username,$password)
Connect-VBRServer -Server "DR-site" -Credential $PSCredential
#Disable-VBRJob -Job test-schedule
Disable-VBRJob -Job test-schedule | Out-File -FilePath C:\Users\backupadmin\Documents\Disable-OUTPUT.txt
Disconnect-VBRServer[/i]
Code: Select all
powershell.exe -executionpolicy Bypass -file C:\Users\backupadmin\Documents\Disable-Windchill-Replication.ps1 > C:\Users\backupadmin\Documents\Disable-Bat.txt
Code: Select all
[i]Set-ExecutionPolicy : Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution
policy for the default (LocalMachine) scope, start Windows PowerShell with the "Run as administrator" option. To
change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
At C:\Users\backupadmin\Documents\Disable-Windchill-Replication.ps1:3 char:1
+ Set-ExecutionPolicy RemoteSigned
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyComma
nd
Connect-VBRServer : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' is
denied.
At C:\Users\seagate2\Documents\Disable-Windchill-Replication.ps1:8 char:1
+ Connect-VBRServer -Server "mtc-veeam" -Credential $PSCredential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Connect-VBRServer], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Veeam.Backup.PowerShell.Cmdlets.ConnectVBRServer
Disable-VBRJob : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Veeam\Veeam Backup and Replication' is denied.
At C:\Users\backupadmin\Documents\Disable-Windchill-Replication.ps1:9 char:1
+ Disable-VBRJob -Job test-schedule | Out-File -FilePath C ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException[/i]
If the PS script is ran from powershell I get the same errors as above accessing the remote registry.
Is there a way for this BAT script to run on a remote server when not ran as administrator and with UAC turned on? Otherwise should this be a feature request for a Backup job to have an option to do this without scripts?
Many thanks
Colin