Monday, May 6, 2019

Powershell script to detect non logged-in initiators of lun on a netapp cdot cluster

A colleague of mine got a customer request to find a way to alert when luns had initiators that were not logged-in.

I wrote him this little piece of code that will dump this information.
It could be easily embedded in WFA and ran on all clusters.
You can then report on it as you please.




get-nclunmap | select -Unique | %{
    Get-NcIgroup -name $_.InitiatorGroup -Vserver $_.Vserver | %{
        $ig = $_
        $vs = $_.Vserver
        @($ig.initiators) | %{
            $in = $_.InitiatorName
            $loggedin = Confirm-NcLunInitiatorLoggedIn -VserverContext $vs -Initiator $in
            $o = @{}
            $o.vserver = $vs
            $o.igroup = $ig
            $o.initiator = $in
            $o.loggedin = $loggedin
            New-Object -TypeName psobject -property $o
        }
    }
}

No comments :

Post a Comment