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

Using Telnet and PowerShell to Test SMTP Relay

PowerShell Method: Example of Failure: PS C:\> sendTestEmail '[email protected]' 'password' '[email protected]'Detected MX Record : ywpjf4z5siycosmh7uqymtuygcjehuc67wa6o4rq4k2a3g2aodma.mx-verification.google.comKnown…

Linux: How to Set Startup Script

In previous Linux versions, startup scripts can simply be enabled by linking a script into…

How To Move WordPress Site To Kubernetes Cluster

a. Create backups of source files and database - Logon to Current Hosting Provider to…