Skip to content

Commit a61455e

Browse files
committed
v1.3.0 final
* Fix vCenter user privilege check * Fix vCenter Tag reporting
1 parent b08dbdd commit a61455e

File tree

6 files changed

+91
-65
lines changed

6 files changed

+91
-65
lines changed

.github/workflows/PublishPSModule.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/Release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Publish PowerShell Module
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-to-gallery:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Publish
13+
shell: pwsh
14+
run: |
15+
Publish-Module -Path ./ -NuGetApiKey ${{ secrets.PSGALLERY_API_KEY }} -Verbose

AsBuiltReport.VMware.vSphere.Style.ps1

Lines changed: 11 additions & 7 deletions
Large diffs are not rendered by default.

AsBuiltReport.VMware.vSphere.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
PSData = @{
9898
# Tags applied to this module. These help with module discovery in online galleries.
99-
Tags = 'AsBuiltReport', 'Report', 'VMware', 'vSphere', 'Documentation', 'PScribo', 'PSEdition_Desktop', 'Windows', 'MacOS', 'Linux'
99+
Tags = 'AsBuiltReport', 'Report', 'VMware', 'vSphere', 'vCenter', 'Documentation', 'PScribo', 'PSEdition_Desktop', 'PSEdition_Core', 'Windows', 'MacOS', 'Linux'
100100

101101
# A URL to the license for this module.
102102
LicenseUri = 'https://raw.githubusercontent.com/AsBuiltReport/AsBuiltReport.VMware.vSphere/master/LICENSE'

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,23 @@ Below are the instructions on how to install, configure and generate a VMware vS
4343

4444
### VMware vSphere
4545
The VMware vSphere As Built Report supports the following vSphere versions;
46-
- vSphere 5.5
47-
- vSphere 6.0
4846
- vSphere 6.5
4947
- vSphere 6.7
5048
- vSphere 7.0
5149

50+
#### End of Support
51+
The following VMware vSphere versions are no longer being tested and/or supported;
52+
- vSphere 5.5
53+
- vSphere 6.0
54+
5255
### PowerShell
5356
This report is compatible with the following PowerShell versions;
5457

55-
| Windows PowerShell 5.1 | PowerShell 7 |
58+
| Windows PowerShell 5.1 | PowerShell 7 ^ |
5659
|:----------------------:|:--------------------:|
5760
| :white_check_mark: | :white_check_mark: |
5861

59-
_Note: Due to compatibility issues, VMware Update Manager information will not be reported when using PowerShell 7_
62+
^ _Due to compatibility issues, VMware Update Manager information will not be reported when using PowerShell 7_
6063

6164
## :wrench: System Requirements
6265
PowerShell 5.1 or PowerShell 7, and the following PowerShell modules are required for generating a VMware vSphere As Built report.
@@ -66,9 +69,17 @@ Each of these modules can be easily downloaded and installed via the PowerShell
6669
- [VMware PowerCLI Module](https://www.powershellgallery.com/packages/VMware.PowerCLI/)
6770
- [AsBuiltReport.VMware.vSphere Module](https://www.powershellgallery.com/packages/AsBuiltReport.VMware.vSphere/)
6871

72+
### Linux & macOS
73+
* .NET Core is required for cover page image support on Linux and macOS operating systems.
74+
* [Installing .NET Core for macOS](https://docs.microsoft.com/en-us/dotnet/core/install/macos)
75+
* [Installing .NET Core for Linux](https://docs.microsoft.com/en-us/dotnet/core/install/linux)
76+
77+
❗ If you are unable to install .NET Core, you must set `ShowCoverPageImage` to `False` in the report JSON configuration file.
78+
79+
6980
### :closed_lock_with_key: Required Privileges
7081

71-
A VMware vSphere As Built Report can be generated with read only privileges, however the following sections will be skipped;
82+
A VMware vSphere As Built Report can be generated with read-only privileges, however the following sections will be skipped;
7283

7384
* vSphere licensing information
7485
* VM Storage Policy information
@@ -142,20 +153,20 @@ There are 6 levels (0-5) of detail granularity for each section as follows;
142153
| 4 | Adv Detailed | Provides detailed information for individual objects, as well as information for associated objects (Hosts, Clusters, Datastores, VMs etc) |
143154
| 5 | Comprehensive | Provides comprehensive information for individual objects, such as advanced configuration settings |
144155

145-
The table below outlines the default, minimum and maximum **InfoLevel** settings for each section.
146-
147-
| Sub-Schema | Default Setting | Minimum Setting | Maximum Setting |
148-
|--------------|:---------------:|:---------------:|:---------------:|
149-
| vCenter | 3 | 1 | 5 |
150-
| Cluster | 3 | 1 | 4 |
151-
| ResourcePool | 3 | 1 | 4 |
152-
| VMHost | 3 | 1 | 5 |
153-
| Network | 3 | 1 | 4 |
154-
| vSAN | 3 | 1 | 4 |
155-
| Datastore | 3 | 1 | 4 |
156-
| DSCluster | 3 | 1 | 4 |
157-
| VM | 2 | 1 | 4 |
158-
| VUM | 3 | 3 | 5 |
156+
The table below outlines the default and maximum **InfoLevel** settings for each section.
157+
158+
| Sub-Schema | Default Setting | Maximum Setting |
159+
|--------------|:---------------:|:---------------:|
160+
| vCenter | 3 | 5 |
161+
| Cluster | 3 | 4 |
162+
| ResourcePool | 3 | 4 |
163+
| VMHost | 3 | 5 |
164+
| Network | 3 | 4 |
165+
| vSAN | 3 | 4 |
166+
| Datastore | 3 | 4 |
167+
| DSCluster | 3 | 4 |
168+
| VM | 2 | 4 |
169+
| VUM | 3 | 5 |
159170

160171
### Healthcheck
161172
The **Healthcheck** schema is used to toggle health checks on or off.

Src/Public/Invoke-AsBuiltReport.VMware.vSphere.ps1

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,14 @@ function Invoke-AsBuiltReport.VMware.vSphere {
5555
#region Generate vSphere report
5656
if ($vCenter) {
5757
# Check logged in user has sufficient privileges to generate an As Built Report
58-
Write-PScriboMessage 'Checking user privileges.'
59-
$UserPermission = Get-VIPermission | Where-Object {$_.Principal -eq $vCenter.User}
60-
$UserRole = Get-VIRole -Name $UserPermission.Role
58+
Write-PScriboMessage 'Checking vCenter user privileges.'
59+
Try {
60+
$UserPermission = Get-VIPermission | Where-Object {$_.Principal -eq $vCenter.User}
61+
$AuthMgr = Get-View $($vCenter.ExtensionData.Content.AuthorizationManager)
62+
$UserRole = $AuthMgr.RoleList | Where-Object {$_.Name -eq $($UserPermission.Role)}
63+
} Catch {
64+
Write-PScriboMessage 'Unable to obtain vCenter user privileges.'
65+
}
6166

6267
# Create a lookup hashtable to quickly link VM MoRefs to Names
6368
# Exclude VMware Site Recovery Manager placeholder VMs
@@ -195,7 +200,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
195200
'MemberType' = 'NoteProperty'
196201
}
197202
#region vCenter Server Detail
198-
if ($UserRole.PrivilegeList -contains 'Global.Licenses') {
203+
if ($UserRole.Privilege -contains 'Global.Licenses') {
199204
$vCenterLicense = Get-License -vCenter $vCenter
200205
Add-Member @MemberProps -Name 'Product' -Value $vCenterLicense.Product
201206
Add-Member @MemberProps -Name 'License Key' -Value $vCenterLicense.LicenseKey
@@ -299,7 +304,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
299304
#endregion vCenter Server Historical Statistics
300305

301306
#region vCenter Server Licensing
302-
if ($UserRole.PrivilegeList -contains 'Global.Licenses') {
307+
if ($UserRole.Privilege -contains 'Global.Licenses') {
303308
Section -Style Heading3 'Licensing' {
304309
$Licenses = Get-License -Licenses | Select-Object Product, @{L = 'License Key'; E = { ($_.LicenseKey) } }, Total, Used, @{L = 'Available'; E = { ($_.total) - ($_.Used) } }, Expiration -Unique
305310
if ($Healthcheck.vCenter.Licensing) {
@@ -396,8 +401,14 @@ function Invoke-AsBuiltReport.VMware.vSphere {
396401
$TagInfo = foreach ($Tag in $Tags) {
397402
[PSCustomObject] @{
398403
'Tag' = $Tag.Name
399-
'Description' = $Tag.Description
400-
'Category' = $Tag.Category
404+
'Description' = Switch ($Tag.Description) {
405+
'' { 'None' }
406+
default { $Tag.Description }
407+
}
408+
'Category' = Switch ($Tag.Category) {
409+
'' { 'None' }
410+
default { $Tag.Category }
411+
}
401412
}
402413
}
403414
$TableParams = @{
@@ -418,8 +429,14 @@ function Invoke-AsBuiltReport.VMware.vSphere {
418429
$TagCategoryInfo = foreach ($TagCategory in $TagCategories) {
419430
[PSCustomObject] @{
420431
'Category' = $TagCategory.Name
421-
'Description' = $TagCategory.Description
422-
'Cardinality' = $TagCategory.Cardinality
432+
'Description' = Switch ($TagCategory.Description) {
433+
'' { 'None' }
434+
default { $TagCategory.Description }
435+
}
436+
'Cardinality' = Switch ($TagCategory.Cardinality) {
437+
'' { 'None' }
438+
default { $TagCategory.Cardinality }
439+
}
423440
}
424441
}
425442
$TableParams = @{
@@ -457,7 +474,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
457474
#endregion vCenter Server Tag Assignments
458475

459476
#region VM Storage Policies
460-
if ($UserRole.PrivilegeList -contains 'StorageProfile.View') {
477+
if ($UserRole.Privilege -contains 'StorageProfile.View') {
461478
$SpbmStoragePolicies = Get-SpbmStoragePolicy | Sort-Object Name
462479
if ($SpbmStoragePolicies) {
463480
Section -Style Heading3 'VM Storage Policies' {
@@ -1464,7 +1481,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
14641481
#endregion Cluster VM Overrides
14651482

14661483
#region Cluster VUM Baselines
1467-
if ($UserRole.PrivilegeList -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
1484+
if ($UserRole.Privilege -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
14681485
if ($VUMConnection) {
14691486
if ("Desktop" -eq $PSVersionTable.PsEdition) {
14701487
$ClusterPatchBaselines = $Cluster | Get-PatchBaseline
@@ -1512,7 +1529,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
15121529
#endregion Cluster VUM Baselines
15131530

15141531
#region Cluster VUM Compliance (Advanced Detail Information)
1515-
if ($UserRole.PrivilegeList -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
1532+
if ($UserRole.Privilege -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
15161533
if ($InfoLevel.Cluster -ge 4 -and $VumServer.Name) {
15171534
if ("Desktop" -eq $PSVersionTable.PsEdition) {
15181535
$ClusterCompliances = $Cluster | Get-Compliance
@@ -1819,7 +1836,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
18191836
'InputObject' = $VMHostDetail
18201837
'MemberType' = 'NoteProperty'
18211838
}
1822-
if ($UserRole.PrivilegeList -contains 'Global.Licenses') {
1839+
if ($UserRole.Privilege -contains 'Global.Licenses') {
18231840
$VMHostLicense = Get-License -VMHost $VMHost
18241841
Add-Member @MemberProps -Name 'Product' -Value $VMHostLicense.Product
18251842
Add-Member @MemberProps -Name 'License Key' -Value $VMHostLicense.LicenseKey
@@ -1950,7 +1967,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
19501967
#endregion ESXi Host Profile Information
19511968

19521969
#region ESXi Host Image Profile Information
1953-
if ($UserRole.PrivilegeList -contains 'Host.Config.Settings') {
1970+
if ($UserRole.Privilege -contains 'Host.Config.Settings') {
19541971
Section -Style Heading5 'Image Profile' {
19551972
$installdate = Get-InstallDate
19561973
$esxcli = Get-EsxCli -VMHost $VMHost -V2 -Server $vCenter
@@ -2017,7 +2034,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
20172034
#endregion ESXi Host Syslog Configuration
20182035

20192036
#region ESXi Update Manager Baseline Information
2020-
if ($UserRole.PrivilegeList -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
2037+
if ($UserRole.Privilege -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
20212038
if ($VumServer.Name) {
20222039
if ("Desktop" -eq $PSVersionTable.PsEdition) {
20232040
$VMHostPatchBaselines = $VMHost | Get-PatchBaseline
@@ -2053,7 +2070,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
20532070
#endregion ESXi Update Manager Baseline Information
20542071

20552072
#region ESXi Update Manager Compliance Information
2056-
if ($UserRole.PrivilegeList -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
2073+
if ($UserRole.Privilege -contains 'VcIntegrity.Updates.com.vmware.vcIntegrity.ViewStatus') {
20572074
if ($VumServer.Name) {
20582075
if ("Desktop" -eq $PSVersionTable.PsEdition) {
20592076
$VMHostCompliances = $VMHost | Get-Compliance
@@ -4158,7 +4175,7 @@ function Invoke-AsBuiltReport.VMware.vSphere {
41584175
#region Virtual Machine Detailed Information
41594176
# TODO: Test Tags
41604177
if ($InfoLevel.VM -ge 3) {
4161-
if ($UserRole.PrivilegeList -contains 'StorageProfile.View') {
4178+
if ($UserRole.Privilege -contains 'StorageProfile.View') {
41624179
$VMSpbmConfig = Get-SpbmEntityConfiguration -VM ($VMs) | Where-Object { $null -ne $_.StoragePolicy }
41634180
} else {
41644181
Write-PScriboMessage "Insufficient user privileges to report VM storage policies. Please ensure the user account has the 'Storage Profile > View' privilege assigned."

0 commit comments

Comments
 (0)