Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateServicesComputerTargetGroup: New resource - managing computer target groups #78

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added UpdateServicesComputerTargetGroup Resource to manage computer target groups

### Changed

- Updated initial offline package sync WSUS.cab.
Expand All @@ -20,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated to load localization strings correctly.
- UpdateServicesServer
- Updated to load localization strings correctly.
- Updated ImitateUpdateServicesModule Module to meet style guidelines
- Internal PDT helper module
- Updated to load localization strings correctly.
- General code cleanup
Expand All @@ -44,6 +49,8 @@ multiple products for the same `Title`.
- Fix issue [#63](https://github.com/dsccommunity/UpdateServicesDsc/issues/63),
Fixed verbose output of WSUS server in UpdateServicesApprovalRule
- Fixed the `azure-pipelines.yml` to trigger on main not master.
- Update build process to pin GitVersion to 5.* to resolve errors
(https://github.com/gaelcolas/Sampler/issues/477).

## [1.2.0] - 2020-05-18

Expand Down
6 changes: 6 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2.
* **CleanupLocalPublishedContentFiles**: Cleanup local published content files.
* **TimeOfDay** Time of day to start cleanup.

**UpdateServicesComputerTargetGroup** resource has following properties:

* **Ensure**: An enumerated value that describes if the Computer Target Group exists.
* **Name**: Name of the Computer Target Group.
* **Path**: Path to the Computer Target Group in the format 'Parent/Child'.

**UpdateServicesServer** resource has following properties:

* **Ensure**: An enumerated value that describes if WSUS is configured.
Expand Down
125 changes: 123 additions & 2 deletions Tests/Helpers/ImitateUpdateServicesModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function Get-WsusServerTemplate
{
$WsusServer = [pscustomobject] @{
Name = 'ServerName'
}
}

$ApprovalRule = [scriptblock]{
$ApprovalRule = [pscustomobject]@{
Expand Down Expand Up @@ -52,13 +52,134 @@ function Get-WsusServerTemplate
return $ApprovalRule
}

$ComputerTargetGroups = [scriptblock]{
$ComputerTargetGroups = @(
[pscustomobject] @{
Name = 'All Computers'
Id = [pscustomobject] @{
GUID = '4be27a8d-b969-4a8a-9cae-ec6b3a282b0b'
}
},
[pscustomobject] @{
Name = 'Servers'
Id = [pscustomobject] @{
GUID = '14adceba-ddf3-4299-9c1a-e4cf8bd56c47'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'All Computers'
Id = [pscustomobject] @{
GUID = '4be27a8d-b969-4a8a-9cae-ec6b3a282b0b'
}
}
ChildTargetGroup = [pscustomobject] @{
Name = 'Web'
Id = [pscustomobject] @{
GUID = 'f4aa59c7-e6a0-4e6d-97b0-293d00a0dc60'
}
}
},
[pscustomobject] @{
Name = 'Web'
Id = [pscustomobject] @{
GUID = 'f4aa59c7-e6a0-4e6d-97b0-293d00a0dc60'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'Servers'
Id = [pscustomobject] @{
GUID = '14adceba-ddf3-4299-9c1a-e4cf8bd56c47'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'All Computers'
Id = [pscustomobject] @{
GUID = '4be27a8d-b969-4a8a-9cae-ec6b3a282b0b'
}
}
}
},
[pscustomobject] @{
Name = 'Workstations'
Id = [pscustomobject] @{
GUID = '31742fd8-df6f-4836-82b4-b2e52ee4ba1b'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'All Computers'
Id = [pscustomobject] @{
GUID = '4be27a8d-b969-4a8a-9cae-ec6b3a282b0b'
}
}
},
[pscustomobject] @{
Name = 'Desktops'
Id = [pscustomobject] @{
GUID = '2b77a9ce-f320-41c7-bec7-9b22f67ae5b1'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'Workstations'
Id = [pscustomobject] @{
GUID = '31742fd8-df6f-4836-82b4-b2e52ee4ba1b'
}
ParentTargetGroup = [pscustomobject] @{
Name = 'All Computers'
Id = [pscustomobject] @{
GUID = '4be27a8d-b969-4a8a-9cae-ec6b3a282b0b'
}
}
}
}
)

foreach ($ComputerTargetGroup in $ComputerTargetGroups)
{
Add-Member -InputObject $ComputerTargetGroup -MemberType ScriptMethod -Name Delete -Value {}

Add-Member -InputObject $ComputerTargetGroup -MemberType ScriptMethod -Name GetParentTargetGroup -Value {
return $this.ParentTargetGroup
}

if ($null -ne $ComputerTargetGroup.ParentTargetGroup)
{
Add-Member -InputObject $ComputerTargetGroup.ParentTargetGroup -MemberType ScriptMethod -Name GetParentTargetGroup -Value {
return $this.ParentTargetGroup
}
}

if ($null -ne $ComputerTargetGroup.ChildTargetGroup)
{
Add-Member -InputObject $ComputerTargetGroup -MemberType ScriptMethod -Name GetChildTargetGroups -Value {
return $this.ChildTargetGroup
}

Add-Member -InputObject $ComputerTargetGroup.ChildTargetGroup -MemberType ScriptMethod -Name Delete -Value {}
}
}

return $ComputerTargetGroups
}

$WsusServer | Add-Member -MemberType ScriptMethod -Name CreateComputerTargetGroup -Value {
param
(
[Parameter(Mandatory = $true)]
[string]
$Name,

[Parameter(Mandatory = $true)]
[object]
$ComputerTargetGroup
)
{
Write-Output $Name
Write-Output $ComputerTargetGroup
}
}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetInstallApprovalRules -Value $ApprovalRule

$WsusServer | Add-Member -MemberType ScriptMethod -Name CreateInstallApprovalRule -Value $ApprovalRule

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassification -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {}
$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value $ComputerTargetGroups

$WsusServer | Add-Member -MemberType ScriptMethod -Name DeleteInstallApprovalRule -Value {}

Expand Down
Loading
Loading