Перейти к содержимому

Как разблокировать файлы через powershell

  • автор:

Unblock a file with PowerShell?

I am trying to have PowerShell unblock a file in Win2K8 R2.

Does anyone have a pointer as to the syntax?

13 Answers 13

If you are using PowerShell v3, you can use the Unblock-File cmdlet.

The «blocking» part is simply an alternate data stream of the file, named «Zone.Identifier». You can display it in CMD by using input redirection (no other way to get to a stream in CMD, though):

You can find them using dir /r on Windows Vista and later:

Also in CMD you can easily get rid of that by overwriting it (using output redirection, this time):

which isn’t quite the same as removing the ADS completely, but works in that Explorer doesn’t complain anymore.

There doesn’t seem to be native support for handling ADS from within PowerShell (as mentioned on The PowerShell Guy’s blog here. That article also has some information how to get that functionality in PowerShell). You could, however, simply call cmd:

That works from PowerShell as well.

Another option would be Mark Russinovich’s streams utility which allows you to inspect a file’s ADS and also to delete them. So

Sorry, you have been blocked

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

What can I do to resolve this?

You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.

Cloudflare Ray ID: 7a29b5badba124a1 • Your IP: Click to reveal 88.135.219.175 • Performance & security by Cloudflare

Use PowerShell to unblock files on Windows

When you save files, such as a PDF or a ZIP file, from a remote location (eg from the internet), Windows tries to protect our machine by blocking it using the Alternate Data Streams (ADS) technology.

To check if a file is blocked, just look at its properties, as shown in the picture below. From here, you can unblock it.

Use PowerShell to unblock files on Windows

This file came from another computer and might be blocked to help protect this computer.

But what if you want to unblock more than one file in one folder? As long as you know that there is no security issue for these files, you can unblock them all with the help of PowerShell.

Unblock files in a folder using PowerShell

Type the following command to unblock all files in a folder by changing the path of the folder to yours.

Get-ChildItem -Path ‘C:\Users\Dimitris\Downloads\’ | Unblock-File

Or for a shortcut, try the following.

gci ‘C:\Users\Dimitris\Downloads \’ | Unblock-File

If you want to unblock all files that exist in the sub-folders as well, just add the -Recurse switch.

Get-ChildItem -Path ‘C:\Users\Dimitris\Downloads\’ -Recurse | Unblock-File

Пакетная разблокировка файлов, загруженных из Интернета в Windows 10

Когда вы загружаете файлы из Интернета, Windows добавляет к ним информацию о зоне и сохраняет ее в альтернативной файловой системе NTFS. Windows 10 показывает предупреждение системы безопасности каждый раз, когда вы пытаетесь ее открыть. Некоторые типы файлов полностью заблокированы для открытия. SmartScreen, функция безопасности Windows 10, вызывает такое поведение. Но даже если SmartScreen выключен, вы все равно получите предупреждение и вам потребуется разблокировать загруженные файлы. Хотя вы можете разблокировать свои файлы один за другим, как описано здесь Как разблокировать файлы, загруженные из Интернета в Windows 10, это очень трудоемкая операция. Если вам нужно разблокировать кучу файлов, загруженных из Интернета в Windows 10, вот как вы можете это сделать.

Когда вы пытаетесь открыть файл, который был загружен из Интернет, вы видите предупреждение, подобное этому:

Чтобы избежать этого и разблокировать все файлы в папке в Windows 10 , нам нужно использовать командную строку PowerShell.

Допустим, вы хотите разблокировать все загруженные файлы в папке «Загрузки», расположенной внутри профиль пользователя. Эта папка по умолчанию используется почти всеми приложениями, такими как веб-браузеры, менеджеры загрузок и т. Д., Поэтому файлы в ней обычно блокируются. Чтобы разблокировать их все сразу, вам необходимо сделать следующее:

  1. Откройте PowerShell, как описано в следующей статье: Все способы открытия PowerShell в Windows 10.
  2. Введите следующую команду:

Замените часть «c: users winaero downloads» фактическим путем к вашей папке.

Затем вы можете опустить путь к папке и выполните следующую команду:

Эта команда PowerShell не производит никакого вывода. Он работает бесшумно и очень быстро.

Совет: вы можете напрямую открыть командное окно PowerShell в нужной папке. Все, что вам нужно сделать, это щелкнуть меню «Файл» проводника -> Открыть Windows Powershell -> Открыть Windows Powershell. См. Следующий снимок экрана:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *