Unblock-File (PowerShell 3.0+)

Unblock files that were downloaded from the Internet.

      Unblock-File [ [-path] | -literalPath ] string[]
         [-Confirm] [-WhatIf] [CommonParameters]

   -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.

       Prompt for confirmation before executing the cmdlet.

       Describe what would happen if you executed the command without actually
       executing the command.

       -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.


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


Clear-ItemProperty - Remove the property value from a property
Clear-Variable - Remove the value from a variable

Copyright © SS64.com 1999-2017
Some rights reserved