PowerShell script exchange
Post Reply
marcodejong
Novice
Posts: 3
Liked: never
Joined: May 13, 2019 7:05 am
Full Name: Marco de Jong
Contact:

Restoring exchange mailbox using Powershell on workstation

Post by marcodejong »

Hi all,

I'm trying to restore a batch of mailboxes using my (admin) workstation, however i'm running into a problem. Here are the steps I'm following:
  • Connect to the backup and restore server : Connect-VBRServer -Credential $cred -Server $veeamServer -Port 9392
  • Get the latest restore point : $VBRRestorePoint = (Get-VBRApplicationRestorePoint -Exchange -name $exchangeServerName) | Sort-Object creationtime -Descending | Select-Object -First 1
  • Start the exchange restore session : $VBRSession = Start-VBRExchangeItemRestoreSession -RestorePoint $VBRRestorepoint -Verbose
When I execute these steps I get a progress :

Exchange Item Restore Session
Mounting Restore Point


After a minute or so an error pops in the terminal :
Start-VBRExchangeItemRestoreSession : File does not exist. File: [SVxxx.vm-341D2020-04-03T232606_FE70.vbk].

In fact the error message is correct, the file is missing from c:\VeeamFLR.

When i try the same steps directly on the backup and restore server everytyhing works as expected. Am i missing a step or parameter, or is it not possible to do a exchange restore from a workstation?

Regards,
Marco
Andreas Neufert
VP, Product Management
Posts: 6749
Liked: 1408 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Restoring exchange mailbox using Powershell on workstation

Post by Andreas Neufert »

Can you please start on the same workstation a windows FLR from the same server and use "Copy to" approach to restore any file of your choice from it to the workstation. I guess something is blocking the datapath.
Andreas Neufert
VP, Product Management
Posts: 6749
Liked: 1408 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Re: Restoring exchange mailbox using Powershell on workstation

Post by Andreas Neufert »

To open a support ticket, upload logs and share then the support ticket here can help as well to get this investigated.
marcodejong
Novice
Posts: 3
Liked: never
Joined: May 13, 2019 7:05 am
Full Name: Marco de Jong
Contact:

Re: Restoring exchange mailbox using Powershell on workstation

Post by marcodejong »

Thanks Andreas,

When using powershell I use Visual studio code as IDE, to use the Veeam cmdlets I imported the VeeamPSSnapin using the add-pssnapin powershell command. It seems this is not enough to get full functionality. I started my script using the integrated powershell Console in the Veeam GUI (hamburger menu -> Console -> PowerShell) and to my surprise the script worked.

Now my question was why does it work from the veaamConsole, and it doesn't using the pssnapin in a default powershell session. So I went on a search and found the initialization script for the 'Veeam powershell console'. I took some of the code and integrated it in my script, this did the trick and now when I start a VBRExchangeRestoreSession the databases get mounted.

Below the code I enbedded in my script:

$powerShellModules = @('Veeam.Exchange.PowerShell', 'Veeam.SQL.PowerShell', 'Veeam.SharePoint.PowerShell', 'Veeam.Oracle.PowerShell')

foreach ($powerShellModule in $powerShellModules) {
$availableModule = Get-Module -ListAvailable -Name $powerShellModule
if ($availableModule) {
$availableModule | Import-Module | Out-Null
}
}

[void][Reflection.Assembly]::LoadWithPartialName('VimService2')
[void][Reflection.Assembly]::LoadWithPartialName('VimService2.XmlSerializers')
[void][Reflection.Assembly]::LoadWithPartialName('VimService')
[void][Reflection.Assembly]::LoadWithPartialName('VimService.XmlSerializers')
[void][Reflection.Assembly]::LoadWithPartialName('VimServiceInt')
[void][Reflection.Assembly]::LoadWithPartialName('VimServiceInt.XmlSerializers')

Set-Alias -Name Add-VBRHPStorage -Value Add-HP4Storage -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Set-VBRHPStorage -Value Set-HP4Storage -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Add-VBRHPSnapshot -Value Add-HP4Snapshot -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Get-VBRHPSnapshot -Value Get-HP4Snapshot -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Get-VBRHPCluster -Value Get-HP4Cluster -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Get-VBRHPStorage -Value Get-HP4Storage -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Get-VBRHPVolume -Value Get-HP4Volume -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Remove-VBRHPSnapshot -Value Remove-HP4Snapshot -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Remove-VBRHPStorage -Value Remove-HP4Storage -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Sync-VBRHPStorage -Value Sync-HP4Storage -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Sync-VBRHPVolume -Value Sync-HP4Volume -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Clone-VBRJob -Value Copy-VBRJob -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Add-VBRCloudTenantToTapeJob -Value Add-VBRBackupToTapeJob -Scope Global -Description 'Veeam VeeamPSSnapIn alias'
Set-Alias -Name Set-VBRCloudTenantToTapeJob -Value Set-VBRBackupToTapeJob -Scope Global -Description 'Veeam VeeamPSSnapIn alias'

Add-PSSnapin VeeamPSSnapIn

$powerShellSnapIn = Get-PSSnapIn 'VeeamPSSnapIn'
$powerShellSnapInFormatDataPath = Join-Path -Path $powerShellSnapIn.ApplicationBase -ChildPath 'Veeam.Backup.PowerShell.format.ps1xml'
Update-FormatData -PrependPath $powerShellSnapInFormatDataPath


Regards,
Marco
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Restoring exchange mailbox using Powershell on workstation

Post by jhoughes »

The issue was that you did not have the Veeam Explorer modules imported. You can shorten this by just dot-sourcing the initialization script PS1 file at the top of your script to accomplish the same result in 1 line of code.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests