This article applies as of PRTG 22


Whenever I try to use a PowerShell sensor with a server or computer that is not joined to the domain, I get the message "Connecting to remote server failed: WinRM cannot process the request." 

The following error occured while using Kerberos authentication: "There are currently no logon servers available to service the logon request."



"No logon servers available" when using PowerShell sensors

With a system that is not joined to the domain, you cannot start a remote PowerShell session via Kerberos Authentication. This is the authentication type for the PowerShell sensors in PRTG.

We set this up with Kerberos because other forms of authentication are not as secure. By enabling these sensors to work with other forms of remote PowerShell session authentication, the respective servers would be open to other systems outside the domain that are initiating similar sessions.


"Unknown security error" when using PowerShell sensors

If WinRM cannot process the request and you get an Unknown security error, see the link below:

My PowerShell sensor returns an error message. What can I do?.


To collect Windows Update statistics from computer that is not joined to the domain (without Kerberos authentication)  the updates are read like this:$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope

In order to execute a command via Invoke-Script, something like this would work:

Param( [string]$ComputerName = "",  [string]$UserName = "", [string]$Password = "" )

# We need a credential object 
#######################################
function createCredentials(){
	if((($env:COMPUTERNAME) -ne $ComputerName)){
		# Generate Credentials Object first 
		$SecPasswd  = ConvertTo-SecureString $Password -AsPlainText -Force
		$Credentials= New-Object System.Management.Automation.PSCredential ($Username, $secpasswd)
		return $Credentials
	}
	else{ return "false" }
}

function getUpdates(){
    $Credentials = (CreateCredentials);
    # Generate CIMSession
    $RemoteSession = New-PSSession -ComputerName $HostName -Credential $Credentials -Name "PRTG Scheduled Task Remote Session"
    $UpdateScope = (Invoke-Command -Session $RemoteSession -ScriptBlock { New-Object Microsoft.UpdateServices.Administration.UpdateScope })

<# the output has to go here #>

	if (!($RemoteSession)){
		Write-Host 1":Error creating remote session.";
		Remove-PSSession($RemoteSession);
		exit 1;
	}

	Remove-PSSession($RemoteSession)
	exit 0
}

# Action!
getUpdates;

Since how you need the output is not fixed, have a look at this "Hey, Scripting Guy!" article, it explains how to retrieve the various updates accordingly.


Disclaimer:
The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.