-
Notifications
You must be signed in to change notification settings - Fork 0
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
Review PR #1
Open
corydwood
wants to merge
15
commits into
reviewBase
Choose a base branch
from
reviewTarget
base: reviewBase
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Review PR #1
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
095e685
Created xGroupPolicy Module.
corydwood c5d934e
Update README.md
corydwood a857081
Update MSFT_xGPOLink.psm1
corydwood 88c9c1e
Update README.md
corydwood ffa153a
Create LICENSE.md
corydwood 95613df
Start of review
corydwood bbb377d
Merge branch 'master' into reviewTarget
corydwood e0f6b25
Removed x from in front of resources.
corydwood 00a7873
Removed x from in front of resources.
corydwood d02430a
Merge branch 'master' into reviewTarget
corydwood cbf186b
Made requested changes.
corydwood 21b5edd
Made changes requested by TravisEz13.
corydwood 70c9d74
Updated Helper.psm1 to reflect changes to parameter names.
corydwood 7d744de
Added $Name parameter to Helper.psm1
corydwood 9366213
Updated tests with new parameter names.
corydwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DSCResource.Tests |
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,64 @@ | ||
<# | ||
.SYNOPSIS | ||
Tests the $Target parameter to ensure it contains the RootDSE and adds it if it doesn't. | ||
|
||
.PARAMETER Target | ||
The target OU Distinguished Name with or without the RootDSE. | ||
|
||
.PARAMETER Domain | ||
Not used. Included to allow @PSBoundParameters in function call. | ||
|
||
.PARAMETER Server | ||
The name of the server. Optional. | ||
|
||
.PARAMETER Ensure | ||
Not used. Included to allow @PSBoundParameters in function call. | ||
|
||
#> | ||
function Test-TargetDN | ||
{ | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$Target, | ||
|
||
[string] | ||
$Domain, | ||
|
||
[string] | ||
$Server, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure = 'Present' | ||
) | ||
|
||
$getADDomainParams = @{} | ||
if ($Server) | ||
{ | ||
$getADDomainParams += @{ | ||
Server = $Server | ||
} | ||
} | ||
Write-Verbose -Message ("Checking the Domain Distinguished Name is " + | ||
"present on the Target Distinguished Name.") | ||
$domainDN = (Get-ADDomain @getADDomainParams).DistinguishedName | ||
if ($Target -like "*$domainDN") | ||
{ | ||
Write-Verbose -Message "Target has full DN." | ||
} | ||
else | ||
{ | ||
Write-Verbose -Message "Adding the Domain Distinguished Name to the Target DN." | ||
if ($Target.EndsWith(",")) | ||
{ | ||
$Target = "$Target$domainDN" | ||
} | ||
else | ||
{ | ||
$Target = "$Target,$domainDN" | ||
} | ||
} | ||
Write-Output -InputObject $Target | ||
} |
156 changes: 156 additions & 0 deletions
156
DSCResources/MSFT_GPInheritance/MSFT_GPInheritance.psm1
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,156 @@ | ||
function Get-TargetResource | ||
{ | ||
[OutputType([Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$Target, | ||
|
||
[string] | ||
$Domain, | ||
|
||
[string] | ||
$Server, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure = 'Present' | ||
) | ||
|
||
Import-Module $PSScriptRoot\..\Helper.psm1 -Verbose:$false | ||
Import-Module -Name GroupPolicy -Verbose:$false | ||
$Target = Test-TargetDN @PSBoundParameters | ||
$targetResource = @{ | ||
Target = $Target | ||
Domain = $null | ||
Server = $null | ||
Ensure = $null | ||
} | ||
$getGPInheritanceParams = @{ | ||
Target = $Target | ||
} | ||
if ($Domain) | ||
{ | ||
$targetResource.Domain = $Domain | ||
$getGPInheritanceParams += @{ | ||
Domain = $Domain | ||
} | ||
} | ||
if ($Server) | ||
{ | ||
$targetResource.Server = $Server | ||
$getGPInheritanceParams += @{ | ||
Server = $Server | ||
} | ||
} | ||
Write-Verbose -Message 'Getting Group Policy Inheritance' | ||
$gpoInheritanceBlocked = (Get-GPInheritance @getGPInheritanceParams).GpoInheritanceBlocked | ||
if (!$gpoInheritanceBlocked) | ||
{ | ||
$targetResource.Ensure = 'Present' | ||
} | ||
else | ||
{ | ||
$targetResource.Ensure = 'Absent' | ||
} | ||
Write-Output -InputObject $targetResource | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$Target, | ||
|
||
[string] | ||
$Domain, | ||
|
||
[string] | ||
$Server, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure = 'Present' | ||
) | ||
|
||
if ($Ensure -eq 'Present') | ||
{ | ||
Write-Verbose -Message 'Enabling Group Policy Inheritance' | ||
$isBlocked = 'No' | ||
} | ||
else | ||
{ | ||
Write-Verbose -Message 'Disabling Group Policy Inheritance' | ||
$isBlocked = 'Yes' | ||
} | ||
$Target = Test-TargetDN @PSBoundParameters | ||
$setGPInheritanceParams = @{ | ||
Target = $Target | ||
IsBlocked = $IsBlocked | ||
} | ||
if ($Domain) | ||
{ | ||
$setGPInheritanceParams += @{ | ||
Domain = $Domain | ||
} | ||
} | ||
if ($Server) | ||
{ | ||
$setGPInheritanceParams += @{ | ||
Server = $Server | ||
} | ||
} | ||
Import-Module -Name GroupPolicy -Verbose:$false | ||
$null = Set-GPInheritance @setGPInheritanceParams | ||
} | ||
|
||
function Test-TargetResource | ||
{ | ||
[OutputType([Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[string] | ||
$Target, | ||
|
||
[string] | ||
$Domain, | ||
|
||
[string] | ||
$Server, | ||
|
||
[ValidateSet('Present','Absent')] | ||
[string] | ||
$Ensure = 'Present' | ||
) | ||
|
||
$targetResource = Get-TargetResource @PSBoundParameters | ||
switch ($Ensure) | ||
{ | ||
Present | ||
{ | ||
if ($targetResource.Ensure -eq 'Present') | ||
{ | ||
Write-Output -InputObject $true | ||
} | ||
else | ||
{ | ||
Write-Output -InputObject $false | ||
} | ||
} | ||
Absent | ||
{ | ||
if ($targetResource.Ensure -eq 'Absent') | ||
{ | ||
Write-Output -InputObject $true | ||
} | ||
else | ||
{ | ||
Write-Output -InputObject $false | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
DSCResources/MSFT_GPInheritance/MSFT_GPInheritance.schema.mof
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,8 @@ | ||
[ClassVersion("1.0.0"), FriendlyName("GPInheritance")] | ||
class MSFT_GPInheritance : OMI_BaseResource | ||
{ | ||
[Key] String Target; | ||
[write] String Domain; | ||
[write] String Server; | ||
[write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add descriptions