Search notes:

PowerShell: set Zone.Identifier to simulate file being downloaded from the Internet

Some browsers mark a file that was being downloaded from the file by setting this file's alternate data stream Zone.Identifier.
PowerShell relies on this information for example to determine if it should run a script.
The following example uses the PowerShell cmdlet set-content to fill the data stream Zone.Identifier, thus prepending that the file was downloaded from the Internet.
$filepath = "$pwd/simulate-downloaded-file.txt"
$url      = 'https://someUrl.xyz/'

set-content $filepath @'
Prepend that this
file was downloaded
from the internet
'@

set-content $filepath -stream Zone.Identifier @"
[ZoneTransfer]
ZoneId=3
ReferrerUrl=$url
HostUrl=$url$(split-path -leaf $filepath)
"@
Github repository about-PowerShell, path: /cmdlets/content/set/set-stream-Zone.Identifier.ps1
The cmdlet unblock-file removes this stream, which is sometimes required to be able to execute a downloaded Powershell script.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1740442704, '3.17.173.145', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/command-inventory/noun/content/set/stream-Zone-Identifier(59): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78