This repository has been archived by the owner on Sep 21, 2021. It is now read-only.
forked from proxb/PoshWSUS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request proxb#47 from 1Dimitri/master
Copy Approval from one TargetGroup to another
- Loading branch information
Showing
3 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
} | ||
|
||
|
||
} | ||
} |