问题描述
我正在尝试让 PowerShell 取消阻止 Win2K8 R2 中的文件.
I am trying to have PowerShell unblock a file in Win2K8 R2.
有人知道语法吗?
推荐答案
如果您使用的是 PowerShell v3,则可以使用 Unblock-File
cmdlet.
If you are using PowerShell v3, you can use the Unblock-File
cmdlet.
阻塞"部分只是文件的备用数据流,名为Zone.Identifier".您可以使用输入重定向在 CMD 中显示它(不过,没有其他方法可以在 CMD 中访问流):
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):
H:\Downloads> more < test.exe:Zone.Identifier
[ZoneTransfer]
ZoneId=3
您可以在 Windows Vista 及更高版本上使用 dir/r
找到它们:
You can find them using dir /r
on Windows Vista and later:
2009-10-24 12:18 54.538.056 test.exe
24 test.exe:Zone.Identifier:$DATA
同样在 CMD 中,您可以通过覆盖它来轻松摆脱它(这次使用输出重定向):
Also in CMD you can easily get rid of that by overwriting it (using output redirection, this time):
echo.>myDownloadedFile.exe:Zone.Identifier
这与完全删除 ADS 不完全相同,但在 Explorer 中工作,不再抱怨.
which isn't quite the same as removing the ADS completely, but works in that Explorer doesn't complain anymore.
似乎没有在 PowerShell 中处理 ADS 的本机支持(如 The PowerShell Guy 的博客中所述 此处.该文章还提供了一些有关如何在其中获取该功能的信息电源外壳).但是,您可以简单地调用 cmd:
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:
cmd /c "echo.>test.exe:Zone.Identifier"
这也适用于 PowerShell.
That works from PowerShell as well.
另一种选择是 Mark Russinovich 的 streams
实用程序,它允许您检查文件的 ADS 并删除它们.所以
Another option would be Mark Russinovich's streams
utility which allows you to inspect a file's ADS and also to delete them. So
streams -d myDownloadedFile.exe
同样有效.
这篇关于使用 PowerShell 取消阻止文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!