Unlock Files Easily with Get-ChildItem Unblock-File – Example Script

Have you ever encountered a situation where files downloaded from the internet only to find out that they are blocked and you can’t use or install them? It can be frustrating, especially when dealing with multiple files in different folders. But what if I told you there’s a simple solution in PowerShell to unblock downloaded files from with just a single command?

Introducing the Get-ChildItem Unblock-File cmdlet in PowerShell. With this powerful command, you can easily unblock files in a directory and its subfolders, saving you time and effort. And the best part is, once the files are unblocked, you won’t have to worry about them getting blocked again, even if you copy them to another location.

So, how does this magical command work? Let’s dive in and explore the world of file unblocking in PowerShell.

Key Takeaways:

  • Get-ChildItem Unblock-File is a powerful cmdlet in PowerShell that can unblock files in a directory and its subfolders.
  • Using this command saves time and effort when dealing with multiple blocked files.
  • Once the files are unblocked, they won’t get blocked again, even if you copy them to another location.

Why are files blocked in Windows?

When you download files from the internet, Windows 10 has a security feature called SmartScreen that blocks certain file types from opening. This is to protect your computer from potentially harmful files. When you try to open a blocked file, you will see a security warning informing you that the file is blocked. This can be problematic if you need to access or use these files. Fortunately, there are methods to unblock these files and remove the security warning.

File BlockingSecurity WarningSmartScreen
Files from the internetBlocks certain file typesProtection against harmful files
Blocked fileSecurity warning displayedCannot access or use the file
Methods to unblock filesRemove the security warningAccess and use blocked files

By unblocking files, you can regain access to important documents, programs, or media that have been flagged by Windows’ security measures. In the next section, I will explain how to manually unblock files, offering step-by-step guidance to eliminate security warnings and ensure smooth file accessibility on your Windows computer.

Manual method to unblock files

In some cases, you may need to unblock files manually, especially if you are dealing with a single file. Here’s a simple step-by-step process to unblock a file using the manual method:

Note: This method is not practical for unblocking multiple files.

  1. Locate the file in File Explorer.
  2. Right-click on the file to open the context menu.
  3. Select “Properties” from the menu to access the file properties.
  4. In the Properties window, go to the “General” tab.
  5. Find and check the “Unblock” checkbox.
  6. Click “Apply” or “OK” to save the changes.

This will remove the security warning and unblock the file. However, keep in mind that this method can be time-consuming if you need to unblock multiple files individually.

The Importance of File Properties

File properties provide information about a file, such as its name, location, and size. Additionally, they also indicate if a file has been blocked. By accessing the properties of a file, you can take specific actions to unblock it and remove any security warnings.

NameThe name of the file.
LocationThe folder or directory where the file is stored.
TypeThe file type or format.
SizeThe size of the file in bytes.
BlockedIndicates if the file is blocked and unable to open.

By accessing the file properties, you can easily identify if a file is blocked and take appropriate measures to unblock it.

get-childitem unblock-files PowerShell

When you need to unblock multiple files at once, PowerShell offers a more efficient solution. By utilizing the “Unblock-File” cmdlet in PowerShell, you can quickly unblock all the files within a specific folder using just a single command. This saves you valuable time and effort in unblocking files individually.

To get started, simply open PowerShell and navigate to the folder where your files are located. Once you’re in the correct directory, run the following command:

Get-ChildItem | Unblock-File

This command utilizes the Get-ChildItem cmdlet to retrieve all the files in the current folder, and then pipes them to the Unblock-File cmdlet, which removes the block on each file. This action will recursively unblock all the files in the folder and its subfolders, effectively removing any security warnings associated with these files.

By using PowerShell, you can streamline the process of unblocking files, especially when dealing with a large number of files spread across different folders. This method offers a more efficient alternative to manually unblocking each file individually and ensures that all files are unblocked in a single operation.

If you’re unfamiliar with PowerShell, don’t worry! It’s a powerful scripting language that allows you to automate various tasks and processes on your Windows system. Give it a try, and you’ll see how PowerShell can simplify your file management and save you time in unblocking files.


Let’s say you have a folder named “Documents” that contains several blocked files. To unblock them using PowerShell, follow these steps:

  1. Open PowerShell
  2. Navigate to the “Documents” folder using the “cd” command
  3. Run the command: Get-ChildItem | Unblock-File

Once the command is executed, PowerShell will unblock all the files within the “Documents” folder and its subfolders.


Using PowerShell’s Unblock-File cmdlet allows you to efficiently remove blocks from multiple files in one go. By running a single command, you can unblock all the files in a given folder and its subfolders, saving valuable time and effort. This method offers a streamlined approach to file unblocking in PowerShell and is highly effective when dealing with numerous files scattered across different directories.

Example script to unblock files

Here is an example script that demonstrates how to use the Get-ChildItem Unblock-File cmdlet to unblock files in PowerShell:

# Script to unblock files using PowerShell

# Import the required module
Import-Module Microsoft.PowerShell.Utility

# Set the path to the folder containing the files to be unblocked
$FolderPath = "C:\Path\To\Folder"

# Get all the files in the specified folder and its subfolders
$Files = Get-ChildItem -Path $FolderPath -Recurse

# Loop through each file
foreach ($File in $Files) {
    # Unblock the file
    Unblock-File -Path $File.FullName

# Output a message when all files have been unblocked
Write-Host "All files in $FolderPath have been unblocked."

With this script, you can easily unblock multiple files at once in PowerShell. Simply replace “C:\Path\To\Folder” with the path to the folder containing the files you want to unblock, and run the script. It will recursively unblock all the files in that folder and its subfolders.

Using this example script will save you time and effort compared to manually unblocking each file individually. Now, let’s take a look at some additional tips for file unblocking in PowerShell.

Additional tips for file unblocking

In order to effectively utilize the Get-ChildItem Unblock-File cmdlet, it is important to ensure that you have PowerShell version 3 or higher. To check the version of PowerShell installed on your system, you can run the following command in PowerShell:


If the version displayed is older than 3, it is recommended to upgrade to a newer version to access the full capabilities of the cmdlet. This will ensure a smoother and more efficient file unblocking process.

Modifying the parameters of the Get-ChildItem cmdlet can also enhance your file unblocking experience. By specifying specific criteria such as file extension or date modified, you can target specific files for unblocking. This allows for greater flexibility and precision when managing your files with PowerShell.

Example: Modifying Get-ChildItem Parameters

Let’s say you want to unblock all .txt files in a particular directory. You can use the following command:

Get-ChildItem -Path "C:\Example\Directory" -Filter "*.txt" | Unblock-File
get-childitem unblock-file
Unlock Files Easily with Get-ChildItem Unblock-File - Example Script 3

This command will only unblock .txt files within the specified directory, leaving other file types untouched.

By experimenting with different parameters, you can customize the Get-ChildItem cmdlet to suit your specific file unblocking needs.

Keep in mind that understanding and using PowerShell versions and modifying Get-ChildItem parameters will empower you to optimize your file unblocking process and efficiently manage your files with ease.


In conclusion, the Get-ChildItem Unblock-File cmdlet in PowerShell provides a convenient and efficient solution to unlock files that have been downloaded from the internet. By using this method, you can easily remove the security warnings and unblock multiple files with just a single command. This saves you time and effort, especially when dealing with numerous files in different folders.

Compared to the manual method of unblocking files individually, PowerShell’s Get-ChildItem Unblock-File cmdlet streamlines your file management process. The example script provided in this article demonstrates how to use this cmdlet effectively. Simply follow the outlined steps and unleash the full potential of PowerShell for managing your files.

With PowerShell’s file unblocking capabilities, you can ensure seamless access and use of downloaded files without any security warnings. Whether you’re a developer working with multiple files or an avid internet user, mastering this technique will enhance your productivity and simplify your file management workflow in PowerShell.

Leave a Comment