PowerShell script exchange
			
		
		
			
				
																			
								mattGamm 							 
						Novice 			
		Posts:  3 				Liked:  1 time  
				Joined:  Feb 01, 2021 2:57 pm 		
		
											Full Name:  Matt Gammon 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by mattGamm   »  Feb 01, 2021 3:19 pm 
				  this post 
			
			
			
			
			Hello There,
I am trying to create a PowerShell script to restore a file from a backup job which will then run on a monthly bases to test the backups, so far have managed to create the following;
Code: Select all 
Add-PSSnapin VeeamPSSnapin
$restore_point = Get-VBRBackup | Get-VBRRestorePoint -Name "SERVER" | Sort-Object –Property CreationTime –Descending | Select-Object -First 1
$restore_start = Start-VBRWindowsFileRestore -RestorePoint $restore_point -Reason "For testing purposes"
# $restore_credentials = Get-VBRCredentials -Name "DOMAIN\Admin"
$restore_session = Get-VBRRestoreSession | ?{$_.state -eq "Working" -and  $Id -eq $restore_start.MountSession.RestoreSessionInfo.Uid}
Start-VBRWindowsGuestItemRestore -Path  "C:\Scripts\" -RestorePolicy Keep -Session $restore_session
Stop-VBRWindowsFileRestore $restore_start 
 
But  we get this error message;
Code: Select all 
Start-VBRWindowsGuestItemRestore : Connection exception
At C:\Scripts\TestRestoreV3.ps1:13 char:1
+ Start-VBRWindowsGuestItemRestore -Path "C:\Scripts\" -RestorePolicy Keep -Sessio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-VBRWindowsGuestItemRestore], ConnectionException
    + FullyQualifiedErrorId : StartWindowsGuestItemRestore,Veeam.Backup.PowerShell.Cmdlets.StartVBRWindowsGuestItemRestore 
I am not sure what I am missing regarding the connection exception issue is
some of the script has come from 
https://developer.cisco.com/codeexchang ... tegration/ 
Thanks,
Matt
 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								HannesK 							 
						Product Manager 			
		Posts:  15627 				Liked:  3453 times  
				Joined:  Sep 01, 2014 11:46 am 		
		
											Full Name:  Hannes Kasparick 
												Location:  Austria 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by HannesK   »  Feb 02, 2021 7:12 am 
				  this post 
			
			
			
			
			Hello, 
and welcome to the forums. 
 
As far as I see, you removed the credentials part. Without credentials, there is no way to log into the machine and do the file level restore. 
 
Best regards, 
Hannes
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								mattGamm 							 
						Novice 			
		Posts:  3 				Liked:  1 time  
				Joined:  Feb 01, 2021 2:57 pm 		
		
											Full Name:  Matt Gammon 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by mattGamm   »  Feb 08, 2021 12:09 pm 
				  this post 
			
			
			
			
			Hello,
Thank you Hannes for your reply I have added the credentials part back in now get this message;
Code: Select all 
Start-VBRWindowsGuestItemRestore : Cannot validate argument on parameter 'GuestCredentials'. The argument is null. Provide a valid value for the 
argument, and then try running the command again.
At C:\Scripts\TestRestoreV3.ps1:13 char:118
+ ... estCredentials $restore_credentials
+                    ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-VBRWindowsGuestItemRestore], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRWindowsGuestItemRestore
Thanks again,
Matt
 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								soncscy 							 
						Veteran 			
		Posts:  643 				Liked:  314 times  
				Joined:  Aug 04, 2019 2:57 pm 		
		
											Full Name:  Harvey 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by soncscy   »  Feb 08, 2021 12:14 pm 
				  this post 
			
			
			
			
			Hi Matt,  
 
The argument is null. Provide a valid value for the  
argument, and then try running the command again. 
 
Basically, $restore_credentials is empty -- run exactly what you put for the command in the Powershell console without trying to save it to some variable and post the output.  
 
