Unblock File - PowerShell
Overview
Unblock-File is a PowerShell command that removes the “blocked” attribute from files downloaded from the internet. By default, files downloaded from the internet are blocked to protect your computer from potentially malicious software. This command allows you to unblock the files so that you can open and use them.
Syntax
Unblock-File [-Path] <string[]>
Options/Flags
| Option | Description | Default |
|—|—|—|
| -Path | The path to the file(s) you want to unblock. Accepts wildcards. | Required |
Examples
Simple Usage
Unblock-File "c:\path\to\file.exe"
Unblock Multiple Files
Unblock-File "c:\path\to\file1.exe" "c:\path\to\file2.exe"
Use Wildcards
Unblock-File "c:\path\to\file*.exe"
Common Issues
“The file is not blocked” error
If you receive this error, the file may not be blocked. Check the file’s properties to verify that the “Blocked” attribute is set to “Yes”.
“Access denied” error
You may need to run PowerShell as an administrator to unblock files.
Integration
Unblock-File can be integrated with other PowerShell commands or tools for advanced tasks. For example, you could use it as part of a script to automatically unblock all downloaded files in a specific folder.
Related Commands
- Get-Item
- Set-ItemProperty
- Remove-Item