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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you returning IP addresses to the unassigned pool?  Any chance that the unassigned pool is empty?
itniflAuthor Commented:
What is an unassigned pool? I want to get unassigned IP addresses from a static IP address pool in VMM.
itniflAuthor Commented:
Seems that there is no way to get unassigned IP addresses with this cmdlet. The -unassigned switch retrieves allocated addresses that have not been assigned to a resource: http://technet.microsoft.com/library/jj654453(v=sc.20).aspx
"Retrieves IP addresses or MAC addresses that have been allocated from an address pool but not assigned to a resource."

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itniflAuthor Commented:
Seems like that was the best possible answer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.