PREFACE:
- I'll be referring to the blog: How to use the IPAM API and get "Free IP Address" specifically a post by mtokarz on June 12, 2014 2:35PM in response to jgovednik
- I am also aware of and have voted for the feature request: Add SWIS features to IPAM
- I have also referred to this question post: to see if any verbs exist for IPAM.IPNode, but none that I can find.
Following the post mentioned in #1, I am able to successfully find the next free ip address and update the status of an IP address in Solarwinds using Powershell:
Pre-reqs: Download the Orion SDK: solarwinds/OrionSDK · GitHub
Getting a Free IP Address:
# START Connect to SWIS
Add-PSSnapin SwisSnapin
$hostname = "mysolarwinds"
$username = "myuser"
$password = ConvertTo-SecureString -String "mypassword" -asplaintext -force
$creds = New-Object -TypeName System.Management.Automation.PSCredential -Argumentlist $username, $password
$swis = Connect-Swis -host $hostname -Credential $creds
# END Connect to SWIS
Function SWOIPAM-GetFreeIpAddress($subnetAddress)
{
$ipaddress = Get-SwisData $swis 'SELECT TOP 1 I.DisplayName FROM IPAM.IPNode I WHERE Status=2 AND I.Subnet.Address=@subnetAddress AND I.DnsBackward IS NULL' @{subnetAddress = $subnetAddress}
return $ipaddress
}
$subnetProvision = 'X.X.X.X'
SWOIPAM-GetFreeIpAddress($subnetProvision)
Where:
- $subnetProvision = Desired subnet to get next available IP Address from
Updating the Free IP Address' status from 'Available' to 'Used':
$postParams = @{__EVENTTARGET='ctl00$BodyContent$ctl05';__EVENTARGUMENT='';'ctl00$BodyContent$Username'='admin';'ctl00$BodyContent$Password'='password'}
Invoke-WebRequest -Uri http://mysolarwinds:8787/Orion/Login.aspx?autologin=no -Method POST -SessionVariable s -Body $postParams
$postParams = @{'entity'='IPAM.IPNode';'verb'='UpdateManyStatus';'ObjectId'='129';'ipstatus'='1';'ids'='4'}
Invoke-WebRequest -Uri http://mysolarwinds:8787/Orion/IPAM/ExtCmdProvider.ashx -Method POST -WebSession $s -Body $postParams
Where:
- ObjectID : type = number => SubnetId from IPAM.IPNode
- One can obtain the SubnetId with the query: SELECT SubnetId, Address, FriendlyName, VLAN FROM IPAM.Subnet
- ipstatus : type = number => where 1 (Used), 2 (Available), 4 (Reserved)
- ids : type = number => the 4th octet of the IP Address you want to update in the specified subnet
THE QUESTION:
If the verb 'UpdateManyStatus' (with the params of ObjectID, ipstatus and ids) exist for IPAM.IPNode to update a particular IP address' status,
(@{'entity'='IPAM.IPNode';'verb'='UpdateManyStatus';'ObjectId'='129';'ipstatus'='1';'ids'='4'}),
are there any other verbs or documentation of verbs with necessary parameters for IPAM.IPNode that will update the DnsBackward (hostname), Comments and SkipScan fields for a particular IP Address??
If I can find out the verbs and their necessary parameters, then I would be able to update via the same method used for updating an IP Address' status in Powershell.
Thank you