Unsolved
This post is more than 5 years old
4 Posts
1
15385
How to add OME Discovery Ranges remotely
I don't ever want to have to launch a web browser to add a host into OME. There are some powershell cmdlets to do this, but they require a snapin only present on the OME server. Powershell Remoting can work around this. Here is the code; just replace the variables up top.
# Set Variables
$IPAddress = "10.1.1.10"
$OMEServer = "ome-server.domain.local"
$GroupName = "YourGroupName"
$WSManPassword = "YourWSManPW"
# Establish Powershell Remoting
$DellOME = New-PSSession -ComputerName $OMEServer -Name OME
# Remote Scriptblock
Invoke-Command $DellOME -ScriptBlock {
param([string]$IPAddress,[string]$GroupName,[string]$WSManPassword)
# Create an XML file
$TempFile = [IO.Path]::GetTempFileName()
[System.XML.XMLDocument] $Global:XMLDocument = New-Object System.XML.XMLDocument
$Declaration = $XMLDocument.CreateXmlDeclaration("1.0", "utf-8", $null)
[System.XML.XMLElement] $XMLRoot = $XMLDocument.CreateElement("DiscoveryConfigurationRanges")
$XMLDocument.InsertBefore($Declaration, $XMLDocument.DocumentElement)
$XMLDocument.appendChild($XMLRoot)
[System.XML.XMLElement] $XMLSystem = $XMLRoot.AppendChild($XMLDocument.CreateElement("Range"))
$XMLSystem.SetAttribute("Name",$IPAddress)
$XMLDocument.Save($TempFile)
# Load the OME CLI Snapin
Add-PSSnapin "Dell.OME.CLI"
# Load the Range into the database and run a discovery and inventory
Set-ModifyDiscoveryRangeGroup -GroupName $GroupName -AddRangeList $TempFile -WSManPassword $WSManPassword
Set-RunDiscoveryInventory -Rangelist $TempFile
# Remove the Temporary XML File
Remove-Item $TempFile -Force
} -ArgumentList $IPAddress,$GroupName,$WSManPassword
Some notes here:
- There is no error correction. You must have Powershell Remoting enabled on your OME server, and you must have admin rights to it.
- You must already have a Discovery group created.
- I'm only using SNMP and WSMan. If you use any of the other protocols, you will have to add those passwords in param and -ArgumentList.
- You have to use XML because Dell neglected to add a CSV option for Set-RunDiscoveryInventory.
Good luck!
DELL-Chris H
Moderator
Moderator
•
8.8K Posts
0
October 10th, 2013 07:00
Agressiv,
Great post, very helpful information. Thank you for sharing your solution with the community.