Skip to content

Commit

Permalink
See change log for v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Sep 20, 2018
1 parent 408d6cb commit d4ccffb
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 37 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

The PowerShell commands in this module are intended to make it easier to automate the process of pausing and resuming Windows Updates on a Windows 10 desktop as well as a few other update related settings.

## Command Overview

[Get-WindowsActiveHours](./docs/Get-WindowsActiveHours.md)

[Get-WindowsUpdateDeferral](./docs/Get-WindowsUpdateDeferral.md)

[Get-WindowsUpdateSetting](./docs/Get-WindowsUpdateSetting.md)

[Resume-WindowsUpdate](./docs/Resume-WindowsUpdate.md)

[Set-WindowsActiveHours](./docs/Set-WindowsActiveHours.md)

[Set-WindowsUpdateDeferral](./docs/Set-WindowsUpdateDeferral.md)

[Suspend-WindowsUpdate](./docs/Suspend-WindowsUpdate.md)

[Test-IsWindowsUpdatePaused](./docs/Test-IsWindowsUpdatePaused.md)

## Suspend and Resume Windows Updates

Normally, you would use Settings to pause Windows Update for 35 days.

![settings](./assets/settings.png)
Expand All @@ -20,6 +40,8 @@ Remaining : 35.03:59:59.1529862

Or you can specify a date, as long as it is less than 35 days. Use `Get-WindowsUpdateSetting` to view the current values or `Test-IsWindowsUpdatePaused` to test.

## Configure Active Hours

This module also contains commands to set your active hours.

