From 17298fddfe0afbd522ec1a49ca2ac9bade6731de Mon Sep 17 00:00:00 2001 From: Race666 Date: Fri, 22 Apr 2022 14:03:28 +0200 Subject: [PATCH 1/3] Update bestpractices.ps1 Fixes issue on remove satp rule: Message: EsxCLI.CLIFault.summary; InnerText: Error deleting SATP rule: No rule matching the given options found, nothing to delete. Specify all options for the rule to delete it successfully.: Not foundEsxCLI.CLIFault.summary --- bestpractices.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bestpractices.ps1 b/bestpractices.ps1 index 4022528..c231b0c 100644 --- a/bestpractices.ps1 +++ b/bestpractices.ps1 @@ -408,6 +408,7 @@ foreach ($esx in $hosts) $satpArgs.satp = $rule.Name $satpArgs.psp = $rule.DefaultPSP $satpArgs.pspoption = $rule.PSPOptions + $satpArgs.boot=$true add-content $logfile "This rule is incorrect, deleting..." $esxcli.storage.nmp.satp.rule.remove.invoke($satpArgs) add-content $logfile "*****NOTE: Deleted the rule.*****" @@ -545,4 +546,4 @@ foreach ($esx in $hosts) } } disconnect-viserver -Server $vcenter -confirm:$false - add-content $logfile "Disconnected vCenter connection" \ No newline at end of file + add-content $logfile "Disconnected vCenter connection" From e9c3c760584cb87b11dcd8823d90a0b5dc288b02 Mon Sep 17 00:00:00 2001 From: Race666 Date: Fri, 22 Apr 2022 14:27:57 +0200 Subject: [PATCH 2/3] Update bestpractices.ps1 Fixes issue an deleting satp rule when the boot parameter is not set correctly. I found no way to recognize the boot parameter of an existing rule so trying both true and false. Message: EsxCLI.CLIFault.summary; InnerText: Error deleting SATP rule: No rule matching the given options found, nothing to delete. Specify all options for the rule to delete it successfully.: Not foundEsxCLI.CLIFault.summary --- bestpractices.ps1 | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/bestpractices.ps1 b/bestpractices.ps1 index c231b0c..374cd8b 100644 --- a/bestpractices.ps1 +++ b/bestpractices.ps1 @@ -402,15 +402,35 @@ foreach ($esx in $hosts) } if ($issuecount -ge 1) { + [bool]$RuleDeleted=$true $satpArgs = $esxcli.storage.nmp.satp.rule.remove.createArgs() $satpArgs.model = $rule.Model $satpArgs.vendor = "PURE" $satpArgs.satp = $rule.Name $satpArgs.psp = $rule.DefaultPSP $satpArgs.pspoption = $rule.PSPOptions - $satpArgs.boot=$true - add-content $logfile "This rule is incorrect, deleting..." - $esxcli.storage.nmp.satp.rule.remove.invoke($satpArgs) + add-content $logfile "This rule is incorrect, trying to delete..." + try + { + $esxcli.storage.nmp.satp.rule.remove.invoke($satpArgs) + add-content $logfile "rule deleted successfully" + $RuleDeleted=$true + } + catch { + add-content $logfile "Deleting of rule failed maybe boot property is not set correctly" + } + if($RuleDeleted -ne $true) + { + add-content $logfile "This rule is incorrect, trying to delete with boot=true..." + $satpArgs.boot=$true + $esxcli.storage.nmp.satp.rule.remove.invoke($satpArgs) + add-content $logfile "rule deleted successfully" + $RuleDeleted=$true + } + if($RuleDeleted -ne $true) + { + add-content $logfile "rule delete failed" + } add-content $logfile "*****NOTE: Deleted the rule.*****" add-content $logfile "-----------------------------------------------" } From cef7e1bc9511f80794ee5a011cc5cf8089b781bf Mon Sep 17 00:00:00 2001 From: Race666 Date: Fri, 22 Apr 2022 14:30:17 +0200 Subject: [PATCH 3/3] Update bestpractices.ps1 Default behaviour changed --- bestpractices.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bestpractices.ps1 b/bestpractices.ps1 index 374cd8b..c0295a0 100644 --- a/bestpractices.ps1 +++ b/bestpractices.ps1 @@ -402,7 +402,7 @@ foreach ($esx in $hosts) } if ($issuecount -ge 1) { - [bool]$RuleDeleted=$true + [bool]$RuleDeleted=$false $satpArgs = $esxcli.storage.nmp.satp.rule.remove.createArgs() $satpArgs.model = $rule.Model $satpArgs.vendor = "PURE" @@ -411,7 +411,7 @@ foreach ($esx in $hosts) $satpArgs.pspoption = $rule.PSPOptions add-content $logfile "This rule is incorrect, trying to delete..." try - { + { $esxcli.storage.nmp.satp.rule.remove.invoke($satpArgs) add-content $logfile "rule deleted successfully" $RuleDeleted=$true