0

While executing the code I am getting the below error

c:\notbackdup\RPGet-ComputerInfo' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. + CategoryInfo : ObjectNotFound: (c:\notbackdup\RPGet-ComputerInfo:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

<#
.Synopsis
   Short description
.DESCRIPTION
   Long description
.EXAMPLE
   Example of how to use this cmdlet
.EXAMPLE
   Another example of how to use this cmdlet
#>
function RPGet-ComputerInfo()
{
    [CmdletBinding()]
    [Alias()]
    [OutputType([int])]
    Param
    (
        # Param1 help description
        [Parameter(Mandatory=$true,
                   ValueFromPipelineByPropertyName=$true,
                   Position=0)]
        $Servername

    )

$Services='DNS','DFS Replication','Intersite Messaging','Kerberos Key Distribution Center','NetLogon',’Active Directory Domain Services’
$hostname =$env:COMPUTERNAME

$systemuptime = (get-date) - (gcim Win32_OperatingSystem).LastBootUpTime
$lastbootuptime = Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime
$serviceStatus = $services | foreach{Get-Service -name $_ | select name,status,machinename}
$testconnection = Test-Connection -ComputerName $Servername
$Eventlog = Get-WinEvent -FilterHashtable @{logname = 'System'; id = 1074, 6005, 6006, 6008} -MaxEvents 10
$repadmin_showrepl = repadmin /showrepl
$repadminQueue= repadmin /queue


$property = @{

        "machinename" = $hostname
        "systemuptime" = $systemuptime
        "lastbootuptime" = $lastbootuptime
        "serviceStatus" = $serviceStatus
        "testconnection" = $testconnection
        "$Eventlog" = $Eventlog
        "repadmin_showrepl" = $repadmin_showrepl
        "repadminQueue" = $repadminQueue
        
        
        }

        $obj = New-Object -TypeName psobject -Property $property

return $obj
    
}

Invoke-Command -Session (Get-PSSession | select -First 1 ) -ScriptBlock {c:\notbackdup\RPGet-ComputerInfo} 

0 Answers0