- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Get-VBRReplica
Hi, 
Any script to list the Replica Jobs in detailed, such as job, type, name, status, result, target, target LUN Size / "optional" free size on target LUN?
Thanks,
			
			
									
						
										
						Any script to list the Replica Jobs in detailed, such as job, type, name, status, result, target, target LUN Size / "optional" free size on target LUN?
Thanks,
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
You could probably pull all that info out of the Get-VBRBackupSession
As for your Lun info
			
			
									
						
										
						Code: Select all
$session = Get-VBRBackupSession -Name "Replication Job" | Sort CreationTime -Descending | Select -First 1
$session | fl
$session.Progress
$session.BackupStats | fl
Code: Select all
Get-VBRServer -Name "ESXiServer" | Find-VBRDatastore | fl
- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hello, 
Can't be by the job Type followed by other information I required?
Thanks,
			
			
									
						
										
						Can't be by the job Type followed by other information I required?
Thanks,
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
So does this look like what your after?

or do you want more info included?
			
			
									
						
										
						or do you want more info included?
- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hello, 
This is fantastic, is it possible to bring in the LUN Name target?
Thanks,
			
			
									
						
										
						This is fantastic, is it possible to bring in the LUN Name target?
Thanks,
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
I've updated the image, anything else?
			
			
									
						
										
						- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
That's great, can I get the syntax please?
Thanks,
			
			
									
						
										
						Thanks,
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
This should be you
Usage 
Output
			
			
									
						
										
						Code: Select all
function Get-vPCReplicaStuff {
	param (
		[Parameter(Position=0,
		ValueFromPipeline=$true,
		ValueFromPipelineByPropertyName=$true)]
		[Alias("Name")]
		[String]$jobName
		)
	PROCESS {
		$job = Get-VBRJob -Name $jobName
		$str = Get-VBRReplica -Name $job.Name
		$esxi = Get-VBRServer | ?{$_.Id -eq $job.TargetHostId}
		$dtstr =  $esxi | Find-VBRDatastore -Name $job.ViReplicaTargetOptions.DatastoreName
		$hashy = @{"Job Name" = "$($job.Name)"; "Target Type" = "$($job.TargetType)"; "Replica Name" = "$($str.Name)";
		"State" = "$($job.GetLastState())"; "Last Result" = "$($job.GetLastResult())"; "Target Name" = "$($esxi.Name)";
		"Storage Info (Free/Total)" = "$($dtstr.FreeSpace / 1GB) / $($dtstr.Capacity / 1GB)"}
		$output = New-Object -TypeName PSObject -Property $hashy
	}
	End {
	$output
	}
}
Code: Select all
Get-VBRJob | ?{$_.IsReplica} | Get-vPCReplicaStuff
Code: Select all
Storage Info (Free/Total) : 897.0234375 / 931.25
Last Result               : Success
Target Type               : SnapReplica
Replica Name              : VC Replication
Target Name               : esxi03
Job Name                  : VC Replication
State                     : Stopped
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
Forgot the Datastore, rounded the storage figures and change some of the names for easier access
Output
Usage hasn't changed
			
			
									
						
										
						Code: Select all
function Get-vPCReplicaStuff {
   param (
      [Parameter(Position=0,
      ValueFromPipeline=$true,
      ValueFromPipelineByPropertyName=$true)]
      [Alias("Name")]
      [String]$jobName
      )
   PROCESS {
      $job = Get-VBRJob -Name $jobName
      $str = Get-VBRReplica -Name $job.Name
      $esxi = Get-VBRServer | ?{$_.Id -eq $job.TargetHostId}
      $dtstr =  $esxi | Find-VBRDatastore -Name $job.ViReplicaTargetOptions.DatastoreName
      $hashy = @{"Job" = "$($job.Name)"; "Type" = "$($job.TargetType)"; "Name" = "$($str.Name)";
      "State" = "$($job.GetLastState())"; "Result" = "$($job.GetLastResult())"; "Target" = "$($esxi.Name)";
      "Datastore" = "$($job.ViReplicaTargetOptions.DatastoreName)"; 
      "StorageInfo" = "$('{0:N2}' -f $($dtstr.FreeSpace / 1GB))GB/$('{0:N2}' -f $($dtstr.Capacity / 1GB))GB"}
      $output = New-Object -TypeName PSObject -Property $hashy
   }
   End {
   $output
   }
}
Code: Select all
State       : Stopped
StorageInfo : 890.98GB/931.25GB
Name        : VC Replication
Type        : SnapReplica
Job         : VC Replication
Target      : esxi03
Result      : Success
Datastore   : LCL-DATASTORE
- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hi, 
I saved it as ps1 script but it doesn't run.
Thanks,
S.Hussain
			
			
									
						
										
						I saved it as ps1 script but it doesn't run.
