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

Indications that Chocolatey is locked down

# System's version is less than vendor's current (Chocolatey v0.10.15) 0+000+00[LAX-WEB005]: PS C:\Users\testadmin\Documents> choco source…

PowerShell: Set Service Startup Mode

# setServiceStartupMode.ps1 # Set auto start and restart upon failures $computernames=@( 'TESTWINDOWS001', 'TESTWINDOWS002' ) $serviceName='windows_exporter'…

Virtual Machine Manager Error ID 23351 FirstBootDevice Invalid

When moving, importing, exporting Generation 2 template in VMM, the following error occurs when trying…
Other project: DragonCoin.com