Courtesy of the long list of things you probably shouldn’t do but will anyway heres how one goes about implementing mutex locking between multiple powershell scripts.
<# 1. Instantiate Mutex Object using new-object syntax 2. Use the same "DesiredMutexName" across scripts. Or move mutex logic into a shared script included by each script desiring access to these mutexes. (. Path\ScriptWithMutexLocks.ps1) #> $mutex = new-object -TypeName System.Threading.Mutex -ArgumentList $false, "YourDesiredMutexName"; # 3. Lock Access to critical sections in each script $result = $mutex.WaitOne(); <# Critical Section #> #4 Release $mutex.ReleaseMutex(); <# Script Specific / Non viotile section #>
. . . Enjoy

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 