Using Output From One Cmdlet to Another Cmd

I'm pretty new to PS so take it easy.   The following query works to get me the IP address of a named interface.

$ActiveIP = Get-NetIPaddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -eq "UniqueName"} | Format-Table IPAddress

Then the $ActiveIP Variable returns the correct information im looking for.  I'm am utterly stuck on how to take that and pipe it correctly to another cmd.

For instance I'd like to automate the DNS config and would pipe that variable to the following...at least that's what I think, but its a no go. I'm sure its something with how im outputting, but then again i'm a noob.

Invoke-Command -ScriptBlock {DNSCMD servername /resetlistenaddresses $ActiveIP}

Any help on straightening me out would be much appreciated.


  • Edited by Slade1040 Wednesday, July 29, 2015 10:43 PM
July 29th, 2015 10:43pm

Mike,

Thanks for the info.  So if I use select-object like so:

$ActiveIP = Get-NetIPaddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -eq "UniqueName"} | Select-Object IPAddress

That returns "IPAddress=xxxxxxxxx" , but I only need the IP not the "IPAddress=", how do I filter down to just that, so I can pass that $activeIP variable correctly?

Thanks again! 


  • Edited by Slade1040 18 hours 25 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 8:47am

jrv,

I'm trying to automate my DNS config, not the DNS setting on a workstation.  Server side, DNS setup.

Thanks

July 30th, 2015 8:50am

Why are you resetting the IP on the DNS server?

WMI can configure DNS directly even remotely.  On WS2012 use the DNS CmdLets.

As I posted above twice:

$IP=(Get-NetIPAddress -InterfaceAlias wi-fi -AddressFamily ipv4).IPAddress

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 9:06am

Hi,
That returns "IPAddress=xxxxxxxxx" , but I only need the IP not the "IPAddress=", how do I filter down to just that, so I can pass that $activeIP variable correctly?

Thanks again! 

You can either use the -ExpandProperty switch of Select-Object or use jrv's dotted notation suggestion.
July 30th, 2015 9:08am

If you are using PowerShell 2 you need to upgrade to  or later.  The Net Framework for XML has changed.

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 9:15am

Thank a lot Mike that's what I needed!
July 30th, 2015 9:41am

I'm not resetting the IP of of server, i'm specifying what IP DNS should listen on...open DNS right click the servername, interfaces tab, you can specify only the following IP addresses.  that's what im trying to set...thanks.
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 9:42am

Thank a lot Mike that's what I needed!

Cheers, you're very welcome.

July 30th, 2015 9:44am

Mike,

Thanks for the info.  So if I use select-object like so:

$ActiveIP = Get-NetIPaddress -AddressFamily IPv4 | Where-Object {$_.InterfaceAlias -eq "UniqueName"} | Select-Object IPAddress

That returns "IPAddress=xxxxxxxxx" , but I only need the IP not the "IPAddress=", how do I filter down to just that, so I can pass that $activeIP variable correctly?

Thanks again! 


  • Edited by Slade1040 Thursday, July 30, 2015 12:46 PM
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 12:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics