Skip to content

Commit 9601439

Browse files
Merge branch 'dev' into 'master'
Release 2.7 See merge request fozzy-winadmins/AutomaticMaintenance!3
2 parents c9a285f + 94b03b8 commit 9601439

9 files changed

+262
-107
lines changed

AutomaticMaintenance.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
RootModule = 'AutomaticMaintenance.psm1'
3-
ModuleVersion = '2.6'
3+
ModuleVersion = '2.7'
44
GUID = '8e34abf8-40ba-4c68-8bf8-f235cd001d82'
55
Author = 'Kirill Nikolaev'
66
CompanyName = 'Fozzy Inc.'

AutomaticMaintenance.psm1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ $ModuleName = ($MyInvocation.MyCommand.Name).Substring(0, ($MyInvocation.MyComma
2424

2525
[int]$ModuleWidePreventiveLockTimeout = 60
2626
[System.TimeSpan]$ModuleWidePreventiveLockThreshold = New-Object -TypeName 'System.TimeSpan' -ArgumentList @(1, 0, 0)
27+
[bool]$ModuleWideSkipPreventivelyLocked = $true
28+
[bool]$ModuleWideSkipNotLockable = $true
2729

2830
[int]$ModuleWideInstallUpdateTimeout = 60
2931
[System.TimeSpan]$ModuleWideInstallUpdateThreshold = New-Object -TypeName 'System.TimeSpan' -ArgumentList @(1, 0, 0)

Config-Example.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
[int]$ModuleWidePreventiveLockTimeout = 60
2525
[System.TimeSpan]$ModuleWidePreventiveLockThreshold = New-Object -TypeName 'System.TimeSpan' -ArgumentList @(1, 0, 0)
26+
[bool]$ModuleWideSkipPreventivelyLocked = $true
27+
[bool]$ModuleWideSkipNotLockable = $true
2628

2729
[int]$ModuleWideInstallUpdateTimeout = 60
2830
[System.TimeSpan]$ModuleWideInstallUpdateThreshold = New-Object -TypeName 'System.TimeSpan' -ArgumentList @(1, 0, 0)

Public/Invoke-ComputerMaintenance.ps1

Lines changed: 133 additions & 99 deletions
Large diffs are not rendered by default.

Public/Invoke-InfrastructureMaintenance.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function Invoke-InfrastructureMaintenance {
77
[string]$LogErrorFilePath = $ModuleWideLogErrorFilePath,
88
[string]$LogFilePathTemplate = $ModuleWideLogFilePathTemplate,
99
[string]$LogMutexName = $ModuleWideTextLogMutexName,
10-
[switch]$DebugLog = $ModuleWideDebugLog
10+
[switch]$DebugLog = $ModuleWideDebugLog,
11+
[switch]$FailOnPreviousFailure = $ModuleWideFailOnPreviousFailure
1112
)
1213

1314
$ErrorActionPreference = 'Stop'
@@ -20,9 +21,9 @@ function Invoke-InfrastructureMaintenance {
2021
Write-Debug -Message ('$LogErrorFilePath = ''{0}''' -f $LogErrorFilePath)
2122
Write-Debug -Message ('$LogFilePathTemplate = ''{0}''' -f $LogFilePathTemplate)
2223

23-
Write-Debug -Message ('$ModuleWideFailOnPreviousFailure : ''{0}''' -f $ModuleWideFailOnPreviousFailure)
24-
Write-Debug -Message 'if ($ModuleWideFailOnPreviousFailure)'
25-
if ($ModuleWideFailOnPreviousFailure) {
24+
Write-Debug -Message ('$FailOnPreviousFailure : ''{0}''' -f $FailOnPreviousFailure)
25+
Write-Debug -Message 'if ($FailOnPreviousFailure)'
26+
if ($FailOnPreviousFailure) {
2627
Write-Debug -Message ('$LogErrorFileExistence = Test-Path -Path ''{0}''' -f $LogErrorFilePath)
2728
$LogErrorFileExistence = Test-Path -Path $LogErrorFilePath
2829
Write-Debug -Message ('$LogErrorFileExistence: {0}' -f $LogErrorFileExistence)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ There are several variables defined in the .psm1-file, which are used by the mod
8181
* `[bool]$ModuleWideDebugLog` - Default value for **Invoke-InfrastructureMaintenance**'s `-DebugLog` parameter.
8282
* `[string]$ModuleWideTextLogMutexName` - Default value for **Invoke-InfrastructureMaintenance**'s `-LogMutexName` parameter.
8383
* `[string]$ModuleWideErrorLogMutexName` - The name of a mutex used to access an error log file object.
84-
* `[bool]$ModuleWideFailOnPreviousFailure` - Defines if the maintenance process should not start when the error log exists.
84+
* `[bool]$ModuleWideFailOnPreviousFailure` - Default value for **Invoke-InfrastructureMaintenance**'s `-FailOnPreviousFailure` parameter.
8585

8686
* `[string]$ModuleWideMaintenanceLogFilePath` - A path to the maintenance track log file.
8787
* `[string]$ModuleWideMaintenanceLogMutexName` - The name of a mutex used to access the maintenance track log file object.
8888
* `[string]$ModuleWideMaintenanceLogFileDelimiter` - A delimiter used to split columns in the maintenance track log file.
8989

9090
* `[int]$ModuleWidePreventiveLockTimeout` - Default value for **Invoke-ComputerMaintenance**'s `-PreventiveLockTimeout` parameter.
9191
* `[System.TimeSpan]$ModuleWidePreventiveLockThreshold` - Default value for **Invoke-ComputerMaintenance**'s `-PreventiveLockThreshold` parameter.
92+
* `[bool]$ModuleWideSkipPreventivelyLocked` - Default value for **Invoke-ComputerMaintenance**'s `-SkipPreventivelyLocked` parameter.
93+
* `[bool]$ModuleWideSkipNotLockable` - Default value for **Invoke-ComputerMaintenance**'s `-SkipNotLockable` parameter.
9294

9395
* `[int]$ModuleWideInstallUpdateTimeout` - Specifies, in seconds, how often the module will request the state of an install update scheduled task. Effectively, this parameter defines the minimum time which the installation will take.
9496
* `[System.TimeSpan]$ModuleWideInstallUpdateThreshold` - Specifies how long the module will wait for the update installation to finish.

docs/Invoke-ComputerMaintenance.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,36 @@ Accept pipeline input: False
8484
Accept wildcard characters: False
8585
```
8686
87+
### -SkipNotLockable
88+
Defines if the maintenance process should silently skip a host if the function cannot put a host lock on it. Otherwise the function will raise an exception.
89+
90+
```yaml
91+
Type: SwitchParameter
92+
Parameter Sets: (All)
93+
Aliases:
94+
95+
Required: False
96+
Position: Named
97+
Default value: None
98+
Accept pipeline input: False
99+
Accept wildcard characters: False
100+
```
101+
102+
### -SkipPreventivelyLocked
103+
Defines if the maintenance process should silently skip a host if it is locked by some other function. Otherwise the function will raise an exception.
104+
105+
```yaml
106+
Type: SwitchParameter
107+
Parameter Sets: (All)
108+
Aliases:
109+
110+
Required: False
111+
Position: Named
112+
Default value: None
113+
Accept pipeline input: False
114+
Accept wildcard characters: False
115+
```
116+
87117
### CommonParameters
88118
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
89119

docs/Invoke-InfrastructureMaintenance.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ Accept pipeline input: False
9999
Accept wildcard characters: False
100100
```
101101
102+
### -FailOnPreviousFailure
103+
Defines if the maintenance process should not start when an error log exists.
104+
105+
```yaml
106+
Type: SwitchParameter
107+
Parameter Sets: (All)
108+
Aliases:
109+
110+
Required: False
111+
Position: Named
112+
Default value: None
113+
Accept pipeline input: False
114+
Accept wildcard characters: False
115+
```
116+
102117
### CommonParameters
103118
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
104119

en-US/AutomaticMaintenance-help.xml

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
</maml:description>
208208
</command:details>
209209
<maml:description>
210-
<maml:para>Use this function to perform maintenance on a single host, defined in the hosts configuration file. If you use an orchestration/configuration management system, you might want to execute this function from there.</maml:para>
210+
<maml:para>Use this function to perform maintenance on a single host, defined in the hosts configuration file. If you use an orchestration/configuration management system, you might prefer it over Invoke-InfrastructureMaintenance to run Invoke-ComputerMaintenance .</maml:para>
211211
</maml:description>
212212
<command:syntax>
213213
<command:syntaxItem>
@@ -248,6 +248,28 @@
248248
</dev:type>
249249
<dev:defaultValue>None</dev:defaultValue>
250250
</command:parameter>
251+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
252+
<maml:name>SkipNotLockable</maml:name>
253+
<maml:Description>
254+
<maml:para>Defines if the maintenance process should silently skip a host if the function cannot put a host lock on it. Otherwise the function will raise an exception.</maml:para>
255+
</maml:Description>
256+
<dev:type>
257+
<maml:name>SwitchParameter</maml:name>
258+
<maml:uri />
259+
</dev:type>
260+
<dev:defaultValue>False</dev:defaultValue>
261+
</command:parameter>
262+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
263+
<maml:name>SkipPreventivelyLocked</maml:name>
264+
<maml:Description>
265+
<maml:para>Defines if the maintenance process should silently skip a host if it is locked by some other function. Otherwise the function will raise an exception.</maml:para>
266+
</maml:Description>
267+
<dev:type>
268+
<maml:name>SwitchParameter</maml:name>
269+
<maml:uri />
270+
</dev:type>
271+
<dev:defaultValue>False</dev:defaultValue>
272+
</command:parameter>
251273
</command:syntaxItem>
252274
</command:syntax>
253275
<command:parameters>
@@ -287,6 +309,30 @@
287309
</dev:type>
288310
<dev:defaultValue>None</dev:defaultValue>
289311
</command:parameter>
312+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
313+
<maml:name>SkipNotLockable</maml:name>
314+
<maml:Description>
315+
<maml:para>Defines if the maintenance process should silently skip a host if the function cannot put a host lock on it. Otherwise the function will raise an exception.</maml:para>
316+
</maml:Description>
317+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
318+
<dev:type>
319+
<maml:name>SwitchParameter</maml:name>
320+
<maml:uri />
321+
</dev:type>
322+
<dev:defaultValue>False</dev:defaultValue>
323+
</command:parameter>
324+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
325+
<maml:name>SkipPreventivelyLocked</maml:name>
326+
<maml:Description>
327+
<maml:para>Defines if the maintenance process should silently skip a host if it is locked by some other function. Otherwise the function will raise an exception.</maml:para>
328+
</maml:Description>
329+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
330+
<dev:type>
331+
<maml:name>SwitchParameter</maml:name>
332+
<maml:uri />
333+
</dev:type>
334+
<dev:defaultValue>False</dev:defaultValue>
335+
</command:parameter>
290336
</command:parameters>
291337
<command:inputTypes>
292338
<command:inputType>
@@ -341,7 +387,7 @@
341387
</maml:description>
342388
</command:details>
343389
<maml:description>
344-
<maml:para>The function performs maintenance on all hosts defined in the hosts configuration files, one by one. Its main purpose is to be executed from Task Scheduler. We do not recommend to execute this function from an orchestration/configuration management system (Ansible, Chef, System Center Orchestrator etc.) - use `Invoke-ComputerMaintenance` for that.</maml:para>
390+
<maml:para>The function performs maintenance on all hosts defined in the hosts configuration files, one by one. Its main purpose is to be executed from Task Scheduler. We do not recommend to execute this function from an orchestration/configuration management system (Ansible, Chef, System Center Orchestrator etc.) - use Invoke-ComputerMaintenance for that.</maml:para>
345391
</maml:description>
346392
<command:syntax>
347393
<command:syntaxItem>
@@ -393,6 +439,17 @@
393439
</dev:type>
394440
<dev:defaultValue>False</dev:defaultValue>
395441
</command:parameter>
442+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
443+
<maml:name>FailOnPreviousFailure</maml:name>
444+
<maml:Description>
445+
<maml:para>Defines if the maintenance process should not start when an error log exists.</maml:para>
446+
</maml:Description>
447+
<dev:type>
448+
<maml:name>SwitchParameter</maml:name>
449+
<maml:uri />
450+
</dev:type>
451+
<dev:defaultValue>False</dev:defaultValue>
452+
</command:parameter>
396453
</command:syntaxItem>
397454
</command:syntax>
398455
<command:parameters>
@@ -444,6 +501,18 @@
444501
</dev:type>
445502
<dev:defaultValue>None</dev:defaultValue>
446503
</command:parameter>
504+
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="False" position="named" aliases="none">
505+
<maml:name>FailOnPreviousFailure</maml:name>
506+
<maml:Description>
507+
<maml:para>Defines if the maintenance process should not start when an error log exists.</maml:para>
508+
</maml:Description>
509+
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
510+
<dev:type>
511+
<maml:name>SwitchParameter</maml:name>
512+
<maml:uri />
513+
</dev:type>
514+
<dev:defaultValue>False</dev:defaultValue>
515+
</command:parameter>
447516
</command:parameters>
448517
<command:inputTypes>
449518
<command:inputType>

0 commit comments

Comments
 (0)