File Cannot be Loaded The File is Not Digitally Signed You Cannot Run this Script on The Current System

bonguides.com
3 min readMay 22, 2024

--

Table of Contents

The File is Not Digitally Signed You Cannot Run this Script

Sometimes, when attempting to execute a PowerShell script on Windows systems, you may encounter the following error. Even the Execution Policy is configured as RemoteSign.

y7gBkxv73xgwSywb1L7lX3X1UPxmyjNnKQfFRw8q4QU1vCkzb3ZPgFZZNRh7

This occurs because, by default, scripts downloaded from the internet are blocked from execution to protect the system. You can check it by right-clicking on the script and then selecting Properties.

u0MxkobwOnFnIbVuWTJIRAzcpO17I3UYxZyyNDyy9P5K5AwXed1dPf82lENE

As you can see, in the security section the file is blocked because it came from another computer. To make it executable, uncheck the checkbox then click OK.

ze9cT98tjtcJJ60mYpn0lWN8AtjSNG3zzlgeD3qxgwafN9N6HvyDUAksPt5U

Alternatively, from PowerShell you can check if a file is blocked by using the Get-Item cmdlet with the -Stream parameter. If you get an error, it means the file is not blocked.

Get-Item .Add_Structure.ps1 -Stream "Zone.Identifier"

If the output resembles the one shown below, it indicates that the file is blocked. You will need to unblock it before you can execute it.

PSPath : Microsoft.PowerShell.CoreFileSystem::D:Run-in-SandboxAdd_Structure.ps1:Zone.Identifier
PSParentPath : Microsoft.PowerShell.CoreFileSystem::D:Run-in-Sandbox
PSChildName : Add_Structure.ps1:Zone.Identifier
PSDrive : D
PSProvider : Microsoft.PowerShell.CoreFileSystem
PSIsContainer : False
FileName : D:Run-in-SandboxAdd_Structure.ps1
Stream : Zone.Identifier
Length : 85

To unblock a file using PowerShell, we need the Unblock-File cmdlet.

Unblock-File .Add_Structure.ps1

Once the file is unblocked, if you check it using the Get-Item cmdlet, you will get as below. It’s expected.

PS D:Run-in-Sandbox> Unblock-File .Add_Structure.ps1
PS D:Run-in-Sandbox> Get-Item .Add_Structure.ps1 -Stream "Zone.Identifier"
Get-Item : Could not open the alternate data stream 'Zone.Identifier' of the file 'D:Run-in-SandboxAdd_Structure.ps1'.
At line:1 char:1
+ Get-Item .Add_Structure.ps1 -Stream "Zone.Identifier"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (D:Run-in-SandboxAdd_Structure.ps1:String) [Get-Item], FileNotFoundExce
ption
+ FullyQualifiedErrorId : AlternateDataStreamNotFound,Microsoft.PowerShell.Commands.GetItemCommand

Finally, use PowerShell to verify that it works.

5x3vTLJMoU8x6oxI9ORPF3wQF3be3lQ0mljht1YH7pkGf9YrhSG5VgSte1Og

Not a reader? Watch this related video tutorial:

https://youtu.be/gPrIFy4eYDk

https://bonguides.com/file-cannot-be-loaded-the-file-is-not-digitally-signed-you-cannot-run-this-script-on-the-current-system/?feed_id=279&_unique_id=664d90c3dca1b

--

--

bonguides.com

Discover some of the best IT articles, tech guides, tech tutorials, tech tips, useful scripts, how-to’s and more.