Category filter
Troubleshoot common scripting issues on Windows devices
1. ‘Execute Custom Script’ action still in the ‘In Progress’ state
Description: Some scripts remain in the ‘In progress’ state for a long time in the Action History page on the Hexnode portal.
Solution: The deployed script might require user interaction. Use codes that do not require any user or device UI interactions. Including the keywords -silent, -passive, -quiet, -nointeractive might make the code run silently on supported cmdlets.
2. Error when PowerShell tries to access the internet to download any file or module
Description: Deploying a script to download a file or a module returns the error, “Unable to download from URI ‘https://go.microsoft.com/fwlink/ ?LinkID=627338&clcid=0x409’ to ‘ ’.”
Cause: When PowerShell is not able to access the internet, it returns this error. This can be because the PowerShell might not be supporting TLS 1.2 protocol.
Solution: Force PowerShell to use TLS 1.2 with the PowerShell command:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 reason
3. “The term ‘xxx’ is not recognized as the term of a cmdlet, function, script file, or operable”
Description: Some commands that run fine on the terminal of the device, when included in a script, are not recognized.
Cause: Some commands only run on PowerShell x64. These commands will not be recognized when run in any other versions of PowerShell.
Solution: Force the commands to run on PowerShell x64. Include the following code snippet before the problematic commands in the script file:
1 2 3 4 5 6 7 8 9 |
if ($PSHOME -like "*syswow64*") { Write-Output 'Relaunching as x64' & (Join-Path ($PSHOME -replace 'syswow64', 'sysnative') powershell.exe) ` -File $Script:MyInvocation.MyCommand.Path ` @args Exit |
4. ‘Executing Custom Script’ action shows ‘Unknown’ status
Description: Once the script is executed, the Action History page shows an ‘Unknown’ status, and the output cannot be fetched.
Cause: This can occur if the Hexnode Agent app is restarted during the execution of the script. This could happen if,
- The device is manually restarted.
- The script executed has a restart command.
- A third-party app has triggered the device to restart.
Solution: Check the device to verify whether the script was executed successfully. If not, ensure the following and deploy the script again.
- The device is not manually restarted before the completion of the script execution.
- A restart is not triggered by any application during the script execution. If so, please close the application before deploying the script again.