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

Barracuda Message Archiver & Office 365 Exchange Online Service Account Configuration

The following script grant an Office 365 Exchange online service account necessary permissions on Exchange…

How to Remove Question Mark ‘Info’ Button in SyntaxHighlighter

If you're looking for a way to remove this subtle, yet spammy link: Do this:Goto…

Basic CSS: Use Clockwise Notation to Specify the Padding of an Element

<style>.injected-text {margin-bottom: -25px;text-align: center;}.box {border-style: solid;border-color: black;border-width: 5px;text-align: center;}.yellow-box {background-color: yellow;padding: 20px 40px 20px 40px;}.red-box…