Solved

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

Posted on 2014-09-06
4
526 Views
Last Modified: 2014-11-25
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.
0
Comment
Question by:itnifl
  • 3
4 Comments
 
LVL 4

Expert Comment

by:Dimarc67
ID: 40307772
Are you returning IP addresses to the unassigned pool?  Any chance that the unassigned pool is empty?
0
 
LVL 2

Author Comment

by:itnifl
ID: 40308310
What is an unassigned pool? I want to get unassigned IP addresses from a static IP address pool in VMM.
0
 
LVL 2

Accepted Solution

by:
itnifl earned 0 total points
ID: 40454726
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."
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 40464103
Seems like that was the best possible answer
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
OfficeMate Freezes on login or does not load after login credentials are input.
In this Micro Tutorial viewers will learn how they can get their files copied out from their unbootable system without need to use recovery services. As an example non-bootable Windows 2012R2 installation is used which has boot problems.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now