Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request proxb#47 from 1Dimitri/master
Browse files Browse the repository at this point in the history
Copy Approval from one TargetGroup to another
  • Loading branch information
proxb authored Apr 13, 2018
2 parents b2394c9 + 85eaba5 commit cfbf97d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PoshWSUS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ModuleToProcess = 'PoshWSUS.psm1'

# Version number of this module.
ModuleVersion = '2.3.1.6'
ModuleVersion = '2.3.2'

# ID used to uniquely identify this module
GUID = '4a327d07-b494-40ad-b154-a6116b1b1eb2'
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PoshWSUS 2.3.1.5 Release Notes
Last Updated: 9 Sept 2016
PoshWSUS 2.3.2 Release Notes
Last Updated: 12 Apr 2018

!!!IMPORTANT!!!
Functions have been renamed from *-PoshWSUS* to *-PSWSUS* based on user feedback.
Expand Down Expand Up @@ -42,6 +42,7 @@ Functions have been renamed from *-PoshWSUS* to *-PSWSUS* based on user feedback
- Set-PSWSUSTargetingMode
- Set-PSWSUSUpdateFiles
- Set-PSWSUSUpdateSource
- Copy-PSWSUSUpdateApproval

-------------------
|Removed Functions|
Expand Down
62 changes: 62 additions & 0 deletions Scripts/Copy-PSWSUSUpdateApproval.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function Copy-PSWSUSUpdateApproval {
<#
.SYNOPSIS
Copies approvals
.DESCRIPTION
Copy appprovals from the SourceComputerTargetGroup to the DestinationComputerTargetGroup
.PARAMETER SourceComputerTargetGroup
ComputerTargetGroup whose approvals will be retrieved
.PARAMETER TargetComputerTargetGroup
ComputerTargetGroup whose approvals will be set
.NOTES
Name: Copy-PSWSUSUpdateApproval
Author: Dimitri Janczak
DateCreated: 09Apr2018
.LINK
https://learn-powershell.net
https://dimitri.janczak.net
.EXAMPLE
Copy-PSWSUSApproval -SourceComputerTargetGroup 'Acceptance' -TargetComputerGroup 'Production'
#>
[cmdletbinding(
ConfirmImpact = 'low',
DefaultParameterSetName = '__Default'
)]
Param(
[Parameter(Position = 0, ValueFromPipeline=$True,Mandatory=$true)]
[string]$SourceComputerTargetGroup,
[Parameter(Position = 1, Mandatory=$true)]
[string]$DestinationComputerTargetGroup
)

$approvalsSource = Get-PSWSUSUpdateApproval -ComputerTargetGroups $SourceComputerTargetGroup


$targetGroupId = Get-PSWSUSGroup -Name $DestinationComputerTargetGroup

$approvalsSource | ForEach-Object {
$action = $_.Action
$kb = $_.UpdateKB
$updateID = $_.UpdateId
$deadline = $_.DeadLine
if ($deadline.ticks -eq 3155378975999999999) {
$wsus.GetUpdate($updateID) | Approve-PSWSUSUpdate -Action $action -Group $targetGroupId
Write-Verbose "$($kb): $Action (no deadline) $SourceComputerTargetGroup => $DestinationComputerTargetGroup"
} else {
$wsus.GetUpdate($updateID) | Approve-PSWSUSUpdate -Action $action -DeadLine $DeadLine -Group $targetGroupId
Write-Verbose "$($kb): $Action (deadline: $($deadline)) $SourceComputerTargetGroup => $DestinationComputerTargetGroup"

}


}
}

0 comments on commit cfbf97d

Please sign in to comment.