Would suggest that the cmdlet just couldn't find any credentials that matched the criteria you provided.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Natalia Lupacheva 							 
						Veteran 			
		Posts:  1143 				Liked:  302 times  
				Joined:  Apr 27, 2020 12:46 pm 		
		
											Full Name:  Natalia Lupacheva 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by Natalia Lupacheva   »  Feb 08, 2021 12:16 pm 
				  this post 
			
			
			
			
			Hi Matt, 
Maybe this 
description  would help, please take a look at the example. 
Did you try to add -GuestCredentials parameter as it's described? 
Thanks!
 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								oleg.feoktistov 							 
						Veeam Software 			
		Posts:  2037 				Liked:  682 times  
				Joined:  Sep 25, 2019 10:32 am 		
		
											Full Name:  Oleg Feoktistov 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by oleg.feoktistov   »  Feb 08, 2021 12:33 pm 
				  this post 
			
			
			
			
			Make sure you passed CCredentials object obtained with Get-VBRCredentials and not PSCredential, which is retrieved with native cmdlet. Thanks!
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								mattGamm 							 
						Novice 			
		Posts:  3 				Liked:  1 time  
				Joined:  Feb 01, 2021 2:57 pm 		
		
											Full Name:  Matt Gammon 
							
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by mattGamm   »  Feb 08, 2021 12:36 pm 
				1 person likes  this post 
			
			
			
			
			Hello,
I have used the following;
Code: Select all 
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
Add-PSSnapin VeeamPSSnapin
$restore_point = Get-VBRBackup | Get-VBRRestorePoint -Name "SERVER" | Sort-Object –Property CreationTime –Descending | Select-Object -First 1
$restore_start = Start-VBRWindowsFileRestore -RestorePoint $restore_point -Reason "For testing purposes"
$restore_credentials = Get-VBRCredentials -Name "Domain\VeeamServiceAccount"
$restore_session = Get-VBRRestoreSession | ?{$_.state -eq "Working" -and  $Id -eq $restore_start.MountSession.RestoreSessionInfo.Uid}
Start-VBRWindowsGuestItemRestore -Path "C:\Scripts\" -RestorePolicy Keep -Session $restore_session -GuestCredentials $restore_credentials
Stop-VBRWindowsFileRestore $restore_start
was using my Admin account but change it to use the Service Account that Veeam uses for backing up and is now working.
Thanks,
Matt
 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								chengeel 							 
						Lurker 			
		Posts:  2 				Liked:  never  
				Joined:  Mar 14, 2024 3:39 am 		
		
						
							
				Contact: 
				
			 
				
		 
		
						
					
																		
							
						
									
						Post 
					 
								by chengeel   »  Mar 14, 2024 4:24 am 
				  this post 
			
			
			
			
			Hi, 
 
I test above script... but getting this error  
 
Add-PSSnapin : The Windows PowerShell snap-in 'VeeamPSSnapin' is not installed on this computer. 
At C:\Scripts\RestoreTest.ps1:1 char:1 
+ Add-PSSnapin VeeamPSSnapin 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo          : InvalidArgument: (VeeamPSSnapin:String) [Add-PSSnapin], PSArgumentException 
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Mildur 							 
						Product Manager 			
		Posts:  11029 				Liked:  3028 times  
				Joined:  May 13, 2017 4:51 pm 		
		
											Full Name:  Fabian K. 
																	Location:  Switzerland 
												
							
				Contact: 
				
			 
				
		 
		
						
					
																			
						
									
						Post 
					 
								by Mildur   »  Mar 14, 2024 8:07 am 
				  this post 
			
			
			
			
			Hi Chengeel 
 
VeeamPSSnapin was removed in version 11. It is not required anymore. 
Does the script work if you remove the line "Add-PSSnapin VeeamPSSnapin"? 
 
Best, 
Fabian
			
			
									
						
							Product Management Analyst @ Veeam Software
			
						 
		 
				
		
		 
	 
	
	
	
		
		Users browsing this forum: No registered users and 8 guests