############################################################################ # Power Shell Scripts to read and configure iRMC settings via CIM (WS-MAN) # ############################################################################ # Version 0.1 # # Need iRMC FW 7.60 or newer # # Tested with Powershell 4.0 # # Date: 2014-12 # ############################################################################ ########################### # Index: ########################### (01) Enable PowerShell Scripting (02) Some How-Tos / additional help (03) initial configuration (04) check configuration (05) create session to execute power shell scripts (06) Get Help for a script (07) Overview of available scripts (08) Release notes ########################### # (01) Enable PowerShell Scripting ########################### 1) Install PowerShell 4 (Included in Windows Management Framework 4.0) Windows 7, Windows Embedded Standard 7, Windows Server 2008 R2, Windows Server 2012 2) Check PowerShell version >PSVersionTable.PSVersion 3) Start Power Shall as Administrator. >Set-ExecutionPolicy RemoteSigned 4)Make sure WinRM client is working. >winrm get winrm/config Notes: The windows user must have a password!!! Open command prompt or PowerShell (!!! with admin rights !!!) ########################### # (02) Some How-Tos / additional help ########################### http://msdn.microsoft.com/en-us/library/windows/desktop/aa384372(v=vs.85).aspx http://blogs.technet.com/b/jonjor/archive/2009/01/09/winrm-windows-remote-management-troubleshooting.aspx ########################### # (03) initial configuration ########################### >winrm quickconfig >winrm set winrm/config/client '@{TrustedHosts="*"} ' >winrm set winrm/config/client/Auth '@{Basic="true"} ' >winrm set winrm/config '@{MaxEnvelopeSizekb="500"} ' >winrm set winrm/config/client '@{AllowUnencrypted="true"} ' Attention: some commands need a much bigger “MaxEnvelopeSizekb”! ########################### # (04) check configuration ########################### >winrm get winrm/config ########################### # (05) create session to execute power shell scripts ########################### Create a remote session to access the iRMC remotely without defining connection settings for each script. Precondition: WinRM must be installed and configured Set credentials: >$c = Get-Credential Enter Username and Password. Create CIM session: >$s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Show session: >Get-CimSession Example response: Id : 6 Name : CimSession6 InstanceId : 56c80b11-3688-4763-a8c3-f3398db96cd4 ComputerName : 123.45.67.89 Protocol : WSMAN ########################### # (06) Get Help for a script ########################### >Get-Help .\ -Detailed E.g. Get-Help .\Clear_iEL.ps1 -Detailed ########################### # (07) Overview of available scripts ########################### ########################### Get_All_Users.ps1 <# .SYNOPSIS Returns a list of all user accounts on iRMC device. .DESCRIPTION Returns a list of all user accounts like: (Number) Identity : .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_All_Users.ps1 -Session $s #> ########################### Get_All_User_Info.ps1 <# .SYNOPSIS Return the configuration details for all users .DESCRIPTION Returns a list of all user information like: (Number) Name : - Account = - Role = - Privilege = .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_All_User_Info.ps1 -Session $s #> ########################### Get_Power_On_Time.ps1 <# .SYNOPSIS Return the time, the server has been powered on and running .DESCRIPTION Returns the PowerOnCounter value of the Base Server in [[years,] [months,] days, hours and minutes .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Power_On_Time.ps1 -Session $s #> Note: needs a FW fix from 2014-09-23 FW 7.61d ########################### Get_Host_Power.ps1 <# .SYNOPSIS Returns the current power state of the host server .DESCRIPTION Returns the power state value of the Base Server: Power State of the Base Server: Power On/ Power Off .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Host_Power.ps1 -Session $s #> ########################### Get_FW_Version.ps1 <# .SYNOPSIS Returns the Firmware Version .DESCRIPTION Returns the installed and booted FW Version and Release Date of the iRMC S4: Firmware Version of the iRMC S4: Installed FW: Version = Release Date = Currently booted FW: Version = Release Date = .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_FW_Version.ps1 -Session $s #> ########################### Clear_SEL.ps1 <# .SYNOPSIS Clears the System Event Log (SEL) .DESCRIPTION Deletes all Log Entries of the SEL. Output: Try to delete Log Entries from SystemName.MessageLog Completed with no Error/Unknown or unspecified Error .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Clear_SEL.ps1 -Session $s #> Note: Needs a FW fix from 2014-09-26 to function every time (not only every second time) FW 7.61d ########################### Clear_iEL.ps1 <# .SYNOPSIS Clears the internal Event Log (iEL) .DESCRIPTION Deletes all Log Entries of the iEL. Output: Try to delete Log Entries from SystemName.InternalEventLog Completed with no Error/Unknown or unspecified Error .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Clear_iEL.ps1 -Session $s #> Note: Needs a FW fix from 2014-09-26 to function every time (not only every second time) FW 7.61d ########################### UID_Control.ps1 <# .SYNOPSIS Turn on/off the Unit ID (UID) light on the host server .DESCRIPTION Switches the ID LED of the Chassis. The output is either: The ID LED is currently turned on and will be turned off! The ID LED is turned off! or: The ID LED is currently turned off and will be turned on! The ID LED is turned on! In case the ID LED is blinking, the state cannot be changed. .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 UID_Control.ps1 -Session $s #> ########################### Get_Host_APO.ps1 <# .SYNOPSIS Retrieve server power options. .DESCRIPTION The script returns: Power Options Power Restore Policy : Restore to powered state prior to power loss/Always power on/Always power off Power On/Off Time Power Scheduling enabled : TRUE/FALSE If Power On / Power Off time is not set, the value is shown as “ -- “ Day | On Time | Off Time ________________________ Su | -- | -- Mo | 05:00h | -- Tu | 06:00h | -- We | 06:00h | -- Th | 06:00h | -- Fr | 06:00h | -- Sa | -- | -- .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Host_APO.ps1 -Session $s #> Note: This script only works on some iRMC S4 – cause under investigation. Fixed with FW 7.70A. ########################### Set_Host_APO.ps1 <# .SYNOPSIS Sets server power options. .DESCRIPTION The script returns updated power options: OLD VALUES: Power Restore Policy : Always power on Power On/Off Time Power Scheduling enabled : TRUE If Power On / Power Off time is not set, the value is shown as “ -- “ Day | On Time | Off Time ________________________ Su | -- | -- Mo | 05:00h | -- Tu | 06:00h | -- We | 06:00h | -- Th | 06:00h | -- Fr | 06:00h | -- Sa | -- | -- NEW VALUES Power Restore Policy : Always power on Power On/Off Time Power Scheduling enabled : TRUE Day | On Time | Off Time ________________________ Su | -- | -- Mo | 06:00h | -- Tu | 06:00h | -- We | 06:00h | -- Th | 06:00h | -- Fr | 06:00h | -- Sa | -- | -- .PARAMETER Session The parameter Session is needed for remote management of the iRMC .PARAMETER PowerRestorePolicy value 0 = Always power on value 1 = Restore to powered state prior to power loss value 2 = Always power off .PARAMETER PowerScheduleEnable value TRUE or FALSE .PARAMETER SundayOff value shall be specified in "hh:mm" h. .PARAMETER SundayOn value shall be specified in "hh:mm" h. .PARAMETER MondayOff value shall be specified in "hh:mm" h. .PARAMETER MondayOn value shall be specified in "hh:mm" h. .PARAMETER TuesdayOff value shall be specified in "hh:mm" h. .PARAMETER TuesdayOn value shall be specified in "hh:mm" h. .PARAMETER WednesdayOff value shall be specified in "hh:mm" h. .PARAMETER WednesdayOn value shall be specified in "hh:mm" h. .PARAMETER ThursdayOff value shall be specified in "hh:mm" h. .PARAMETER ThursdayOn value shall be specified in "hh:mm" h. .PARAMETER FridayOff value shall be specified in "hh:mm" h. .PARAMETER FridayOn value shall be specified in "hh:mm" h. .PARAMETER SaturdayOff value shall be specified in "hh:mm" h. .PARAMETER SaturdayOn value shall be specified in "hh:mm" h. .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Set_Host_APO.ps1 -Session $s #> Note: As “get the values” only works on some iRMC S4 (see chapter 3.9), also the setting of values only works on some iRMC S4 – cause under investigation. Fixed with FW 7.70A. Deletion of existing values can be done with argument either “ “ (a string containing only a ) or “--“ (a string containing two dashes), e.g.: Set_Host_APO.ps1 -Session $s –MondayOff “--" ########################### Get_Host_ASRandR.ps1 <# .SYNOPSIS Retrieve server ASR$R Settings. .DESCRIPTION The script returns: ASR$R Options ASR`$R Boot Delay (1-30) : Retry counter MAX (0-7) : Retry counter (0-MAX) : BIOS Recovery Flash : Prevent Power On on Critical Temperature : Power Cycle Delay (0-15) : .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Host_ASRandR.ps1 -Session $s #> ########################### Set_Host_ASRandR.ps1 <# .SYNOPSIS Sets server power options. .DESCRIPTION The script returns updated power options: OLD VALUES ASR$R Options ASR$R Boot Delay (1-30) : Minutes Retry counter MAX (0-7) : Retry counter (0-MAX) : BIOS Recovery Flash : Prevent Power On on Critical Temperature : Power Cycle Delay (0-15) : seconds NEW VALUES ASR$R Options ASR$R Boot Delay (1-30) : Minutes Retry counter MAX (0-7) : Retry counter (0-MAX) : BIOS Recovery Flash : Prevent Power On on Critical Temperature : Power Cycle Delay (0-15) : seconds .PARAMETER Session The parameter Session is needed for remote management of the iRMC .PARAMETER ErrorOffRestartTime The parameter ErrorOffRestartTime defines the ASR$R Boot Delay (1-30) in Minutes .PARAMETER RetryCounterMax The parameter RetryCounterMax defines the Retry counter MAX (0-7) .PARAMETER RebootRetryCounter The parameter RebootRetryCounter defines the Retry counter (0-MAX) .PARAMETER RecoveryFlash The parameter RecoveryFlash defines the BIOS Recovery Flash option TRUE/FALSE .PARAMETER TempCriticalPowerOff The parameter TempCriticalPowerOff defines if Prevent Power On on Critical Temperature TRUE/FALSE .PARAMETER PowerCycleDelay The parameter PowerCycleDelay defines the Power Cycle Delay (0-15) in seconds .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Set_Host_APO.ps1 -Session $s #> ########################### Get_EmHealth.ps1 <# .SYNOPSIS Return the health information of the server .DESCRIPTION Return the health information of the server: Health State of the Base Server and its components .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_EmHealth.ps1 -Session $s #> ###########################Reset_BMC.ps1 <# .SYNOPSIS Restart the iRMC Management Processor .DESCRIPTION Send a "Request State Change" to the iRMC Management Processor .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Reset_BMC.ps1 -Session $s #> ########################### Reset_Server.ps1 <# .SYNOPSIS Restart the Server .DESCRIPTION Restart the Server: Send a "request state change" .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Reset_Server.ps1 -Session $s #> ########################### Get_iEL.ps1 <# .SYNOPSIS Get the internal Event Log (iEL) .DESCRIPTION Get all Log Entries of the iEL. Output: Show the Log Entries from SystemName.InternalEventLog .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_iEL.ps1 -Session $s #> Note1: This script needs a much bigger “MaxEnvelopeSizekb”, e.g. 32000 for a full iEL or SEL. Note2: The value “severity” needs a FW fix from 2014-09-23 FW 7.61d ########################### Get_SEL.ps1 <# .SYNOPSIS Get the System Event Log (SEL) .DESCRIPTION Get all Log Entries of the SEL. Output: Show the Log Entries from SystemName.MessageLog .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_SEL.ps1 -Session $s #> Note1: This script needs a much bigger “MaxEnvelopeSizekb”, e.g. 32000 for a full iEL or SEL. Note2: The value “severity” needs a FW fix from 2014-09-23 FW 7.61d ########################### Get_Network.ps1 <# .SYNOPSIS Get the Network settings. .DESCRIPTION Show the available Network settings. .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Network.ps1 -Session $s #> Note: Get DNS values only works, if they are visible (even greyed out) in the web interface. ########################### Get_Server_Name.ps1 <# .SYNOPSIS Return the host server name .DESCRIPTION Returns the name of the Base Server .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_Server_Name.ps1 -Session $s #> Note1: This script only works, if agents are running. Note2: This script may need a FW fix from 2014-09-11 to function FW 7.61d ########################### Get_VM_Status.ps1 <# .SYNOPSIS Show Virtual Media status .DESCRIPTION Show properties of the SVS_iRMCMediaRedirection profile .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Get_VM_Status.ps1 -Session $s #> ########################### Set_Host_Power.ps1 <# .SYNOPSIS Turn on/off the host server .DESCRIPTION Switches the Power State of the host server. If the host server is powered on, an additional message is output, which must be acknowledged explicitly by typing in "yes" to power off the server. .PARAMETER Session The parameter Session is needed for remote management of the iRMC .EXAMPLE $c = Get-Credential $s = New-CimSession -Authentication basic -Credential $c -ComputerName -Port 80 Set_Host_Power.ps1 -Session $s #> Note: If server is powered on, this script performs a hard power off. For this reason an extra user acknowledge is implemented. ########################### # (08) Release notes ########################### 2014-12-18 - Initial Version