Skip to main content
All CollectionsRunning HawkScan
'hawk.ps1 cannot be loaded' error when running the hawk command with PowerShell
'hawk.ps1 cannot be loaded' error when running the hawk command with PowerShell

Troubleshooting script permissions errors when running HawkScan CLI commands in PowerShell

Anthony Stinn avatar
Written by Anthony Stinn
Updated over a year ago

Applies To

HawkScan CLI on Windows


Issue

When attempting to run a CLI command in PowerShell, an error is returned about hawk.ps1 not being loaded due to running scripts being disabled on the system.

For example:

PS C:\WINDOWS\system32> hawk version
hawk : File C:\Users\Dan\hawk-2.11.0\hawk.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.

Other variations to the error may exist after cannot be loaded, such as:

  • the file (C:\Path\To\hawk.ps1) is not digitally signed

Regardless of the other text, the error references Execution_Policies.


Cause

ExecutionPolicy configuration issue on the Windows system running the CLI.


Solution

First, check the current set of policies with Get-ExecutionPolicy -List:

PS C:\Users\Dan\projects\mnode_windows> Get-ExecutionPolicy -List
>>

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined

Note: Consult with your IT Administration team as to which of the ExecutionPolicy types are allowed in your environment.

Then, use Set-ExecutionPolicy to set the CurrentUser Scope to an ExecutionPolicy which allows the hawk.ps1 file to run.

For example:

PS C:\Users\Dan\projects\mnode_windows> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A
PS C:\Users\Dan\projects\mnode_windows> Get-ExecutionPolicy -List
>>

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Undefined

After which, the CLI script will be executable:

PS C:\WINDOWS\system32> hawk version
v2.11.0


Additional Information

To see how to install the Windows CLI in the first place, see How to run the HawkScan CLI on Windows.

Did this answer your question?