Search code examples
windowsfilepowershellpowershell-4.0alternate-data-stream

Block a file with Powershell


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.


Solution

  • 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