You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PowerShell module to manage lock files using the current process and computer name.
4
+
This type of locking is useful in the event there is a script that needs to be highly available running on multiple computers but only one instance can be active at a time.
5
+
6
+
## Install
7
+
8
+
```powershell
9
+
# PowerShellGet
10
+
Install-Module LockFile
11
+
12
+
# PSResourceGet
13
+
Install-PSResource LockFile
14
+
```
15
+
16
+
## Usage
17
+
18
+
### Create Lock File
19
+
20
+
If creating a lock file that needs to be read from multiple machines use a shared path.
21
+
22
+
```powershell
23
+
Set-LockFile -Path \\scripts\myscript.lock
24
+
```
25
+
26
+
### Get Lock File
27
+
28
+
To get the configuration of the lock file.
29
+
30
+
```powershell
31
+
Get-LockFile -Path \\scripts\myscript.lock
32
+
33
+
ComputerName ProcessId ProcessName
34
+
------------ --------- -----------
35
+
TestDC 4800 pwsh
36
+
```
37
+
38
+
### Test Lock File Validity
39
+
40
+
```powershell
41
+
Test-FileLock -Path \\scripts\myscript.lock
42
+
```
43
+
44
+
You can also pipe the outputs from `Get-LockFile`.
0 commit comments