Skip to content

Commit 554265f

Browse files
authored
Merge pull request #82 from tpcarman/dev
v1.2.0 release
2 parents 036866e + fc03637 commit 554265f

16 files changed

+1732
-889
lines changed

AsBuiltReport.VMware.vSphere.Style.ps1

Lines changed: 47 additions & 19 deletions
Large diffs are not rendered by default.

AsBuiltReport.VMware.vSphere.json

312 Bytes
Binary file not shown.

AsBuiltReport.VMware.vSphere.psd1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'AsBuiltReport.VMware.vSphere.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.1.4'
15+
ModuleVersion = '1.2.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Desktop'
@@ -48,7 +48,12 @@
4848
# ProcessorArchitecture = ''
4949

5050
# Modules that must be imported into the global environment prior to importing this module
51-
RequiredModules = @('AsBuiltReport.Core')
51+
RequiredModules = @(
52+
@{
53+
ModuleName = 'AsBuiltReport.Core';
54+
ModuleVersion = '1.1.0'
55+
}
56+
)
5257

5358
# Assemblies that must be loaded prior to importing this module
5459
# RequiredAssemblies = @()

AsBuiltReport.VMware.vSphere.psm1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Get public function definition files and dot source them
2-
$Public = @(Get-ChildItem -Path $PSScriptRoot\Src\Public\*.ps1)
1+
# Get public and private function definition files and dot source them
2+
$Public = @(Get-ChildItem -Path $PSScriptRoot\Src\Public\*.ps1 -ErrorAction SilentlyContinue)
3+
$Private = @(Get-ChildItem -Path $PSScriptRoot\Src\Private\*.ps1 -ErrorAction SilentlyContinue)
34

