greiginsydney / New-OoklaSpeedTest.ps1

GNU General Public License v3.0
7 stars 2 forks source link

Script not allowed to run on clean install #6

Closed Tuumke closed 2 years ago

Tuumke commented 2 years ago

Hey,

Just installed PRTG and have a pretty default Windows (11) installation. I couldn't get any script results so was wondering what was going on. Set it to store results always and finally got some errors back:

2022-02-06 00:07:15,090 [DEBUG] - Received Script Path: C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\New-OoklaSpeedTest.ps1
2022-02-06 00:07:15,090 [DEBUG] - Escaped Script Path: C:\Program` Files` `(x86`)\PRTG` Network` Monitor\custom` sensors\EXEXML\New-OoklaSpeedTest.ps1
2022-02-06 00:07:15,214 [DEBUG] - Script exit code was 0, but execution of the script returned an error state. Error Message: File C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\New-OoklaSpeedTest.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

When i run get-executionpolicy -list: PS C:\WINDOWS\system32> Get-ExecutionPolicy -List Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy Undefined Process Undefined CurrentUser RemoteSigned LocalMachine RemoteSigned

-edit- Found this article and did Disable new PowerShell security feature In case the first option didn't work, you can try to disable the feature under Setup > System Administration > Monitoring (/systemsetup.htm?tabid=2) > Experimental Features | PowerShell Security Enhancement.

That gave me an error result for the script:

& : File C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\New-OoklaSpeedTest.ps1 cannot be loaded 
because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:138
+ ... l.Utility};&'C:\Program Files (x86)\PRTG Network Monitor\custom senso ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
Tuumke commented 2 years ago

Alright, seems to work now. Aparently the settings are seperate for Powershell (x86) and Powershell (x64). I set them both to bypass for now. Do get a new 'error'?

<?xml version="1.0" encoding="UTF-8"?><prtg><error>1</error><text>error</text></prtg>

Tuumke commented 2 years ago

Hm seems to work now. Maybe i was too impatient :-(.. Would be good to mention the powershell x86 in the tutorial ;)