I want to block (not unblock) a file with Powershell. I want to cause Windows to believe that a file on disk was downloaded from the internet, or whatever other scenario exists such that files become blocked. I need this to test how some software I'm developing behaves in the presence of a blocked file.
Asked
Active
Viewed 2,974 times
1 Answers
10
If you're just trying to add the zone identifier you could try something like this:
$data = "[ZoneTransfer]
ZoneId=3"
Set-Content example.txt -Stream "Zone.Identifier" -Value $data

Nacimota
- 22,395
- 6
- 42
- 44
-
1I used the following for the newline in $data: $data = "[ZoneTransfer]`nZoneId=3" – Suraj Mar 31 '18 at 18:11
-
5Applying the comment from @SFun28 to the answer yields the one-liner: ``Set-Content example.txt -Stream "Zone.Identifier" -Value "[ZoneTransfer]`nZoneId=3"`` – Starson Hochschild Feb 24 '21 at 17:11