I try to run following script:

https://helpdesk.paessler.com/en/support/solutions/articles/60478-how-can-i-monitor-licenses-in-my-network

but I cant, cuz the log tells me sth. I dont unterstand.

Die Datei "C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\li csense_status.ps1" kann nicht geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen erhalten Sie mit "get-hel p about_signing". Bei Zeile:1 Zeichen:2 + & <<<< 'C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\lic sense_status.ps1' ExpirationDate='18.11.2014'; exit $LASTEXITCODE + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException

After I read this msg once, I did using the "set-executionpolicy remotesigned" (I even tried "AllSigned" just sayn). But I still get the same error. Do I have to restart the System or the probe?

Any suggestions? best regards


Article Comments

Hi,
as the PRTG probe is a 32 bit process it is only able to spawn 32 bit child processes. Therefore when a Powershell script is executed the 32 bit version of Powershell is used.
Please try (for testing purposes) executing the following command in your 32 bit Powershell:

Set-ExecutionPolicy unrestricted

Afterwards, try adding the sensor again. If this works you can switch to a more restrictive execution policy.
Best regards


May, 2014 - Permalink

Hi,

thank your for your reply. I did the change on the execution policy as you said. Now I get a different error msg:

New-TimeSpan : Der Parameter "End" kann nicht gebunden werden. Der Wert "Expira tionDate=18.11.2014" kann nicht in den Typ "System.DateTime" konvertiert werden . Fehler: "Die Zeichenfolge wurde nicht als gültige DateTime erkannt. Ein unbek anntes Wort beginnt bei Index 0." Bei C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\licsense_ status.ps1:3 Zeichen:54 + $DateDifference = New-TimeSpan -Start (Get-Date) -End <<<< $ExpirationDate + CategoryInfo : InvalidArgument: (:) [New-TimeSpan], ParameterBi ndingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerSh ell.Commands.NewTimeSpanCommand

0:License expired for days!

sounds like a parameter does not fit as it should. But unfortunately I'm not that powershell pro and dont know what to do there. =/

regards


Jun, 2014 - Permalink

Without the code it is pretty hard doing debugging but I assume you are passing the date as string to the script. If so, please try casting this string explicitly to datetime format, e.g. as outlined in this article.


Jun, 2014 - Permalink

I simply copied the script from the thread I mentioned in my 1st post:

Param([string]$ExpirationDate)

$DateDifference = New-TimeSpan -Start (Get-Date) -End $ExpirationDate $Days = $DateDifference.Days $DaysPassed = ($Days * -1) if($Days -gt 0){ Write-Host $Days":License expires in "$Days" day(s)." exit 0 } if($Days -eq 0){ Write-Host $Days":The license expires today!"; exit 1 } if($Days -lt 0){ Write-Host 0":License expired for "$DaysPassed" days!" exit 1 }


Jun, 2014 - Permalink

Hi,
please try passing the expiration date in the following format:

YYYY-DD-MM

The complete call should then look somewhat like this:

yourscript.ps1 ExpirationDate="2015-30-10"

Jun, 2014 - Permalink

Hi,

I fixed it now. But its more like a workaround I came up with, not the real solution.

1st I tried to put the custom pwoershell script not in the

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML

but rather into the

C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE

...folder.

Then I the script runs through. But I still dont get any value.

So I edited the script like adding the parameter for the expiration date into it.

Param([string]$ExpirationDate)

$ExpirationDate="2014-11-18"

$DateDifference = New-TimeSpan -Start (Get-Date) -end $ExpirationDate
$Days = $DateDifference.Days
$DaysPassed = ($Days *
...

that solved it for me. Thanks.


Jun, 2014 - Permalink

Me again!

I finally found the problem, as always it was situated in front of the monitor.

In the thread:

https://helpdesk.paessler.com/en/support/solutions/articles/60478-how-can-i-monitor-licenses-in-my-network

Mr. Linke mentioned to set the Parameter of the sensor like:

ExpirationDate="2015-31-12"

But then the sensor runs in error state. But I just enter the date without the string before, it works. 2015-31-12 as parameter of the sensor and you win! :-)

PS maybe the post from Mr. Linke should edit his post?

best regards


Jun, 2014 - Permalink