Monday, April 22, 2019

Getting and setting IPMI settings through powershell

We had an issue where some servers had IMPI enabled and some did not, in order to get uniformity on > 200 servers, a quick script was developed to read and then set them all to the same value. The racadm commands documented syntax is poor at best unless you want to read through the 200+ plus page manual linked at the bottom of this. Enjoy.


#get command to read values, enable=enabled means that IPMI is enabled

cls

$servers = get-content("\\xxx\c$\Temp\Security Patches\Servers\serversComplete(E2013)-Alphabetical.txt"); # read in a list of servers

foreach ($server in $servers)
{
    $results = Invoke-Command -ComputerName $server -ScriptBlock { racadm get iDRAC.IPMILan }
    foreach ($result in $results)
    {
        if ($result.StartsWith("Enable="))
        {
            Write-Host $server ", IPMI setting is set to: " $result;
        }
    }
}


 # sets ipmi to disabled 
cls

$servers = get-content("\\xxx\c$\Temp\Security Patches\Servers\serversComplete(E2013)-Alphabetical.txt"); # read in a list of servers

foreach ($server in $servers)
{
    $results = Invoke-Command -ComputerName $server -ScriptBlock { racadm set iDRAC.IPMILan.Enable 0 } # 0 to disable, 1 to enable
       Write-Host $server;
       Write-Host $results;
       Write-Host “”;
Write-Host “”;
}


All commands



No comments:

Post a Comment