Posted On March 29, 2019

PowerShell: Simulate File Open Locking

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Simulate File Open Locking
# Simulate error by creating file in current directory with some contents; then, open file in locking mode
Add-Content ($directories+”\testlock.txt”) “cowabunga!”
$file=[System.IO.File]::Open(($directories+”\testlock.txt”), ‘Open’, ‘Read’, ‘None’)
 
# Close file afterward
$file.close();

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: DHCP Server Scope Options Editing

Occasionally, internal DNS server changes as machines are refreshed and/or decommissioned. DHCP servers should also…

Use psexec to install application remotely

psexec @ComputerList.txt -u domain\administrator cmd /s /c "xcopy "\\NetworkPath\Forefront Software\Install.exe" "C:\Windows" && Install.exe /u /s…

NaN

- Meaning: Not a Number - When used as an assignment to an element index…