Thanks,
S.Hussain
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
That won't work as the ps1 file won't be loading the Veeam snapin or calling the function, to make it easy let me know what sort of file(CSV/HTML) you want and I'll finish it off for youhabibalby wrote:Hi,
I saved it as ps1 script but it doesn't run.
Thanks,
S.Hussain
- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hi, 
Any file CSV or HTML will work.
			
			
									
						
										
						Any file CSV or HTML will work.
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
Try this out( edit '$file = "C:\Scripts\Test.htm"' to the correct location and filename you would like)
			
			
									
						
										
						Code: Select all
######### Edit Path and File Name#################
$file = "C:\Scripts\Test.htm"
##################################################
$html = "<style>"
$html = $html + "BODY{background-color:#fff;}"
$html = $html + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$html = $html + "TH{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:#00FF00}"
$html = $html + "TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:#fff}"
$html = $html + "</style>"
########## Don't Touch ###########################
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue
function Get-vPCReplicaStuff {
   param (
      [Parameter(Position=0,
      ValueFromPipeline=$true,
      ValueFromPipelineByPropertyName=$true)]
      [Alias("Name")]
      [String]$jobName
      )
   PROCESS {
      $job = Get-VBRJob -Name $jobName
      $str = Get-VBRReplica -Name $job.Name
      $esxi = Get-VBRServer | ?{$_.Id -eq $job.TargetHostId}
      $dtstr =  $esxi | Find-VBRDatastore -Name $job.ViReplicaTargetOptions.DatastoreName
      $hashy = @{"Job" = "$($job.Name)"; "Type" = "$($job.TargetType)"; "Name" = "$($str.Name)";
      "State" = "$($job.GetLastState())"; "Result" = "$($job.GetLastResult())"; "Target" = "$($esxi.Name)";
      "Datastore" = "$($job.ViReplicaTargetOptions.DatastoreName)"; 
      "StorageInfo" = "$('{0:N2}' -f $($dtstr.FreeSpace / 1GB))GB/$('{0:N2}' -f $($dtstr.Capacity / 1GB))GB"}
      $output = New-Object -TypeName PSObject -Property $hashy
   }
   End {
   $output
   }
}
Get-VBRJob | ?{$_.IsReplica} | %{Get-vPCReplicaStuff $_.Name} | 
Select Job, Type, Name, State, Result, Target, Datastore, Storageinfo | 
ConvertTo-HTML -head $html | Out-File $file
Invoke-Expression $file
- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hello, 
Thank you, I run it it runs fine without any issue. But when I open the Test.htm nothing appears.
Thanks,
			
			
									
						
										
						Thank you, I run it it runs fine without any issue. But when I open the Test.htm nothing appears.
Thanks,
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
Are you on v5 or v6 Veeam b&r? And your saving it and running it on the Veeam server? seems to work fine on mine
			
			
									
						
										
						- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
Hello, 
I'm on version 5, and yes i'm saving it on veeam machine and C:\Scripts folder on veeam machine as well.
			
			
									
						
										
						I'm on version 5, and yes i'm saving it on veeam machine and C:\Scripts folder on veeam machine as well.
- 
				ThomasMc
 - Veteran
 - Posts: 293
 - Liked: 19 times
 - Joined: Apr 13, 2011 12:45 pm
 - Full Name: Thomas McConnell
 - Contact:
 
Re: Get-VBRReplica
well I can't help you there, sorry, this uses the v6 parameters and new cmdlets and I don't run v5 to rewrite it for that
			
			
									
						
										
						- 
				Gostev
 - Chief Product Officer
 - Posts: 32792
 - Liked: 7994 times
 - Joined: Jan 01, 2006 1:01 am
 - Location: Baar, Switzerland
 - Contact:
 
Re: Get-VBRReplica
Yes another good reason to upgrade!
			
			
									
						
										
						- 
				habibalby
 - Veteran
 - Posts: 392
 - Liked: 34 times
 - Joined: Jul 18, 2011 9:30 am
 - Full Name: Hussain Al Sayed
 - Location: Bahrain
 - Contact:
 
Re: Get-VBRReplica
will plan that... Thanks a lot for your great help.. Highly appreciated.
			
			
									
						
										
						Who is online
Users browsing this forum: Semrush [Bot] and 7 guests