Skip to content

Commit 5da9a99

Browse files
committed
fix: resolve all PSScriptAnalyzer warnings and compliance issues
- Replace Write-Host with Write-Information in Test-NoRebootCompatibility.ps1 - Remove trailing whitespace from all PowerShell scripts - Add UTF-8 BOM encoding for Unicode compliance - Ensure all scripts pass PSScriptAnalyzer validation with no warnings or errors - Maintain professional PowerShell coding standards All PowerShell scripts now fully compliant with PSScriptAnalyzer requirements.
1 parent 8d05455 commit 5da9a99

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

scripts/Test-NoRebootCompatibility.ps1

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
VMware Tools No-Reboot Compatibility Checker
4-
4+
55
.DESCRIPTION
66
This script tests virtual machines for compatibility with no-reboot VMware Tools upgrades.
77
It validates VM state, Tools version, and system requirements.
8-
8+
99
.PARAMETER vCenter
1010
vCenter Server FQDN or IP address
11-
11+
1212
.PARAMETER VMName
1313
Specific VM name to test
14-
14+
1515
.EXAMPLE
1616
.\Test-NoRebootCompatibility.ps1 -vCenter "vcenter.example.com" -VMName "VM-001"
17-
17+
1818
.NOTES
1919
Author: uldyssian-sh
2020
Version: 1.0.0
@@ -24,7 +24,7 @@
2424
param(
2525
[Parameter(Mandatory = $true)]
2626
[string]$vCenter,
27-
27+
2828
[Parameter(Mandatory = $true)]
2929
[string]$VMName
3030
)
@@ -34,23 +34,23 @@ Import-Module VMware.PowerCLI -ErrorAction Stop
3434
try {
3535
Connect-VIServer -Server $vCenter
3636
$vm = Get-VM -Name $VMName
37-
38-
Write-Host "=== No-Reboot Compatibility Check ===" -ForegroundColor Cyan
39-
Write-Host "VM: $($vm.Name)" -ForegroundColor White
40-
Write-Host "Power State: $($vm.PowerState)" -ForegroundColor White
41-
Write-Host "Tools Status: $($vm.ExtensionData.Guest.ToolsStatus)" -ForegroundColor White
42-
Write-Host "Tools Version: $($vm.ExtensionData.Guest.ToolsVersion)" -ForegroundColor White
43-
44-
$compatible = $vm.PowerState -eq "PoweredOn" -and
37+
38+
Write-Information "=== No-Reboot Compatibility Check ===" -InformationAction Continue
39+
Write-Information "VM: $($vm.Name)" -InformationAction Continue
40+
Write-Information "Power State: $($vm.PowerState)" -InformationAction Continue
41+
Write-Information "Tools Status: $($vm.ExtensionData.Guest.ToolsStatus)" -InformationAction Continue
42+
Write-Information "Tools Version: $($vm.ExtensionData.Guest.ToolsVersion)" -InformationAction Continue
43+
44+
$compatible = $vm.PowerState -eq "PoweredOn" -and
4545
$vm.ExtensionData.Guest.ToolsStatus -ne "toolsNotInstalled" -and
4646
$vm.ExtensionData.Guest.ToolsVersion -ge 10000
47-
47+
4848
if ($compatible) {
49-
Write-Host "✅ VM is compatible with no-reboot upgrade" -ForegroundColor Green
49+
Write-Information "✅ VM is compatible with no-reboot upgrade" -InformationAction Continue
5050
} else {
51-
Write-Host "❌ VM is NOT compatible with no-reboot upgrade" -ForegroundColor Red
51+
Write-Information "❌ VM is NOT compatible with no-reboot upgrade" -InformationAction Continue
5252
}
53-
53+
5454
Disconnect-VIServer -Confirm:$false
5555
} catch {
5656
Write-Error "Error: $($_.Exception.Message)"

scripts/Upgrade-VMTools-NoReboot.ps1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
VMware Tools Conditional Upgrade (No Reboot) PowerCLI Script
4-
4+
55
.DESCRIPTION
66
Upgrade VMware Tools on a single VM only if:
77
- VMware Tools are running
88
- Upgrade is needed (NeedUpgrade or SupportedOld)
99
- Tools are installed
1010
Upgrade runs silently and does NOT trigger a guest OS reboot.
11-
11+
1212
.PARAMETER vCenter
1313
vCenter Server FQDN or IP address (optional - will prompt if not provided)
14-
14+
1515
.PARAMETER VMName
1616
VM name to upgrade (optional - will prompt if not provided)
17-
17+
1818
.PARAMETER Credential
1919
vCenter credentials (optional - will prompt if not provided)
20-
20+
2121
.EXAMPLE
2222
.\Upgrade-VMTools-NoReboot.ps1
23-
23+
2424
.EXAMPLE
2525
.\Upgrade-VMTools-NoReboot.ps1 -vCenter "vcenter.example.com" -VMName "VM-001"
26-
26+
2727
.NOTES
2828
Author: uldyssian-sh
2929
Version: 1.0.0
3030
Requires: PowerCLI, vCenter administrative privileges
3131
Based on: Medium article methodology for no-reboot VMware Tools upgrades
32-
32+
3333
.LINK
3434
https://github.com/uldyssian-sh/vmware-tools-no-reboot
3535
#>
@@ -38,10 +38,10 @@
3838
param(
3939
[Parameter(Mandatory = $false)]
4040
[string]$vCenter,
41-
41+
4242
[Parameter(Mandatory = $false)]
4343
[string]$VMName,
44-
44+
4545
[Parameter(Mandatory = $false)]
4646
[PSCredential]$Credential
4747
)

0 commit comments

Comments
 (0)