Skip to content

Commit 03ec6ac

Browse files
authored
Update bestpracticecheckerv5.ps1
1 parent 6d298c2 commit 03ec6ac

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

bestpracticecheckerv5.ps1

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,24 @@ If ($Global:DefaultVIServer) {
8484
Write-Host "Connected to " -NoNewline
8585
Write-Host $Global:DefaultVIServer -ForegroundColor Green
8686
} else {
87+
# If not connected to vCenter Server make a connection
8788
Write-Host "Not connected to vCenter Server" -ForegroundColor Red
8889
$VIFQDN = Read-Host "Please enter the vCenter Server FQDN"
90+
# Prompt for credentials using the native PowerShell Get-Credential cmdlet
8991
$VICredentials = Get-Credential -Message "Enter credentials for vCenter Server"
9092
try {
93+
# Attempt to connect to the vCenter Server
9194
Connect-VIServer -Server $VIFQDN -Credential $VICredentials -ErrorAction Stop | Out-Null
9295
Write-Host "Connected to $VIFQDN" -ForegroundColor Green
96+
# Note that we connected to vCenter so we can disconnect upon termination
9397
$ConnectVc = $True
9498
}
9599
catch {
100+
# If we could not connect to vCenter report that and exit the script
96101
Write-Host "Failed to connect to $VIFQDN" -BackgroundColor Red
97102
Write-Host $Error
98103
Write-Host "Terminating the script " -BackgroundColor Red
104+
# Note that we did not connect to vCenter Server
99105
$ConnectVc = $False
100106
return
101107
}
@@ -160,7 +166,7 @@ if ($clusterChoice -match "[yY]") {
160166
$Hosts = Get-VMHost | Sort-Object Name
161167
}
162168

163-
169+
# Begin the main execution of the script
164170
$errorHosts = @()
165171
Write-Host "Executing..."
166172
Add-Content $Logfile "Iterating through all ESXi hosts..."
@@ -270,12 +276,22 @@ Foreach ($Esx in $Hosts)
270276
Add-Content $Logfile " Checking for FlashArray iSCSI targets and verify their configuration on the host. Only misconfigured iSCSI targets will be reported."
271277
$iscsitofix = @()
272278
$flasharrayiSCSI = $false
279+
280+
# Get a list of all of the Pure Storage iSCSI Targets (if any)
273281
$targets = $esxcli.iscsi.adapter.target.portal.list.Invoke().where{$_.Target -Like "*purestorage*"}
282+
283+
# Store the iSCSI Software Adaper in a variable
274284
$iscsihba = $Esx | Get-VMHostHba |Where-Object{$_.Model -eq "iSCSI Software Adapter"}
285+
286+
# Store any Static targets
275287
$statictgts = $iscsihba | Get-IScsiHbaTarget -type static
288+
289+
# Enumerate through all iSCSI targets
276290
Foreach ($target in $targets) {
277291
if ($target) {
278292
$flasharrayiSCSI = $true
293+
294+
# Check for DelayedACK = False and LoginTimeout = 30
279295
Foreach ($statictgt in $statictgts) {
280296
if ($target.IP -eq $statictgt.Address) {
281297
$iscsioptions = $statictgt.ExtensionData.AdvancedOptions
@@ -286,6 +302,7 @@ Foreach ($Esx in $Hosts)
286302
if (($iscsiack -eq $true) -or ($iscsitimeout -ne 30)) {
287303
if ($iscsiack -eq $true) {$iscsiack = "Enabled"}
288304
else {$iscsiack = "Disabled"}
305+
# Create an object to better report iSCSI targets
289306
$iscsitgttofix = new-object psobject -Property @{
290307
TargetIP = $target.IP
291308
TargetIQN = $target.Target
@@ -298,7 +315,7 @@ Foreach ($Esx in $Hosts)
298315
}
299316
}
300317
}
301-
318+
# If there are any iSCSI targets with issues, report them here
302319
if ($iscsitofix.count -ge 1)
303320
{
304321
$EsxError = $true
@@ -321,6 +338,8 @@ Foreach ($Esx in $Hosts)
321338

322339
Add-Content $Logfile " -------------------------------------------------------------------------------------------------------------------------------------------"
323340
Add-Content $Logfile " Checking for Software iSCSI Network Port Bindings."
341+
342+
# Check for network port binding configuration
324343
if ($flasharrayiSCSI -eq $true)
325344
{
326345
$iSCSInics = $Esxcli.iscsi.networkportal.list.invoke()
@@ -385,13 +404,14 @@ Foreach ($Esx in $Hosts)
385404
}
386405

387406

388-
# Check the rules
407+
# Check the NMP rules
389408

390409
Add-Content $Logfile " -------------------------------------------------------------------------------------------------------------------------------------------"
391410
Add-Content $Logfile " Checking VMware NMP Multipathing configuration for FlashArray devices."
392411
$rules = $Esxcli.storage.nmp.satp.rule.list.invoke() | Where-Object {$_.Vendor -eq "PURE"}
393412
$correctrule = 0
394413

414+
# If vSphere 7, default to Latency, otherwise use IOPS=1
395415
Switch ($HostVersionMajor) {
396416
"7" { $SatpOption = "policy";$SatpType="latency"}
397417
default { $SatpOption = "iops";$SatpType="iops"}

0 commit comments

Comments
 (0)