Welcome › Forums › General PowerShell Q&A › IPAM powershell to find and reserve an ip – Find-IpamFreeAddress
- This topic has 4 replies, 2 voices, and was last updated 4 months, 2 weeks ago by
Participant.
-
AuthorPosts
-
-
August 28, 2020 at 5:08 pm #253205
Hi
I am having issues getting the right info from ipam windows with powershell
here is what i type to get an ip
Get-IpamRange -StartIPAddress “10.102.4.25” -EndIPAddress “10.102.5.254” | Find-IpamFreeAddress -NumAddress 1 -TestReachability
it gets me result but i only want an ip that is not ready
I tried | Where-Object … but i dont know what parameter to call
Nothing is documented well or seems i dont get it
I want the next ip that is not ready and to be able to store in a variable
Thanks for the help
Mike
-
August 28, 2020 at 9:26 pm #253232
What exactly did you search for? First search result..
https://docs.microsoft.com/en-us/powershell/module/ipamserver/find-ipamfreeaddress?view=win10-ps
The Find-IpamFreeAddress cmdlet gets one or more free IP addresses from a range of IP addresses in IP Address Management (IPAM). If you specify the NumAddress parameter, the cmdlet returns the requested number of free IPv4 addresses. If you do not specify the NumAddress parameter, the cmdlet returns a single free IP address.
-
August 28, 2020 at 9:31 pm #253238
Here is the line I am using…
Get-IpamRange -StartIPAddress “10.102.4.25” -EndIPAddress “10.102.5.254” | Find-IpamFreeAddress -NumAddress 1 -TestReachability
but i need to identify and use if reachability is false
-
This reply was modified 4 months, 2 weeks ago by
mbmondor75.
-
This reply was modified 4 months, 2 weeks ago by
-
August 31, 2020 at 10:59 am #253523
What exactly did you search for? First search result..
https://docs.microsoft.com/en-us/powershell/module/ipamserver/find-ipamfreeaddress?view=win10-ps
The Find-IpamFreeAddress cmdlet gets one or more free IP addresses from a range of IP addresses in IP Address Management (IPAM). If you specify the NumAddress parameter, the cmdlet returns the requested number of free IPv4 addresses. If you do not specify the NumAddress parameter, the cmdlet returns a single free IP address.
I actually need to be able to find the ip, check the status and after reserve it. if the ip can ping i dont want to use it
-
September 2, 2020 at 5:15 pm #254270
$FreeIP=Get-IpamRange -StartIPAddress “10.102.4.25” -EndIPAddress “10.102.5.254” | Find-IpamFreeAddress -NumAddress 5 -TestReachability
If($FreeIP){
ForEach($IP in $FreeIP){
If($IP.PingStatus -eq ‘NoReply’){
Write-Host “Free IP found: $($IP.IpAddress)”
Set-IpamAddress -IpAddress ($IP.IpAddress).IPAddressToString
#-ManagedByService IPAM -ServiceInstance localhost -DeviceType Host -IpAddressState In-Use -AssignmentType Static -DeviceName $hostname -ForwardLookupZone croixbleue.corp -ForwardLookupPrimaryServer v1adds01 -ReverseLookupZone 4.102.10.in-addr.arpa -ReverseLookupPrimaryServer v1adds01 -PassThru | select @{N=”Name”;E={$_.DeviceName}}, @{N=”IpV4Address”;E={$_.IPaddress}} | Add-DnsServerResourceRecord -A -ZoneName “croixbleue.corp” -ComputerName $hostname -CreatePtr
}
}
}Set-IpamAddress : No MSFT_IPAM_Address objects found with property ‘Address’ equal to ‘10.102.4.131’. Verify the value of the property and retry.
At line:6 char:13
+ Set-IpamAddress -IpAddress ($IP.IpAddress).IPAddressToString
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (10.102.4.131:IPAddress) [Set-IpamAddress], CimJobException
+ FullyQualifiedErrorId : CmdletizationQuery_NotFound_Address,Set-IpamAddressWhat is wrong with my lines?
-
-
AuthorPosts
- The topic ‘IPAM powershell to find and reserve an ip – Find-IpamFreeAddress’ is closed to new replies.