Disable IP Binding for the HP System Management Homepage

If IP binding is enabled for HP System Management Homepage (which is used to manage HP Proliant Servers), it can by default only be accessed from the server itself, because it binds to 127.0.0.1. In order to disable this, I've written a PowerShell function that can disable IP binding remotely and for multiple servers. It uses xmlobjects and get-service.

#=====================================================================
# Disable-HPSMH_IPBinding
#=====================================================================
Function Disable-HPSMH_IPBinding
{
<#

.SYNOPSIS
Disables IP Binding for the HP System Management Homepage.

.DESCRIPTION

Works both remote as well as local. has no dependencies (uses XML manipulation and get- stop- start- service).

Other potentially interesting settings:

- <system-management-homepage>
  <admin-group>REDMOND\ITG-ADMIN</admin-group> 
  <operator-group /> 
  <user-group /> 
  <allow-default-os-admin>true</allow-default-os-admin> 
  <anonymous-access>false</anonymous-access> 
  <localaccess-enabled>false</localaccess-enabled> 
  <localaccess-type>Anonymous</localaccess-type> 
  <trustmode>TrustByCert</trustmode> 
  <xenamelist /> 
  <ip-binding>true</ip-binding> 
  <ip-binding-list>127.0.0.1/255.0.0.0</ip-binding-list> 
  <ip-restricted-logins>false</ip-restricted-logins> 
  <ip-restricted-include /> 
  <ip-restricted-exclude /> 
  </system-management-homepage>

.PARAMETER ComputerName
Computername to query

.EXAMPLE

Disable-HPSMH_IPBinding SVCHSMVS15 -verbose

.NOTES

.LINK

http://winfred.com
#>
param(
[Parameter(Position=0, Mandatory=$True)]$Computername
)
    # check to see if there is a xml file with HP System Management Homepage settings
    $XMFile = "\\$Computername\c$\hp\hpsmh\conf\smhpd.xml"
    if(test-path $XMFile)
    {
        # Now check if there is a HP System Management Homepage service
        $HPSMHService = Get-Service -DisplayName "HP System Management Homepage" -ComputerName $ComputerName  -ErrorAction:SilentlyContinue
        if($HPSMHService)
        {
            # Load XML
            [xml]$xml = get-content $XMFile
            $IPBinding = $xml."system-management-homepage"."ip-binding"
            # Check and change the IP Binding if required.
            if($IPBinding -eq "false")
            {
                write-verbose "HP SMH on $Computername IP Binding is already set to false"
            }elseif($IPBinding -eq "true")
            {
                write-verbose "HP SMH on $Computername IP Binding is set to true - Changing it to false"
                $xml."system-management-homepage" | % {$_."ip-binding" = "false"}
                write-verbose "Saving File"
                $xml.save("\\$Computername\c$\hp\hpsmh\conf\smhpd.xml")
                write-verbose "restarting HP System Management Homepage Service"
                $HPSMHService.stop()
                do
                {
                    start-sleep -Milliseconds 200
                }until((Get-Service -DisplayName "HP System Management Homepage" -ComputerName $ComputerName -ErrorAction:SilentlyContinue).Status -eq "Stopped")
                $HPSMHService.start()
            }else{
                write-warning "HP SMH on $Computername IP Binding is set to $($xml."system-management-homepage"."ip-binding")"
            }
        }else{
            write-warning "Unable to find HP System Management Homepage Service on $Computername"
        }
    }else{
        write-warning "Unable to find $XMFile"
    }
}