locked
Get-IPAddress PowerShell cmdlet is not Functioning? RRS feed

  • Question

  • Hello everyone!

    I am new to Windows PowerShell and I am having difficulty with a particular cmdlet (Get-IPAddress). At the moment my PowerShell prompt does not even recognize the cmdlet. Please see the output below:

    PS C:\> get-help get-ipaddress
    Get-Help : Cannot find Help for topic "get-ipaddress".
    At line:1 char:9
    + get-help <<<<  get-ipaddress
        + CategoryInfo          : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
        + FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand

    Furthermore, I believe I ran this command yesterday (Get-IPAddress google.com) but today if I issue the command I get the following output:

    PS C:\> Get-IPAddress google.com
    The term 'Get-IPAddress' is not recognized as the name of a cmdlet, function, script file, or operabl
    he spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:14
    + Get-IPAddress <<<<  google.com
        + CategoryInfo          : ObjectNotFound: (Get-IPAddress:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

    May someone please provide insight on this? Does this cmdlet exist? If so, how is my syntax incorrect? I would like to use this cmdlet to resolve hostnames to IP addresses. I know that the command nslookup also provides hostname to IP address resolution but I would like to learn the Get-IPAddress command so that I may create PowerShell scripts.

    Thank you in advance for any assistance!



    Friday, February 1, 2013 2:12 PM

Answers

  • Get-IPAddress is not a core cmdlet within powershell.

    Update:

    here is a list of Net TCP/IP cmdlets: http://technet.microsoft.com/en-us/library/hh826123.aspx  which applies to Server 2012.

    • Edited by G. Samuel Hays Friday, February 1, 2013 2:34 PM Updated Info
    • Proposed as answer by G. Samuel Hays Friday, February 1, 2013 3:31 PM
    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 2:32 PM
  • I think you may be looking for  Get-NetIPAddress


    Mike Crowley | MVP
    My Blog -- Planet Technologies

    • Proposed as answer by Mike Crowley Friday, February 1, 2013 3:30 PM
    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 3:29 PM
  • Get-IPAddresses of IPV6 capable adapters (author jrv)

    <# 
    # Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2011
    # 
    
            Converted from codeplex
            Demo code shows how to ewxtract individual types of address
    # NAME:  get-IPAddress.ps1
    # 
    # AUTHOR: James Vierra , Designed Systems & Services
    # DATE  : 12/18/2011
    # 
    # COMMENT:   Return IP Addresses of IPV6 enabled adapters
    #   
    #>
    #requires -version 2.0
    function get-IPAddress {
        [CmdletBinding()]
        param (
            [string]$computer=$env:COMPUTERNAME
        )
        
        Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computer -filter 'IPEnabled="True"' |
        ForEach-Object{
        
            $address = $_.IPAddress[1]            
        
            Write-Verbose "Test for ::"
            if ($_.IPAddress[1].Contains("::")){
                $blocks = $_.IPAddress[1] -split ":"
                $count = $blocks.Count
                $replace = 8 - $count + 1
                for ($i=0; $i -le $count-1; $i++){
                    if ($blocks[$i] -eq ""){
                        $blocks[$i] = ("0000:" * $replace).TrimEnd(":")
                    }
                }
                $address = $blocks -join ":"
            }            
        
            Write-Verbose "Check leading 0 in place"
            $blocks = $address -split ":"
            for ($i=0; $i -le $blocks.Count-1; $i++){
                if ($blocks[$i].length -ne 4){
                    $blocks[$i] = $blocks[$i].Padleft(4,"0")
                }
            }
        
            $address = $blocks -join ":"            
          
            New-Object -TypeName PSObject -Property @{
                    Description = $($_.Description)
                    IPv4Address = $($_.IPAddress[0])
                    IPv4Subnet = $($_.IPSubnet[0])
                    IPv6Address = $address
                    IPv6Subnet = $($_.IPSubnet[1])
                    DeviceId =  $($_.Index)
                }
        }
    }
    
    get-IPAddress

    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 3:42 PM

All replies

  • Get-IPAddress is not a core cmdlet within powershell.

    Update:

    here is a list of Net TCP/IP cmdlets: http://technet.microsoft.com/en-us/library/hh826123.aspx  which applies to Server 2012.

    • Edited by G. Samuel Hays Friday, February 1, 2013 2:34 PM Updated Info
    • Proposed as answer by G. Samuel Hays Friday, February 1, 2013 3:31 PM
    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 2:32 PM
  • I think you may be looking for  Get-NetIPAddress


    Mike Crowley | MVP
    My Blog -- Planet Technologies

    • Proposed as answer by Mike Crowley Friday, February 1, 2013 3:30 PM
    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 3:29 PM
  • Get-IPAddresses of IPV6 capable adapters (author jrv)

    <# 
    # Microsoft PowerShell Source File -- Created with SAPIEN Technologies PrimalScript 2011
    # 
    
            Converted from codeplex
            Demo code shows how to ewxtract individual types of address
    # NAME:  get-IPAddress.ps1
    # 
    # AUTHOR: James Vierra , Designed Systems & Services
    # DATE  : 12/18/2011
    # 
    # COMMENT:   Return IP Addresses of IPV6 enabled adapters
    #   
    #>
    #requires -version 2.0
    function get-IPAddress {
        [CmdletBinding()]
        param (
            [string]$computer=$env:COMPUTERNAME
        )
        
        Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computer -filter 'IPEnabled="True"' |
        ForEach-Object{
        
            $address = $_.IPAddress[1]            
        
            Write-Verbose "Test for ::"
            if ($_.IPAddress[1].Contains("::")){
                $blocks = $_.IPAddress[1] -split ":"
                $count = $blocks.Count
                $replace = 8 - $count + 1
                for ($i=0; $i -le $count-1; $i++){
                    if ($blocks[$i] -eq ""){
                        $blocks[$i] = ("0000:" * $replace).TrimEnd(":")
                    }
                }
                $address = $blocks -join ":"
            }            
        
            Write-Verbose "Check leading 0 in place"
            $blocks = $address -split ":"
            for ($i=0; $i -le $blocks.Count-1; $i++){
                if ($blocks[$i].length -ne 4){
                    $blocks[$i] = $blocks[$i].Padleft(4,"0")
                }
            }
        
            $address = $blocks -join ":"            
          
            New-Object -TypeName PSObject -Property @{
                    Description = $($_.Description)
                    IPv4Address = $($_.IPAddress[0])
                    IPv4Subnet = $($_.IPSubnet[0])
                    IPv6Address = $address
                    IPv6Subnet = $($_.IPSubnet[1])
                    DeviceId =  $($_.Index)
                }
        }
    }
    
    get-IPAddress

    • Marked as answer by Yan Li_ Tuesday, February 5, 2013 3:06 AM
    Friday, February 1, 2013 3:42 PM
  • First, thank you all for your help.

    Also, I am running Windows PowerShell in Windows 7 Professional.

    Lastly, the link below provides information on using the Get-IPAddress cmdlet. Is this incorrect?

    http://blogs.technet.com/b/wsnetdoc/archive/2011/10/17/windows-powershell-script-resolve-ip-address-from-hostname.aspx

    Friday, February 1, 2013 4:16 PM
  • That link specifically says that it's a script to be downloaded, not a cmdlet. The code to the script was posted above by Kazun.

    You'll need to save it to a file and treate it as a script.


    G. Samuel Hays

    Friday, February 1, 2013 4:20 PM