Agentless Management with PowerShell 3.0 - CIM Cmdlets and iDRAC/Lifecycle Controller

This post was originally written by Syama Poluri and Michael Schroeder.

Have a great PowerShell idea for PowerEdge? Send your suggestions or comments toWinServerBlogs@dell.com.

Introduction

Microsoft Windows Server® 2012 introduced CIM Cmdlets with PowerShell 3.0 to help manage any server or device that complies with CIM and WS-Man standards. From a Windows® host, CIM sessions can be established to remotely connect to the iDRAC interface on your Dell™ PowerEdge™ servers. Once connected, you have access to a large number of management tasks available that you can perform like changing settings in the BIOS, collecting hardware inventory and many others. This blog demonstrates how easy the PowerShell 3.0 CIM Cmdlets are to use when managing your system and also provides a simple script you can work from for retrieving basic hardware information from your servers using the iDRAC interface.

PowerShell 3.0 is native to Windows 8 and Windows Server 2012; there’s nothing else you need to install. In order to run PowerShell 3.0 CIM Cmdlets on Windows® 7 or Windows Server® 2008 R2 systems, the Windows Management Framework 3.0 needs to be installed on your management host.

iDRAC/Lifecycle Controller and CIM In Action

With this script, we’ll perform the following steps using elevated Administrator privileges in PowerShell 3.0:

  1. Enter the destination iDRAC IP Address.
  2. Provide the iDRAC credentials for authentication.
  3. Set up the CIM Session connection with our options.
  4. Retrieve instances for a variety of system components.
  5. Store the results to a file using the service-model name of the system.

 

<#Get-HWInfo.ps1

#Retrieve Base Hardware Information using PS3/CIM Cmdlets

#Author: Michael_Schroeder

  #############################################################################

 

  (C) 2012 Dell Inc.  All rights reserved.

 

  THIS SOFTWARE IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT IS

  PROVIDED “AS IS” WITHOUT ANY WARRANTY, EXPRESS, IMPLIED OR OTHERWISE,

  INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY OR

  FITNESS FOR A PARTICULAR PURPOSE OR ANY WARRANTY REGARDING TITLE OR

  AGAINST INFRINGEMENT.  IN NO EVENT SHALL DELL BE LIABLE FOR ANY DIRECT,

  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES

  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTUTUTE GOODS OR

  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)

  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,

  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING

  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

  POSSIBILITY OF SUCH DAMAGE.

 

  This sample script is provided as an example only, and is not warranted

  in any way by Dell; Dell disclaims any liability in connection therewith.

  Dell provides no technical support with regard to content herein. For

  more information on libraries and tools used in this example, refer to

  applicable documentation

 

#############################################################################

#>

 

#Enter the iDRAC IP Address

$IPaddress=Read-Host -Prompt "Enter the iDRAC IP Address"

 

#Enter the iDRAC Username

$Username=Read-Host -Prompt "Enter the iDRAC Username"

 

#Setup the CIM Session and Options

$Cimop=New-CimSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck -Encoding Utf8 -UseSsl

$Session=New-CimSession -Authentication Basic -Credential $Username -ComputerName $IPAddress -Port 443 -SessionOption $Cimop

 

#Retrieve & Store an instance of System,CPU,Memory,NIC,Fan,iDRAC Views

Write-Host #blank line

$System=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_SystemView"

$CPU=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_CPUView"

$Memory=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_MemoryView"

$NIC=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_NICView"

$Fans=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_FanView"

$iDRAC=Get-CimInstance -CimSession $session -ResourceUri "http://schemas.dell.com/wbem/wscim/1/cim-schema/2/DCIM_iDRACCARDView"

 

#Store service tag & model and create a file

$Svctag=$System.ServiceTag

$Model=$System.Model

$File = New-Item -ItemType file -Name "$Svctag-$Model.txt" -Force

 

#Function for HW property output

function GetOutput

{

Write-Host "System Information: " -ForegroundColor Green; $System | Select Manufacturer,Model,BIOSVersionString,ServiceTag | fl

Write-Host "CPU Information: " -ForegroundColor Green; $CPU | Select FQDD,Manufacturer,MaxClockSpeed,NumberOfProcessorCores | fl

Write-Host "Memory Information: " -ForegroundColor Green; $Memory | Select FQDD, Manufacturer,Size,Speed | fl

Write-Host "NIC Information: " -ForegroundColor Green; $NIC | Select FQDD,ProductName | fl

Write-Host "Fan RPM Information: " -ForegroundColor Green; $Fans | Select FQDD,CurrentReading | fl

Write-Host "iDRAC Information: " -ForegroundColor Green; $iDRAC | Select FirmwareVersion,Model,PermanentMACAddress | fl

}

#Send output to the console and to the Svctag-Model.txt file

GetOutput | Tee-Object -FilePath $File

 

The script outputs to the screen and also to a file. In this example, the file is named   7Z284P1-PowerEdge R715.txt. Note- You may need to change your PowerShell Script Execution Policy before running any scripts.

 

This simple example provides a small window into the potential of PowerShell 3.0 CIM Cmdlets when used with iDrac/Lifecycle Controller. There are many server management tasks available, whether making a BIOS configuration change or reconfiguring your RAID card or just retrieving inventory information from your systems in your datacenter. Agentless management ensures that your CPU cycles are left for your intended workloads and also prevents the burden of continually updating software agents across racks of servers. In addition to these benefits, you also have the flexibility to customize and automate the management tasks to best meet your datacenter needs. 

 

Additional Resources:

Using Microsoft™ Windows® PowerShell CIM Cmdlets with Dell™ iDRAC

Lifecycle Controller 2 Web Services Interface Guide for Windows