Solved

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

Posted on 2014-09-06
4
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…

729 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