![activehours](./assets/activehours.png)
Expand All @@ -39,6 +61,8 @@ Computername ActiveHoursStart ActiveHoursEnd
BOVINE320 6 20
```

## Configure Update Deferral

The module also contains commands to manage deferrals of certain updates.

![deferrals](./assets/deferrals.png)
Expand Down
2 changes: 1 addition & 1 deletion WindowsUpdateSetting.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RootModule = 'WindowsUpdateSetting.psm1'

# Version number of this module.
ModuleVersion = '0.2.1'
ModuleVersion = '0.3.0'

# Supported PSEditions
CompatiblePSEditions = @("Desktop")
Expand Down
39 changes: 24 additions & 15 deletions WindowsUpdateSetting.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#region main code
Function Set-WindowsUpdateDeferral {
[cmdletbinding(SupportsShouldProcess)]
[OutputType("None", "WindowsUpdateDeferral")]

Param (
[Parameter(HelpMessage = "Enter the number of days (0-365) to defer feature updates")]
[ValidateRange(0, 365)]
Expand Down Expand Up @@ -32,9 +34,10 @@ Function Set-WindowsUpdateDeferral {

Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($myinvocation.mycommand)"
}

Function Get-WindowsUpdateDeferral {
[cmdletbinding()]
[OutputType("WindowsUpdateDeferral")]

Param ()

Write-Verbose "[$((Get-Date).TimeofDay)] Starting $($myinvocation.mycommand)"
Expand All @@ -43,16 +46,20 @@ Function Get-WindowsUpdateDeferral {
$feature = Get-ItemPropertyValue -Path $base1 -Name DeferFeatureUpdatesPeriodInDays
$Quality = Get-ItemPropertyValue -Path $base1 -Name DeferQualityUpdatesPeriodInDays

[PSCustomObject]@{
$obj = [PSCustomObject]@{
Computername = $env:COMPUTERNAME
FeatureUpdateDeferral = $Feature
QualityUpdateDeferral = $Quality
}

$obj.psobject.typenames.insert(0, 'WindowsUpdateDeferral')
$obj
Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($myinvocation.mycommand)"
}
Function Set-WindowsActiveHours {
[cmdletbinding(SupportsShouldProcess)]
[OutputType("None", "WindowsActiveHours")]

Param(
[Parameter(Mandatory, HelpMessage = "Enter a starting time like 7:00AM")]
[datetime]$StartTime,
Expand Down Expand Up @@ -88,10 +95,9 @@ Function Set-WindowsActiveHours {
Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($myinvocation.mycommand)"

} #close Set-WindowsActiveHours

Function Get-WindowsActiveHours {
[cmdletbinding()]
[OutputType([PSCustomObject])]
[OutputType('WindowsActiveHours')]

Param()

Expand All @@ -102,20 +108,22 @@ Function Get-WindowsActiveHours {
$start = Get-ItemPropertyValue -Path $base1 -Name ActiveHoursStart
$end = Get-ItemPropertyValue -Path $base1 -Name ActiveHoursEnd

[PSCustomObject]@{
$obj = [PSCustomObject]@{
Computername = $env:COMPUTERNAME
ActiveHoursStart = $start
ActiveHoursEnd = $end
}

$obj.psobject.typenames.insert(0, 'WindowsActiveHours')
$obj

Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($myinvocation.mycommand)"

} #close Get-WindowsActiveHours

Function Suspend-WindowsUpdate {

[CmdletBinding(SupportsShouldProcess)]
[OutputType("None")]
[OutputType("None", "WindowsUpdateSetting")]

Param(
[Parameter(HelpMessage = "Enter a datetime to resume updates. This must be less than 35 days.")]
Expand All @@ -140,7 +148,8 @@ Function Suspend-WindowsUpdate {
}
})]
[datetime]$Resume = (Get-Date).AddDays(35),
[switch]$Passthru)
[switch]$Passthru
)

Write-Verbose "[$((Get-Date).TimeofDay)] Starting $($MyInvocation.Mycommand)"

Expand All @@ -155,7 +164,7 @@ Function Suspend-WindowsUpdate {

Write-Verbose "[$((Get-Date).TimeofDay)] Pausing Windows Updates until $end"

if ($pscmdlet.ShouldProcess($env:computername)) {
if ($pscmdlet.ShouldProcess($env:computername, "Suspend Windows Update until $Resume")) {

$base1 = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\ux\Settings"
Set-ItemProperty -Path $base1 -Name PauseFeatureUpdatesStartTime -Value $start -Type String
Expand All @@ -178,11 +187,10 @@ Function Suspend-WindowsUpdate {
Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($MyInvocation.Mycommand)"

} #close function

Function Resume-WindowsUpdate {

[CmdletBinding(SupportsShouldProcess)]
[OutputType("None")]
[OutputType("None", "WindowsUpdateSetting")]

Param([switch]$Passthru)

Expand Down Expand Up @@ -233,7 +241,6 @@ Function Resume-WindowsUpdate {
Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($MyInvocation.Mycommand)"

} #close function

Function Test-IsWindowsUpdatePaused {

[cmdletbinding()]
Expand All @@ -254,11 +261,10 @@ Function Test-IsWindowsUpdatePaused {

Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($MyInvocation.Mycommand)"
}

Function Get-WindowsUpdateSetting {

[CmdletBinding()]
[OutputType([PSCustomObject])]
[OutputType('WindowsUpdateSetting')]

Param()

Expand All @@ -278,14 +284,17 @@ Function Get-WindowsUpdateSetting {
$resume = $null
$remain = $null
}
[pscustomobject]@{
$obj = [pscustomobject]@{
Computername = $env:computername
UpdatesPaused = $paused
PauseStartUTC = $start
PauseEndUTC = $resume
Remaining = $remain
}

$obj.psobject.typenames.insert(0, 'WindowsUpdateSetting')
$obj

Write-Verbose "[$((Get-Date).TimeofDay)] Ending $($MyInvocation.Mycommand)"
}

Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog for WindowsUpdateSetting

## v0.3.0

+ Updated ShouldProcess message on `Suspend-WindowsUpdate` (Issue #3)
+ Added custom type names to PSCustomobject output (Issue #2)
+ Updated README
+ Updated documentation

## v0.2.1

+ Github updates
Expand Down
5 changes: 2 additions & 3 deletions docs/Get-WindowsActiveHours.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ BOVINE320 7 20

### CommonParameters

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).
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).

## INPUTS

### None

## OUTPUTS

### System.Management.Automation.PSObject
### WindowsActiveHours

## NOTES

Expand Down
6 changes: 2 additions & 4 deletions docs/Get-WindowsUpdateDeferral.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Get-WindowsUpdateDeferral [<CommonParameters>]

Get the current settings for deferring Windows feature or quality updates.


## EXAMPLES

### Example 1
Expand All @@ -38,16 +37,15 @@ BOVINE320 30 7

### CommonParameters

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).
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).

## INPUTS

### None

## OUTPUTS

### System.Object
### WindowsUpdateDeferral

## NOTES

Expand Down
2 changes: 1 addition & 1 deletion docs/Get-WindowsUpdateSetting.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## OUTPUTS

### PSCustomObject
### WindowsUpdateSetting

## NOTES

Expand Down
2 changes: 1 addition & 1 deletion docs/Resume-WindowsUpdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### None
### PSCustomObject
### WindowsUpdateSetting
## NOTES
Expand Down
7 changes: 4 additions & 3 deletions docs/Set-WindowsActiveHours.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ Accept wildcard characters: False
### CommonParameters
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).
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).
## INPUTS
### None
## OUTPUTS
### System.Object
### None
### WindowsActiveHours
## NOTES
Expand Down
7 changes: 4 additions & 3 deletions docs/Set-WindowsUpdateDeferral.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,17 @@ Accept wildcard characters: False
### CommonParameters
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).
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).
## INPUTS
### None
## OUTPUTS
### System.Object
### None
### WindowsUpdateDeferral
## NOTES
Expand Down
2 changes: 2 additions & 0 deletions docs/Suspend-WindowsUpdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### None
### WindowsUpdateSetting
## NOTES
Learn more about PowerShell:
Expand Down
Loading

0 comments on commit d4ccffb

Please sign in to comment.