RPC Server is unavailable

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Kasun Rajapakse Kasun Rajapakse 2 years, 6 months ago.

  • Author
    Posts
  • #15346
    Profile photo of Kasun Rajapakse
    Kasun Rajapakse
    Participant

    Hi,

    This is the script i run

    $KRErrorLogPreferance = "E:\Education\BIT\MCSA\Powershell\CBT Tool Making Code"

    function Get-SystemInfo{
    < # .SYNOPSIS Quieries critical information from a single computer .DESCRIPTION Quiries OS and the Hardware information from a single computer. This Utilize WMI Objects,so appropriate WMI port must be open and you must be admin on the remort machine .PARAMETER ComputerName The computer name to query, accept multiple values and pipeline input .PARAMETER IPAddress Enter the IP Address to query, pipeline is not accepted .EXAMPLE Get-SystemInfo.ps1 -ComputerName WHATEVER This will query infromation from the computer WHATEVER .EXAMPLE Get-SystemInfo.ps1 -ComputerName WHATEVER | Format-Table * This will display the information as a table #>

    [CmdletBinding()]

    Param(
    [Parameter(Mandatory=$True,
    ValueFromPipeline=$True,
    ParameterSetName='computername',
    ValueFromPipelineByPropertyName=$True,
    HelpMessage="Enter the computer name to qury WMI object")]
    [Alias('hostname')]
    [ValidateLength(4,15)]
    [string[]]$ComputerName,

    [Parameter(Mandatory=$True,
    HelpMessage="Enter the IP Address to query WMI Object",
    ParameterSetName='ip')]
    [ValidatePattern('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')]
    [string[]]$IPAddress,

    [Parameter()]
    [string]$ErrorLogFilePath =$KRErrorLogPreferance
    )

    BEGIN{
    if($PSBoundParameters.ContainsKey('ipaddress')){
    $ComputerName=$IPAddress
    }
    }

    PROCESS{

    foreach($computer in $ComputerName){

    Write-Verbose "Connecting via WMI $computer"

    $os=Get-WmiObject win32_OperatingSystem -ComputerName $computer
    $cs=Get-WmiObject win32_computerSystem -ComputerName $computer

    Write-Verbose "Finished with WMI building output"

    $props =@{'ComputerName'=$computer;
    'OSVersion'= $os.version;
    'OSBuild'=$os.BuildNumber;
    'SPVersion'=$os.ServicePackMajorVersion;
    'Model'=$cs.Model;
    'Manufacture'=$cs.Manufacturer;
    'RAM'=$cs.TotalPhysicalMemory / 1GB -as [int]
    'Sockets'=$cs.NumberOfProcessors;
    'Cores'=$cs.NumberOfLogicalProcessors
    }

    $obj = New-Object -TypeName PSObject -Property $props

    Write-Verbose "Outputing to pipeline "

    Write-Output $obj

    }
    }

    END{}
    }

    #Get-SystemInfo -ComputerName localhost
    #'kasunrajapakse','localhost','kasunrajapakse' | Get-SystemInfo
    #Import-Csv -Path 'E:\Education\BIT\MCSA\PowerShell\CBT Tool Making Code\computers.csv' | Get-SystemInfo
    Get-SystemInfo -IPAddress 127.0.0.0.1 -Verbose

    When i run it using ipaddress parameter it gives me the following error

    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At line:57 char:17
    + $os=Get-WmiObject win32_OperatingSystem -ComputerName $computer
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Please help me !!!

  • #15348
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    The IP address 127.0.0.0.1 you've provided is not valid. One .0 octet too much.

    Try again with:
    Get-SystemInfo -IPAddress 127.0.0.1 -Verbose

    Verify "localhost" address:
    ping -4 localhost

  • #15351
    Profile photo of Kasun Rajapakse
    Kasun Rajapakse
    Participant

    oh i see it thanks for pointing it to me 🙂

You must be logged in to reply to this topic.