CmdID / PowerShell / Cmdlets / Unblock
Unblock-File
Unblocks files that were downloaded from the internet. PowerShell reference
From the PowerShell reference 4 parameters
What it does
Unblocks files that were downloaded from the internet. The Unblock-File cmdlet lets you open files that were downloaded from the internet. It unblocks PowerShell script files that were downloaded from the internet so you can run them, even when the PowerShell execution policy is RemoteSigned. By default, these files are blocked to protect the computer from untrusted files. Before using the Unblock-File cmdlet, review the file and its source and verify that it is safe to open. Internally, the Unblock-File cmdlet removes the Zone.Identifier alternate data stream, which has a value of 3 to indicate that it was downloaded from the internet. For more information about PowerShell execution policies, see about_Execution_Policies. This cmdlet was introduced in Windows PowerShell 3.0.
Unblock-File [-Path] <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]Unblock-File -LiteralPath <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
Unblock a file
PS C:> Unblock-File -Path C:\Users\User01\Documents\Downloads\PowerShellTips.chmIdentifyUnblock multiple files
PS C:> dir C:\Downloads\PowerShell | Unblock-FileIdentifyFind and unblock scripts
PS C:> Get-Item * -Stream "Zone.Identifier" -ErrorAction SilentlyContinue
FileName: C:\ps-test\Start-ActivityTracker.ps1
Stream Length
------ ------
Zone.Identifier 26
PS C:> C:\ps-test\Start-ActivityTracker.ps1
C:\ps-test\Start-ActivityTracker.ps1 : File C:\ps-test\Start-ActivityTracker.ps1 cannot
be loaded. The file C:\ps-test\Start-ActivityTracker.ps1 is not digitally signed. The script
will not execute on the system. For more information, see about_Execution_Policies.
At line:1 char:1
+ C:\ps-test\Start-ActivityTracker.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS C:> Get-Item C:\ps-test\Start-ActivityTracker.ps1 | Unblock-FileIdentifyIts page in the reference: Unblock-File.
Parameters
-LiteralPathSpecifies the files to unblock. Unlike Path, the value of the LiteralPath parameter is used exactly as it is typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks ('). Single quotation marks tell PowerShell not to interpret any characters as escape sequences.-PathSpecifies the files to unblock. Wildcard characters are supported.-ConfirmPrompts you for confirmation before running the cmdlet.-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.