Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Would like to get unassigned IP address from static address pool with powershell

Using VMM and Hyper-V on 2012 R2.
I would like to get an available IP address from an static IP address pool and assign it to a nic on a vm:
$address = Get-SCIPAddress -UnAssigned -StaticIPAddressPool (Get-SCStaticIPAddressPool -Name "AddressPool")
$Adapter = (Get-SCVirtualNetworkAdapter -VM (get-vm -name "vmName")  | where  {$_.VLanID -eq "123"})
Set-SCVirtualNetworkAdapter -IPv4AddressType Static -VirtualNetworkAdapter $Adapter -IPv4Addresses $address[0].Address

Open in new window


However the first line returns no address. If I use the option -Assigned, I will get a list of addresses already used, but I would like the -UnAssigned switch to work. I guess I could figure out what is unassigned if i know what is assigned, but that would be a workaround.
Avatar of Dimarc67
Dimarc67
Flag of United States of America image

Are you returning IP addresses to the unassigned pool?  Any chance that the unassigned pool is empty?
Avatar of itnifl

ASKER

What is an unassigned pool? I want to get unassigned IP addresses from a static IP address pool in VMM.
ASKER CERTIFIED SOLUTION
Avatar of itnifl
itnifl
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

Seems like that was the best possible answer