4-
foreach ($Module in $Public) {
5+
foreach ($Module in @($Public + $Private)) {
56
try {
67
. $Module.FullName
78
} catch {
@@ -10,3 +11,4 @@ foreach ($Module in $Public) {
1011
}
1112

1213
Export-ModuleMember -Function $Public.BaseName
14+
Export-ModuleMember -Function $Private.BaseName

CHANGELOG.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
# VMware vSphere As Built Report Changelog
1+
# :arrows_counterclockwise: VMware vSphere As Built Report Changelog
22

3-
## [Unreleased]
3+
## [1.2.0] - 2020-08-31
44
### Added
5-
- vCenter Server database version
65
- vCenter Server advanced system settings
76
- vCenter Server alarm health check
87
- Basic VM storage policy reporting
8+
- Headers, footers & table captions/numbering
99

1010
### Changed
11+
- Improved table formatting
1112
- Enhanced vCenter alarm reporting
1213
- Changed Tag Assignment section to separate the category and tag to their own table columns
1314
- Changed Tag Assignment section to sort on Entity
15+
- Renamed InfoLevel `Informative` to `Adv Summary`
16+
- Moved script functions from main script to private functions
1417

1518
### Fixed
1619
- Section error with vSAN InfoLevel 4 or above
17-
- Corrected text color for highlighted cells in default VMware style
20+
- Fixed text color for highlighted cells in default VMware style
1821
- Fixed reporting of stateless boot devices (Fix #76)
1922
- Fixed issue where script was failing trying to parse vSphere Tag data (Fix #77)
23+
- Fixed issue with reporting on PCI-E device drivers by adding additional filter (Fix #75)
2024

21-
## [1.1.3 - 2020-02-04]
25+
## [1.1.3] - 2020-02-04
2226
### Added
2327
- Added vCenter Server certificate information (Fix #31)
2428
- Added VM summary information
@@ -113,7 +117,7 @@
113117
- Improved VM reporting for Guest OS, CPU Hot Add/Remove, Memory Hot Add & Change Block Tracking
114118
- Minor updates to section paragraph text
115119

116-
## 0.2.1
120+
## [0.2.1]
117121
### Added
118122
- Added SDRS VM Overrides to Datastore Cluster section
119123

@@ -124,7 +128,7 @@
124128
- Script formatting improvements to some sections to align with PowerShell best practice guidelines
125129
- vCenter Server SSL Certificate section removed temporarily
126130

127-
## 0.2.0
131+
## [0.2.0]
128132
### Added
129133
- Added regions/endregions to all sections of script
130134
- Added Resource Pool summary information

README.md

Lines changed: 161 additions & 158 deletions
Large diffs are not rendered by default.
72.6 KB
Loading

Src/Private/Get-ESXiBootDevice.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
function Get-ESXiBootDevice {
2+
<#
3+
.NOTES
4+
===========================================================================
5+
Created by: William Lam
6+
Organization: VMware
7+
Blog: www.virtuallyghetto.com
8+
Twitter: @lamw
9+
===========================================================================
10+
.DESCRIPTION
11+
This function identifies how an ESXi host was booted up along with its boot
12+
device (if applicable). This supports both local installation to Auto Deploy as
13+
well as Boot from SAN.
14+
.PARAMETER VMHostname
15+
The name of an individual ESXi host managed by vCenter Server
16+
.EXAMPLE
17+
Get-ESXiBootDevice
18+
.EXAMPLE
19+
Get-ESXiBootDevice -VMHost esxi-01
20+
#>
21+
param(
22+
[Parameter(Mandatory = $false)][PSObject]$VMHost
23+
)
24+
25+
$results = @()
26+
$esxcli = Get-EsxCli -V2 -VMHost $VMHost -Server $vCenter
27+
$bootDetails = $esxcli.system.boot.device.get.Invoke()
28+
29+
# Check to see if ESXi booted over the network
30+
$networkBoot = $false
31+
if ($bootDetails.BootNIC) {
32+
$networkBoot = $true
33+
$bootDevice = $bootDetails.BootNIC
34+
} elseif ($bootDetails.StatelessBootNIC) {
35+
$networkBoot = $true
36+
$bootDevice = $bootDetails.StatelessBootNIC
37+
}
38+
39+
# If ESXi booted over network, check to see if deployment
40+
# is Stateless, Stateless w/Caching or Stateful
41+
if ($networkBoot) {
42+
$option = $esxcli.system.settings.advanced.list.CreateArgs()
43+
$option.option = "/UserVars/ImageCachedSystem"
44+
try {
45+
$optionValue = $esxcli.system.settings.advanced.list.Invoke($option)
46+
} catch {
47+
$bootType = "Stateless"
48+
}
49+
$bootType = $optionValue.StringValue
50+
}
51+
52+
# Loop through all storage devices to identify boot device
53+
$devices = $esxcli.storage.core.device.list.Invoke()
54+
$foundBootDevice = $false
55+
foreach ($device in $devices) {
56+
if ($device.IsBootDevice -eq $true) {
57+
$foundBootDevice = $true
58+
59+
if ($device.IsLocal -eq $true -and $networkBoot -and $bootType -ne "Stateful") {
60+
$bootType = "Stateless Caching"
61+
} elseif ($device.IsLocal -eq $true -and $networkBoot -eq $false) {
62+
$bootType = "Local"
63+
} elseif ($device.IsLocal -eq $false -and $networkBoot -eq $false) {
64+
$bootType = "Remote"
65+
}
66+
67+
$bootDevice = $device.Device
68+
$bootModel = $device.Model
69+
$bootVendor = $device.VEndor
70+
$bootSize = $device.Size
71+
$bootIsSAS = $TextInfo.ToTitleCase($device.IsSAS)
72+
$bootIsSSD = $TextInfo.ToTitleCase($device.IsSSD)
73+
$bootIsUSB = $TextInfo.ToTitleCase($device.IsUSB)
74+
}
75+
}
76+
77+
# Pure Stateless (e.g. No USB or Disk for boot)
78+
if ($networkBoot -and $foundBootDevice -eq $false) {
79+
$bootModel = "N/A"
80+
$bootVendor = "N/A"
81+
$bootSize = "N/A"
82+
$bootIsSAS = "N/A"
83+
$bootIsSSD = "N/A"
84+
$bootIsUSB = "N/A"
85+
}
86+
87+
$tmp = [PSCustomObject]@{
88+
Host = $vmhost.Name;
89+
Device = $bootDevice;
90+
BootType = $bootType;
91+
Vendor = $bootVendor;
92+
Model = $bootModel;
93+
SizeMB = $bootSize;
94+
IsSAS = $bootIsSAS;
95+
IsSSD = $bootIsSSD;
96+
IsUSB = $bootIsUSB;
97+
}
98+
$results += $tmp
99+
$results
100+
}

Src/Private/Get-InstallDate.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function Get-InstallDate {
2+
$esxcli = Get-EsxCli -VMHost $VMHost -V2 -Server $vCenter
3+
$thisUUID = $esxcli.system.uuid.get.Invoke()
4+
$decDate = [Convert]::ToInt32($thisUUID.Split("-")[0], 16)
5+
$installDate = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($decDate))
6+
[PSCustomObject][Ordered]@{
7+
Name = $VMHost.Name
8+
InstallDate = $installDate
9+
}
10+
}

Src/Private/Get-License.ps1

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
function Get-License {
2+
<#
3+
.SYNOPSIS
4+
Function to retrieve vSphere product licensing information.
5+
.DESCRIPTION
6+
Function to retrieve vSphere product licensing information.
7+
.NOTES
8+
Version: 0.2.0
9+
Author: Tim Carman
10+
Twitter: @tpcarman
11+
Github: tpcarman
12+
.PARAMETER VMHost
13+
A vSphere ESXi Host object
14+
.PARAMETER vCenter
15+
A vSphere vCenter Server object
16+
.PARAMETER Licenses
17+
All vSphere product licenses
18+
.INPUTS
19+
System.Management.Automation.PSObject.
20+
.OUTPUTS
21+
System.Management.Automation.PSObject.
22+
.EXAMPLE
23+
Get-License -VMHost ESXi01
24+
.EXAMPLE
25+
Get-License -vCenter VCSA
26+
.EXAMPLE
27+
Get-License -Licenses
28+
#>
29+
[CmdletBinding()][OutputType('System.Management.Automation.PSObject')]
30+
31+
Param
32+
(
33+
[Parameter(Mandatory = $false, ValueFromPipeline = $false)]
34+
[ValidateNotNullOrEmpty()]
35+
[PSObject]$vCenter,
36+
[PSObject]$VMHost,
37+
[Parameter(Mandatory = $false, ValueFromPipeline = $false)]
38+
[Switch]$Licenses
39+
)
40+
41+
$LicenseObject = @()
42+
$ServiceInstance = Get-View ServiceInstance -Server $vCenter
43+
$LicenseManager = Get-View $ServiceInstance.Content.LicenseManager -Server $vCenter
44+
$LicenseManagerAssign = Get-View $LicenseManager.LicenseAssignmentManager -Server $vCenter
45+
if ($VMHost) {
46+
$VMHostId = $VMHost.Extensiondata.Config.Host.Value
47+
$VMHostAssignedLicense = $LicenseManagerAssign.QueryAssignedLicenses($VMHostId)
48+
$VMHostLicense = $VMHostAssignedLicense.AssignedLicense
49+
$VMHostLicenseExpiration = ($VMHostLicense.Properties | Where-Object { $_.Key -eq 'expirationDate' } | Select-Object Value).Value
50+
if ($VMHostLicense.LicenseKey -and $Options.ShowLicenseKeys) {
51+
$VMHostLicenseKey = $VMHostLicense.LicenseKey
52+
} else {
53+
$VMHostLicenseKey = "*****-*****-*****" + $VMHostLicense.LicenseKey.Substring(17)
54+
}
55+
$LicenseObject = [PSCustomObject]@{
56+
Product = $VMHostLicense.Name
57+
LicenseKey = $VMHostLicenseKey
58+
Expiration =
59+
if ($VMHostLicenseExpiration -eq $null) {
60+
"Never"
61+
} elseif ($VMHostLicenseExpiration -gt (Get-Date)) {
62+
$VMHostLicenseExpiration.ToShortDateString()
63+
} else {
64+
"Expired"
65+
}
66+
}
67+
}
68+
if ($vCenter) {
69+
$vCenterAssignedLicense = $LicenseManagerAssign.GetType().GetMethod("QueryAssignedLicenses").Invoke($LicenseManagerAssign, @($_.MoRef.Value)) | Where-Object { $_.EntityID -eq $vCenter.InstanceUuid }
70+
$vCenterLicense = $vCenterAssignedLicense.AssignedLicense
71+
$vCenterLicenseExpiration = ($vCenterLicense.Properties | Where-Object { $_.Key -eq 'expirationDate' } | Select-Object Value).Value
72+
if ($vCenterLicense.LicenseKey -and $Options.ShowLicenseKeys) {
73+
$vCenterLicenseKey = $vCenterLicense.LicenseKey
74+
} else {
75+
$vCenterLicenseKey = "*****-*****-*****" + $vCenterLicense.LicenseKey.Substring(17)
76+
}
77+
$LicenseObject = [PSCustomObject]@{
78+
Product = $vCenterLicense.Name
79+
LicenseKey = $vCenterLicenseKey
80+
Expiration =
81+
if ($vCenterLicenseExpiration -eq $null) {
82+
"Never"
83+
} elseif ($vCenterLicenseExpiration -gt (Get-Date)) {
84+
$vCenterLicenseExpiration.ToShortDateString()
85+
} else {
86+
"Expired"
87+
}
88+
}
89+
}
90+
if ($Licenses) {
91+
foreach ($License in ($LicenseManager.Licenses | Where-Object { $_.licensekey -ne '' })) {
92+
$Object = @()
93+
$LicenseExpiration = $License.Properties | Where-Object { $_.Key -eq 'expirationDate' } | Select-Object -ExpandProperty Value
94+
if ($Options.ShowLicenseKeys) {
95+
$LicenseKey = $License.LicenseKey
96+
} else {
97+
$LicenseKey = "*****-*****-*****" + $License.LicenseKey.Substring(17)
98+
}
99+
$Object = [PSCustomObject]@{
100+
'License' = $License.License
101+
'Product' = $License.Name
102+
'LicenseKey' = $LicenseKey
103+
'Total' = $License.Total
104+
'Used' = Switch ($License.Used) {
105+
$null { "0" }
106+
default { $License.Used }
107+
}
108+
'Expiration' =
109+
if ($LicenseExpiration -eq $null) {
110+
"Never"
111+
} elseif ($LicenseExpiration -gt (Get-Date)) {
112+
$LicenseExpiration.ToShortDateString()
113+
} else {
114+
"Expired"
115+
}
116+
}
117+
$LicenseObject += $Object
118+
}
119+
}
120+
Write-Output $LicenseObject
121+
}

0 commit comments

Comments
 (0)