Created
September 29, 2016 20:26
-
-
Save MichaelRyom/4be0eb386f7afb48e326eb13ce5be256 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$usernameHost = Read-Host -Prompt 'Host Username' | |
$secPwHost = Read-Host -Prompt 'Host Password' -AsSecureString | |
$credHost = New-Object PSCredential -ArgumentList $usernameHost,$secPwHost | |
$VMHosts = "Host01","Host02","Host03" | |
foreach($Vmhost in $Vmhosts){ | |
Connect-VIServer $Vmhost -Credential $credHost | |
$esxcli = Get-EsxCli $VMHost | |
$rules = $esxcli.corestorage.claimrule.list() | where {[INT]$_.rule -gt "101" -and [INT]$_.rule -ne "65535"} | |
foreach($rule in $rules){ | |
$Path = $rule.Matches -split("adapter=|channel=|target=|lun=") | |
$RuleNR = $Rule.rule | |
$esxcli.corestorage.claimrule.delete($null,$RuleNR) | |
$esxcli.corestorage.claimrule.load() | |
$esxcli.corestorage.claiming.unclaim($Path[1].Trim(),[INT]$Path[2],$null,$null,$null,[INT]$Path[4],$null,$null,$null,[INT]$Path[3],"location",$null) | |
$esxcli.corestorage.claimrule.run() | |
} | |
Get-VMHostStorage -VMhost $VMHost -RescanAllHba | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment