Skip to content

Commit

Permalink
Merge pull request #6 from AsBuiltReport/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tpcarman authored Dec 18, 2021
2 parents 2dec17e + b731ab0 commit 64495ab
Show file tree
Hide file tree
Showing 10 changed files with 530 additions and 156 deletions.
2 changes: 1 addition & 1 deletion AsBuiltReport.VMware.SRM.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AsBuiltReport.VMware.SRM.psm1'

# Version number of this module.
ModuleVersion = '0.2.0'
ModuleVersion = '0.3.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# :arrows_counterclockwise: VMware SRM As Built Report Changelog

## [0.3.0] - 2021-12-11

### Added

- Added VM hardware information:
- vCenter Server Inventory
- SRM Server Inventory
- Replication Server Inventory
- Added Function to convert from VIObject to Inventory Mapping

### Changed

- Improved Recovery Site vCenter status validation.
- Improved title structure

### Fixed

- Fixed credential issues. Closes [#4](https://github.com/AsBuiltReport/AsBuiltReport.VMware.SRM/issues/4)

## [0.2.0] - 2021-11-01

### Added
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ VMware SRM As Built Report is a PowerShell module which works in conjunction wit

Please refer to the AsBuiltReport [website](https://www.asbuiltreport.com) for more detailed information about this project.

# :books: Sample Reports

## Sample Report - Custom Style 1

Sample VMware SRM As Built report HTML file: [Sample VMware SRM As-Built Report.html](https://technomyth.zenprsolutions.net/wp-content/uploads/2021/12/Sample-VMware-SRM-As-Built-Report.html)

# :beginner: Getting Started

Below are the instructions on how to install, configure and generate a VMware SRM As Built report.
Expand Down
97 changes: 52 additions & 45 deletions Src/Private/Get-AbrSRMInventoryMapping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrSRMInventoryMapping {
.DESCRIPTION
.NOTES
Version: 0.2.0
Version: 0.3.0
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -34,8 +34,8 @@ function Get-AbrSRMInventoryMapping {
foreach ($ObjMap in $Mapping) {
$HashObj = $Null
Write-PscriboMessage "Discovered Folder Mapping information for $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
$LocalObj = get-view $ObjMap.PrimaryObject | Select-Object -ExpandProperty Name -Unique
$RemoteObj = get-view $ObjMap.SecondaryObject | Select-Object -ExpandProperty Name -Unique
$LocalObj = ConvertTo-VIobject $ObjMap.PrimaryObject
$RemoteObj = ConvertTo-VIobject $ObjMap.SecondaryObject
$HashObj = @{
$LocalObj = $RemoteObj
}
Expand Down Expand Up @@ -70,8 +70,8 @@ function Get-AbrSRMInventoryMapping {
$HashObj = $Null
foreach ($ObjMap in $Mapping) {
Write-PscriboMessage "Discovered Network Mapping information for $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
$LocalObj = get-view $ObjMap.PrimaryObject | Select-Object -ExpandProperty Name -Unique
$RemoteObj = get-view $ObjMap.SecondaryObject | Select-Object -ExpandProperty Name -Unique
$LocalObj = ConvertTo-VIobject $ObjMap.PrimaryObject
$RemoteObj = ConvertTo-VIobject $ObjMap.SecondaryObject
$HashObj = @{
$LocalObj = $RemoteObj
}
Expand Down Expand Up @@ -106,8 +106,8 @@ function Get-AbrSRMInventoryMapping {
$HashObj = $Null
foreach ($ObjMap in $Mapping) {
Write-PscriboMessage "Discovered Resources Mapping information for $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
$LocalObj = get-view $ObjMap.PrimaryObject | Select-Object -ExpandProperty Name -Unique
$RemoteObj = get-view $ObjMap.SecondaryObject | Select-Object -ExpandProperty Name -Unique
$LocalObj = ConvertTo-VIobject $ObjMap.PrimaryObject
$RemoteObj = ConvertTo-VIobject $ObjMap.SecondaryObject
$HashObj = @{
$LocalObj = $RemoteObj
}
Expand Down Expand Up @@ -139,52 +139,59 @@ function Get-AbrSRMInventoryMapping {
Write-PscriboMessage -IsWarning $_.Exception.Message
}
try {
$Mapping = $LocalSRM.ExtensionData.PlaceholderDatastoreManager.GetPlaceholderDatastores()
Section -Style Heading3 'Placeholder Datastore Mappings' {
if ($Options.ShowDefinitionInfo) {
Paragraph "For each protected virtual machine Site Recovery Manager creates a placeholder virtual machine at the recovery site. Placeholder virtual machines are contained in a datastore and registered with the vCenter Server at the recovery site. This datastore is called the placeholder datastore. Since placeholder virtual machines do not have virtual disks they consume a minimal amount of storage"
if ($RemotevCenter) {
$Mapping = $LocalSRM.ExtensionData.PlaceholderDatastoreManager.GetPlaceholderDatastores()
Section -Style Heading3 'Placeholder Datastore Mappings' {
if ($Options.ShowDefinitionInfo) {
Paragraph "For each protected virtual machine Site Recovery Manager creates a placeholder virtual machine at the recovery site. Placeholder virtual machines are contained in a datastore and registered with the vCenter Server at the recovery site. This datastore is called the placeholder datastore. Since placeholder virtual machines do not have virtual disks they consume a minimal amount of storage"
BlankLine
}
Paragraph "The following section provides a summary of the Placeholder Datastore Mapping on Site $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
BlankLine
}
Paragraph "The following section provides a summary of the Placeholder Datastore Mapping on Site $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
BlankLine
$OutObj = @()
if ($Mapping) {
foreach ($ObjMap in $Mapping) {
#//Todo "How the fuck i can extract remote PlaceHolder Datastore Info"
Write-PscriboMessage "Discovered Placeholder Datastore Mapping information for $($ObjMap.Name) on $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
$inObj = [ordered] @{
"Name" = $ObjMap.Name
"Datastore Type" = $ObjMap.Type
"Capacity" = "$([math]::Round(($ObjMap.Capacity)/ 1GB, 2)) GB"
"Free Space" = "$([math]::Round(($ObjMap.FreeSpace)/ 1GB, 2)) GB"
"Reserved Space" = "$([math]::Round(($ObjMap.ReservedSpace)/ 1GB, 2)) GB"
"Location" = get-view $ObjMap.VisibleTo.key | Select-Object -ExpandProperty Name -Unique
"Fault" = ConvertTo-EmptyToFiller $ObjMap.Fault
"Status" = SWitch ($ObjMap.Status) {
"green" {"OK"}
"orange" {"Warning"}
"red" {"Critical"}
default {$ObjMap.Status}
$OutObj = @()
if ($Mapping) {
foreach ($ObjMap in $Mapping) {
#//Todo "How the fuck i can extract remote PlaceHolder Datastore Info"
Write-PscriboMessage "Discovered Placeholder Datastore Mapping information for $($ObjMap.Name) on $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
$inObj = [ordered] @{
"Name" = $ObjMap.Name
"Datastore Type" = $ObjMap.Type
"Capacity" = "$([math]::Round(($ObjMap.Capacity)/ 1GB, 2)) GB"
"Free Space" = "$([math]::Round(($ObjMap.FreeSpace)/ 1GB, 2)) GB"
"Reserved Space" = "$([math]::Round(($ObjMap.ReservedSpace)/ 1GB, 2)) GB"
"Location" = ConvertTo-VIobject $ObjMap.VisibleTo.key
"Fault" = Switch ($ObjMap.Fault) {
"" {"-"; break}
$Null {"-"; break}
default {$ObjMap.Fault}
}
"Status" = Switch ($ObjMap.Status) {
"green" {"OK"}
"orange" {"Warning"}
"red" {"Critical"}
default {$ObjMap.Status}
}
}
$OutObj += [pscustomobject]$inobj
}
$OutObj += [pscustomobject]$inobj
}
}

if ($Healthcheck.InventoryMapping.Status) {
$OutObj | Where-Object { $_.'Status' -ne 'OK'} | Set-Style -Style Warning -Property 'Status'
}
if ($Healthcheck.InventoryMapping.Status) {
$OutObj | Where-Object { $_.'Status' -ne 'OK'} | Set-Style -Style Warning -Property 'Status'
}

$TableParams = @{
Name = "Placeholder Datastore Mappings - $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)"
List = $true
ColumnWidths = 50, 50
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
$TableParams = @{
Name = "Placeholder Datastore Mappings - $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)"
List = $true
ColumnWidths = 50, 50
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
}
$OutObj | Table @TableParams
}
$OutObj | Table @TableParams
}
else {Write-PscriboMessage -IsWarning "No Recovery Site vCenter connection has been detected. Deactivating placeholder datastore mappings section"}
}
catch {
Write-PscriboMessage -IsWarning $_.Exception.Message
Expand Down
45 changes: 44 additions & 1 deletion Src/Private/Get-AbrSRMProtectedSiteInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function Get-AbrSRMProtectedSiteInfo {
.DESCRIPTION
.NOTES
Version: 0.2.0
Version: 0.3.0
Author: Jonathan Colon
Twitter: @jcolonfzenpr
Github: rebelinux
Expand Down Expand Up @@ -64,6 +64,49 @@ function Get-AbrSRMProtectedSiteInfo {
$TableParams['Caption'] = "- $($TableParams.Name)"
}
$OutObj | Table @TableParams
try {
$LocalSRMFQDM = $LocalSRM.Name
$LocalSRMHostName = $LocalSRMFQDM.Split(".")[0]
if ($LocalSRMFQDM) {
$LocalSRMVM = Get-VM * -Server $LocalvCenter | where-object {$_.Guest.HostName -match $LocalSRMFQDM}
}
elseif (!$LocalSRMVM) {
$LocalSRMVM = Get-VM * -Server $LocalvCenter | where-object {$_.Guest.VmName -match $LocalSRMHostName}
}
if ($LocalSRMVM) {
Section -Style Heading4 "SRM Server VM Properties" {
Paragraph "The following section provides the hardware properties of the Protected Site $($LocalSRM.ExtensionData.GetLocalSiteInfo().SiteName)."
BlankLine
$OutObj = @()
Write-PscriboMessage "Discovered SRM VM Properties $($LocalSRMVM.Name)."
$inObj = [ordered] @{
'VM Name' = $LocalSRMVM.Name
'Number of CPUs' = $LocalSRMVM.NumCpu
'Cores Per Socket' = $LocalSRMVM.CoresPerSocket
'Memory in GB' = $LocalSRMVM.MemoryGB
'Host' = $LocalSRMVM.VMHost
'Guest Id' = $LocalSRMVM.GuestId
'Provisioned Space GB' = "$([math]::Round(($LocalSRMVM.ProvisionedSpaceGB)))"
'Used Space GB' = "$([math]::Round(($LocalSRMVM.UsedSpaceGB)))"
'Datastores' = $LocalSRMVM.DatastoreIdList | ForEach-Object {get-view $_ -Server $LocalvCenter | Select-Object -ExpandProperty Name}
}
$OutObj += [pscustomobject]$inobj

$TableParams = @{
Name = "SRM VM Properties - $($LocalSRMVM.Name)"
List = $true
ColumnWidths = 40, 60
}
if ($Report.ShowTableCaptions) {
$TableParams['Caption'] = "- $($TableParams.Name)"
}
$OutObj | Table @TableParams
}
}
}
catch {
Write-PscriboMessage -IsWarning $_.Exception.Message
}
}
}
catch {
Expand Down
Loading

0 comments on commit 64495ab

Please sign in to comment.