PowerTip: Use PowerShell 3.0 to Find an IP Address

Summary: Using Windows PowerShell 3.0 on Windows 8 or Windows Server 2012 to display the IP address.

Hey, Scripting Guy! Question How can I use Windows PowerShell 3.0 on Windows 8 or Windows Server 2012 to display IP address configurations?

Hey, Scripting Guy! Answer Use the Get-NetAdapter cmdlet and filter for net adapters that have a status of up. Pipe the results to the Get-NetIPAddress cmdlet. To produce a nice output, send the results to the Format-Tablecmdlet, as shown here.

Get-NetAdapter | ? status -eq 'up' | Get-NetIPAddress -ea 0 | ft ipaddress, interfacealias, prefixorigin -a

Comments (7)

  1. Anonymous says:

    Is there any way to get all of the new comdlets provided in '08 and 2012 into my r2 and win 7 boxes.  I have downloaded powershell v3 and installed it but I still don't see these new cmdlet's when I search for them.  

  2. mredwilson says:

    @AballahSonDis If you have installed PowerShell 3 on, say perhaps, Windows 7, then many of the new cmdlets — those based on CIM wrappers are not available because they are part of the Windows 8 operating system. To see all of your available cmdlets load all your modules GMO -List | IPMO and then use Get-Command to see the new commands.

    @Shraddha see this blog article blogs.technet.com/…/use-powershell-to-identify-your-real-network-adapter.aspx

  3. I require Powershell which checks for a string value in a file if not present it will append the val says:

    Hi All,

    I require a powershell script which will check the particular string value in txt file and if not present  that string will be appended otherwise not.Any help is much apprecaited

    many thanks

  4. Shraddha says:

    How about Windows7? what could be the script?

  5. ML49448 says:

    Hi Scripting Guys!

    Why is it that "IPAddress" was not included as default property of the NetAdapter? Why do we have pipe to another cmdlet to get that basic piece of information?

Skip to main content