Skip to content

Commit 0eedf7a

Browse files
committed
Using a more efficient module version check
Replaced the previous method to check for module version checks with a more efficient method.
1 parent 0b97476 commit 0eedf7a

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

VvolsReadinessCheckerV2.ps1

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,50 +165,49 @@ Add-Content $Logfile ' '
165165

166166

167167
# Get the Pure Storage SDK2 version
168-
$PurePSSDKVersion = Get-Module -Name PureStoragePowerShellSDK2 -ListAvailable | Select-Object -Property Version
168+
#$PurePSSDKVersion = Get-Module -Name PureStoragePowerShellSDK2 -ListAvailable | Select-Object -Property Version
169169

170170
# If the Pure Storage SDK Version is not v2.26 or higher, recommend that the user install it or a higher version
171-
If ($PurePSSDKVersion.Version.Major -ge "2") {
172-
if ($PurePSSDKVersion.Version.Minor -ge "26") {
171+
If (Get-Module -ListAvailable PureStoragePowerShellSDK2 | Where-Object -Property version -cge "2.26") {
173172
Write-Host "Pure Storage SDK version 2.26 or higher present, " -NoNewLine
174-
Write-Host "proceeding" -ForegroundColor Green
175-
}
173+
Write-Host " "
174+
#Write-Host "proceeding" -ForegroundColor Green
176175

177176
} else {
178-
Write-Host "The Pure Storage SDK version could not be determined or is less than version 2.26" -Foregroundcolor Red
179-
Write-Host "Please install the Pure Storage SDK version 2.26 or higher and rerun this script" -Foregroundcolor Yellow
177+
Write-Host "The Pure Storage SDK version could not be determined or is less than version 2.26" -ForegroundColor Red
178+
Write-Host "Please install the Pure Storage SDK version 2.26 or higher and rerun this script" -ForegroundColor Yellow
180179
Write-Host " "
181180
exit
182181
}
183182

184183
# Get the Pure Storage PowerShell Toolkit version
185-
$PurePSToolkitVersion = Get-Module -Name PureStoragePowerShellToolkit -ListAvailable | Select-Object -Property Version
184+
#$PurePSToolkitVersion = Get-Module -Name PureStoragePowerShellToolkit -ListAvailable | Select-Object -Property Version
186185

187186
# If the Pure Storage SDK Version is not v3.0 or higher, recommend that the user install it or a higher version
188-
If ($PurePSToolkitVersion.Version.Major -ge "3") {
187+
If (Get-Module -ListAvailable PureStoragePowerShellToolkit | Where-Object -Property version -cge "3.0") {
189188
Write-Host "Pure Storage PowerShell Toolkit version 3.0 or higher present, " -NoNewLine
190-
Write-Host "proceeding" -ForegroundColor Green
189+
Write-Host " "
190+
#Write-Host "proceeding" -ForegroundColor Green
191191

192192
} else {
193-
Write-Host "The Pure Storage PowerShell Toolkit version could not be determined or is less than version 3.0" -Foregroundcolor Red
194-
Write-Host "Please install the Pure Storage Toolkit version 3.0 or higher and rerun this script" -Foregroundcolor Yellow
193+
Write-Host "The Pure Storage PowerShell Toolkit version could not be determined or is less than version 3.0" -ForegroundColor Red
194+
Write-Host "Please install the Pure Storage Toolkit version 3.0 or higher and rerun this script" -ForegroundColor Yellow
195195
Write-Host " "
196196
exit
197197
}
198198

199199
# Get the PowerCLI Version
200-
$PowerCLIVersion = Get-Module -Name VMware.PowerCLI -ListAvailable | Select-Object -Property Version
200+
#$PowerCLIVersion = Get-Module -Name VMware.PowerCLI -ListAvailable | Select-Object -Property Version
201201

202202
# If the PowerCLI Version is not v13 or higher, recommend that the user install PowerCLI 13 or higher
203-
If ($PowerCLIVersion.Version.Major -ge "13") {
204-
if ($PowerCLIVersion.Version.Minor -ge "3") {
205-
Write-Host "PowerCLI version 13.3 or higher present, " -NoNewLine
206-
Write-Host "proceeding" -ForegroundColor Green
207-
}
203+
If (Get-Module -ListAvailable VMware.PowerCLI | Where-Object -Property version -cge "13.0") {
204+
Write-Host "PowerCLI version 13.0 or higher present, " -NoNewLine
205+
Write-Host " "
206+
#Write-Host "proceeding" -ForegroundColor Green
208207

209208
} else {
210209
Write-Host "PowerCLI version could not be determined or is less than version 13.3" -Foregroundcolor Red
211-
Write-Host "Please install PowerCLI 13.3 or higher and rerun this script" -Foregroundcolor Yellow
210+
Write-Host "Please install PowerCLI 13.0 or higher and rerun this script" -Foregroundcolor Yellow
212211
Write-Host " "
213212
exit
214213
}

0 commit comments

Comments
 (0)