Unblock files that were downloaded from the Internet.
Syntax Unblock-File [ [-path] | -literalPath ] string[] [-Confirm] [-WhatIf] [CommonParameters] Key -path string[] The files to unblock. Wildcard characters are supported. -literalPath string[] The files to unblock, like Path above, only the value is used exactly as typed. No characters are interpreted as wildcards. If the path includes any escape characters then enclose the path in single quotation marks. -confirm Prompt for confirmation before executing the cmdlet. -whatIf Describe what would happen if you executed the command without actually executing the command. CommonParameters -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer and -OutVariable
Unblock-File unblocks PowerShell script files that have been 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 Unblock-File, review the file and its source and verify that it is safe to open.
Internally, Unblock-File removes the Zone.Identifier alternate data stream, which has a value of "3" to indicate that it was downloaded from the Internet.
Examples
Unblock a file:
PS C:> Unblock-File -Path C:\Downloads\cryptovirus.xls
Unblock multiple .XLS files:
PS C:> dir C:\Downloads\*.xls | Unblock-File
The -Stream parameter of Get-Item can be used to get all currently blocked files by searching for the Zone.Identifier stream:
PS C:> Get-Item C:\Downloads\* -Stream "Zone.Identifier" -ErrorAction SilentlyContinue
“The block of granite which was an obstacle in the pathway of the weak becomes a stepping-stone in the pathway of the strong” ~ Thomas Carlyle
Related PowerShell Cmdlets:
Get-FileHash - Compute the hash value for a file.