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
Copy file name to clipboardExpand all lines: Public/Invoke-InfrastructureMaintenance.ps1
+63-33Lines changed: 63 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ function Invoke-InfrastructureMaintenance {
34
34
Write-Debug-Message 'if ($LogErrorFileContent)'
35
35
if ($LogErrorFileContent) {
36
36
$Message= ('Error log file {0} is not empty. To ignore this, set the module configuration variable $ModuleWideFailOnPreviousFailure to $false.'-f$LogErrorFilePath)
Copy file name to clipboardExpand all lines: README.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,15 @@ The main function you need from this module is [**Invoke-InfrastructureMaintenan
15
15
16
16
Under the hood, **Invoke-InfrastructureMaintenance** uses another function to actually perform maintenance on each host — [**Invoke-ComputerMaintenance**](docs/Invoke-ComputerMaintenance.md). If you want to use an external orchestration/configuration management system (Ansible, Puppet etc.), configure it to execute **Invoke-ComputerMaintenance**, not **Invoke-InfrastructureMaintenance**.
17
17
18
+
## Update detection and installation
19
+
**Invoke-ComputerMaintenance** uses the standard Windows Update API to detect and install updates. That means that to make updates available for a host, you have to make them available at WSUS or use direct connection to Microsoft Update. But you can exclude some updates from installation/detection:
20
+
* Use the `UpdateInstallFilter` configuration attribute (or the `$ModuleWideInstallUpdateDefaultFilterString` module configuration variable) to specify filter for updates installation.
21
+
* Use the `UpdateCheckFilter` configuration attribute (or the `$ModuleWideCheckUpdateDefaultFilterString` module configuration variable) to specify filter for updates detection.
22
+
23
+
If the detection process (**Test-WindowsUpdateNeeded**) finds available updates, the host maintenance process will start. Otherwise, **Invoke-ComputerMaintenance** skips to the next host.
24
+
25
+
There's no built-in way to install a specific update, but it is possible by leveraging step commands (see below), since you can execute custom commands and scripts there.
26
+
18
27
## Host types
19
28
While the module can potentially support machines with various type of workloads, currently there are only two supported types:
20
29
***HV-SCVMM** - for stand-alone hypervisors (yes, *not* fail-over clusters) managed by SCVMM. Workload movement is provided by the [SCVMReliableMigration](https://github.com/FozzyHosting/SCVMReliableMigration) module.
@@ -85,8 +94,8 @@ There are several variables defined in the .psm1-file, which are used by the mod
85
94
*`[System.TimeSpan]$ModuleWideInstallUpdateThreshold` - Specifies how long the module will wait for the update installation to finish.
86
95
*`[string]$ModuleWideInstallUpdateTaskName` - The name of a Task Scheduler task which executes code to find and install updates.
87
96
*`[string]$ModuleWideInstallUpdateTaskDescription` - The description of a Task Scheduler task which executes code to find and install updates.
88
-
*`[string]$ModuleWideCheckUpdateDefaultFilterString` - A filter which is used to detect new updates.
89
-
*`[string]$ModuleWideInstallUpdateDefaultFilterString` - A filter which is used during updates installation.
97
+
*`[string]$ModuleWideCheckUpdateDefaultFilterString` - A filter which is used to detect new updates. Used if an `UpdateCheckFilter` attribute is not defined in host's configuration.
98
+
*`[string]$ModuleWideInstallUpdateDefaultFilterString` - A filter which is used during updates installation. Used if an `UpdateInstallFilter` attribute is not defined in host's configuration.
90
99
*`[string]$ModuleWideUpdateSearchCriteria` - Criteria for the IUpdateSearcher::Search method (https://docs.microsoft.com/en-us/windows/desktop/api/wuapi/nf-wuapi-iupdatesearcher-search)
Copy file name to clipboardExpand all lines: docs-additional/Configuration.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,8 +24,9 @@ The `Include` attribute defines a collection of objects. Each of those objects m
24
24
25
25
## Attributes
26
26
* Name - The name of a host where you want to install updates automatically. Should be unique.
27
-
* Type - A type of a host. Currently, acceptable values are "HV-SCVMM", "Generic".
27
+
* Type - A type of a host. Currently, acceptable values are `HV-SCVMM`, `Generic`.
28
28
* UpdateInstallFilter - A filter which is used to filter out unneeded updates, like preview versions etc.
29
+
* Disabled - Settings this attribute to `True` allows you to temporary disable processing of this particular host. Useful when you need to perform some manual maintenance.
29
30
30
31
The following set of attributes describes step commands (plug-ins):
31
32
* PreClearCommands
@@ -35,7 +36,7 @@ The following set of attributes describes step commands (plug-ins):
35
36
* TestCommands
36
37
* FinallyCommands
37
38
38
-
Each attribute is usually a name of a PowerShell script, located in a "ScriptBlocks" folder in the module's folder. See more about these commands [here](Step-Commands.md)
39
+
Each attribute is usually a name of a PowerShell script, located in a `ScriptBlocks` folder in the module's folder. See more about these commands [here](Step-Commands.md)
Copy file name to clipboardExpand all lines: docs-additional/Step-Commands.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,18 @@
1
-
# Plug-ins (Step Commands)
2
-
There are several steps defined (in the order of execute):
1
+
# Step Commands (Plug-ins)
2
+
Step commands are scripts which can be run at steps executed throughout the maintenance process, as defined below. Usually you would like to create a PowerShell script, put it into the `ScriptBlocks` folder, then insert the name of the script into an appropriate attribute in the main configuration file or in the templates file (or in both, if your config requires so - it's completely up to you).
3
+
4
+
Step commands are good in letting other systems know that a host is about to reboot or it has returned back into service, but you of course can find them useful in other ways as well.
5
+
6
+
There are several steps defined (in the order of execution):
3
7
* Pre-Clear (PreClearCommands) - this step executes before workload is removed from the host. It's a good step to execute a command which will prevent further workload placing on the host.
4
8
* Post-Clear (PostClearCommands) - this step executes right after workload is removed from the host. At this step you can disable monitoring, for example.
5
9
* Test (TestCommands) - this step executes after the host is back after reboot. Its purpose is to run commands which ensure that it is safe to move workload back to the host.
6
10
* Pre-Restore (PreRestoreCommands) - executes before moving workload back to the host. We recommend to enable monitoring here,if you disabled it at "Post-Clear".
7
11
* Post-Restore (PostRestoreCommands) - executes when workload moving back has completed. If you prevented workload placement earlier, you can enable it now.
8
-
* Finally (FinallyCommands) - this step always executes at the end of the process. If an error happens, it will execute after error processing.
12
+
* Finally (FinallyCommands) - this step always executes at the end of the process. If an error happens, it will execute after error processing (The whole function is in a `try` block and `FinallyCommands` run at its `finally` section).
9
13
10
14
## Requirements
11
-
Executable files (usually PowerShell scripts), specified in those attributes must accept two following parameters:
15
+
Executable files (usually, PowerShell scripts), specified in those attributes must be in the `ScriptBlocks` folder and must accept two following parameters:
12
16
* ComputerName - A string, containing a name of a computer which is in progress right now. Mandatory.
13
17
* Variables - A collection of `System.Management.Automation.PSVariable` objects. Might be empty, but unlikely.
0 commit comments