Skip to content

Commit

Permalink
Remove semicolon from rows
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Jun 15, 2019
1 parent 5cd649a commit 37f3b2e
Show file tree
Hide file tree
Showing 12 changed files with 505 additions and 505 deletions.
100 changes: 50 additions & 50 deletions DSCResources/MSFT_xADDomain/MSFT_xADDomain.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function Get-TargetResource
)

Assert-Module -ModuleName 'ADDSDeployment' -ImportModule
$domainFQDN = Resolve-DomainFQDN -DomainName $DomainName -ParentDomainName $ParentDomainName;
$isDomainMember = Test-DomainMember;
$domainFQDN = Resolve-DomainFQDN -DomainName $DomainName -ParentDomainName $ParentDomainName
$isDomainMember = Test-DomainMember

$retries = 0
$maxRetries = 5
Expand All @@ -99,46 +99,46 @@ function Get-TargetResource
if ($isDomainMember)
{
## We're already a domain member, so take the credentials out of the equation
Write-Verbose ($script:localizedData.QueryDomainWithLocalCredential -f $domainFQDN);
$domain = Get-ADDomain -Identity $domainFQDN -ErrorAction Stop;
Write-Verbose ($script:localizedData.QueryDomainWithLocalCredential -f $domainFQDN)
$domain = Get-ADDomain -Identity $domainFQDN -ErrorAction Stop
$forest = Get-ADForest -Identity $domain.Forest -ErrorAction Stop
}
else {
Write-Verbose ($script:localizedData.QueryDomainWithCredential -f $domainFQDN);
Write-Verbose ($script:localizedData.QueryDomainWithCredential -f $domainFQDN)
$domain = Get-ADDomain -Identity $domainFQDN -Credential $DomainAdministratorCredential -ErrorAction Stop
$forest = Get-ADForest -Identity $domain.Forest -Credential $DomainAdministratorCredential -ErrorAction Stop
}

## No need to check whether the node is actually a domain controller. If we don't throw an exception,
## the domain is already UP - and this resource shouldn't run. Domain controller functionality
## should be checked by the xADDomainController resource?
Write-Verbose ($script:localizedData.DomainFound -f $domain.DnsRoot);
Write-Verbose ($script:localizedData.DomainFound -f $domain.DnsRoot)

$targetResource = @{
DomainName = $domain.DnsRoot;
ParentDomainName = $domain.ParentDomain;
DomainNetBIOSName = $domain.NetBIOSName;
DomainName = $domain.DnsRoot
ParentDomainName = $domain.ParentDomain
DomainNetBIOSName = $domain.NetBIOSName
ForestMode = (ConvertTo-DeploymentForestMode -Mode $forest.ForestMode) -as [String]
DomainMode = (ConvertTo-DeploymentDomainMode -Mode $domain.DomainMode) -as [String]
}

return $targetResource;
return $targetResource
}
catch [Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException]
{
$errorMessage = $script:localizedData.ExistingDomainMemberError -f $DomainName;
ThrowInvalidOperationError -ErrorId 'xADDomain_DomainMember' -ErrorMessage $errorMessage;
$errorMessage = $script:localizedData.ExistingDomainMemberError -f $DomainName
ThrowInvalidOperationError -ErrorId 'xADDomain_DomainMember' -ErrorMessage $errorMessage
}
catch [Microsoft.ActiveDirectory.Management.ADServerDownException]
{
Write-Verbose ($script:localizedData.DomainNotFound -f $domainFQDN)
$domain = @{ };
$domain = @{ }
# will fall into retry mechanism
}
catch [System.Security.Authentication.AuthenticationException]
{
$errorMessage = $script:localizedData.InvalidCredentialError -f $DomainName;
ThrowInvalidOperationError -ErrorId 'xADDomain_InvalidCredential' -ErrorMessage $errorMessage;
$errorMessage = $script:localizedData.InvalidCredentialError -f $DomainName
ThrowInvalidOperationError -ErrorId 'xADDomain_InvalidCredential' -ErrorMessage $errorMessage
}
catch
{
Expand Down Expand Up @@ -206,42 +206,42 @@ function Test-TargetResource
)

$targetResource = Get-TargetResource @PSBoundParameters
$isCompliant = $true;
$isCompliant = $true

## The Get-Target resource returns .DomainName as the domain's FQDN. Therefore, we
## need to resolve this before comparison.
$domainFQDN = Resolve-DomainFQDN -DomainName $DomainName -ParentDomainName $ParentDomainName
if ($domainFQDN -ne $targetResource.DomainName)
{
$message = $script:localizedData.ResourcePropertyValueIncorrect -f 'DomainName', $domainFQDN, $targetResource.DomainName;
Write-Verbose -Message $message;
$isCompliant = $false;
$message = $script:localizedData.ResourcePropertyValueIncorrect -f 'DomainName', $domainFQDN, $targetResource.DomainName
Write-Verbose -Message $message
$isCompliant = $false
}

$propertyNames = @('ParentDomainName','DomainNetBIOSName');
$propertyNames = @('ParentDomainName','DomainNetBIOSName')
foreach ($propertyName in $propertyNames)
{
if ($PSBoundParameters.ContainsKey($propertyName))
{
$propertyValue = (Get-Variable -Name $propertyName).Value;
$propertyValue = (Get-Variable -Name $propertyName).Value
if ($targetResource.$propertyName -ne $propertyValue)
{
$message = $script:localizedData.ResourcePropertyValueIncorrect -f $propertyName, $propertyValue, $targetResource.$propertyName;
Write-Verbose -Message $message;
$isCompliant = $false;
$message = $script:localizedData.ResourcePropertyValueIncorrect -f $propertyName, $propertyValue, $targetResource.$propertyName
Write-Verbose -Message $message
$isCompliant = $false
}
}
}

if ($isCompliant)
{
Write-Verbose -Message ($script:localizedData.ResourceInDesiredState -f $domainFQDN);
return $true;
Write-Verbose -Message ($script:localizedData.ResourceInDesiredState -f $domainFQDN)
return $true
}
else
{
Write-Verbose -Message ($script:localizedData.ResourceNotInDesiredState -f $domainFQDN);
return $false;
Write-Verbose -Message ($script:localizedData.ResourceNotInDesiredState -f $domainFQDN)
return $false
}

} #end function Test-TargetResource
Expand Down Expand Up @@ -297,66 +297,66 @@ function Set-TargetResource
)

# Debug can pause Install-ADDSForest/Install-ADDSDomain, so we remove it.
[ref] $null = $PSBoundParameters.Remove('Debug');
[ref] $null = $PSBoundParameters.Remove('Debug')
## Not entirely necessary, but run Get-TargetResouece to ensure we raise any pre-flight errors.
$targetResource = Get-TargetResource @PSBoundParameters;
$targetResource = Get-TargetResource @PSBoundParameters

$installADDSParams = @{
SafeModeAdministratorPassword = $SafemodeAdministratorPassword.Password;
NoRebootOnCompletion = $true;
Force = $true;
SafeModeAdministratorPassword = $SafemodeAdministratorPassword.Password
NoRebootOnCompletion = $true
Force = $true
}

if ($PSBoundParameters.ContainsKey('DnsDelegationCredential'))
{
$installADDSParams['DnsDelegationCredential'] = $DnsDelegationCredential;
$installADDSParams['CreateDnsDelegation'] = $true;
$installADDSParams['DnsDelegationCredential'] = $DnsDelegationCredential
$installADDSParams['CreateDnsDelegation'] = $true
}
if ($PSBoundParameters.ContainsKey('DatabasePath'))
{
$installADDSParams['DatabasePath'] = $DatabasePath;
$installADDSParams['DatabasePath'] = $DatabasePath
}
if ($PSBoundParameters.ContainsKey('LogPath'))
{
$installADDSParams['LogPath'] = $LogPath;
$installADDSParams['LogPath'] = $LogPath
}
if ($PSBoundParameters.ContainsKey('SysvolPath'))
{
$installADDSParams['SysvolPath'] = $SysvolPath;
$installADDSParams['SysvolPath'] = $SysvolPath
}
if ($PSBoundParameters.ContainsKey('DomainMode'))
{
$installADDSParams['DomainMode'] = $DomainMode;
$installADDSParams['DomainMode'] = $DomainMode
}

if ($PSBoundParameters.ContainsKey('ParentDomainName'))
{
Write-Verbose -Message ($script:localizedData.CreatingChildDomain -f $DomainName, $ParentDomainName);
Write-Verbose -Message ($script:localizedData.CreatingChildDomain -f $DomainName, $ParentDomainName)
$installADDSParams['Credential'] = $DomainAdministratorCredential
$installADDSParams['NewDomainName'] = $DomainName
$installADDSParams['ParentDomainName'] = $ParentDomainName
$installADDSParams['DomainType'] = 'ChildDomain';
$installADDSParams['DomainType'] = 'ChildDomain'
if ($PSBoundParameters.ContainsKey('DomainNetBIOSName'))
{
$installADDSParams['NewDomainNetbiosName'] = $DomainNetBIOSName;
$installADDSParams['NewDomainNetbiosName'] = $DomainNetBIOSName
}
Install-ADDSDomain @installADDSParams;
Write-Verbose -Message ($script:localizedData.CreatedChildDomain);
Install-ADDSDomain @installADDSParams
Write-Verbose -Message ($script:localizedData.CreatedChildDomain)
}
else
{
Write-Verbose -Message ($script:localizedData.CreatingForest -f $DomainName);
$installADDSParams['DomainName'] = $DomainName;
Write-Verbose -Message ($script:localizedData.CreatingForest -f $DomainName)
$installADDSParams['DomainName'] = $DomainName
if ($PSBoundParameters.ContainsKey('DomainNetbiosName'))
{
$installADDSParams['DomainNetbiosName'] = $DomainNetBIOSName;
$installADDSParams['DomainNetbiosName'] = $DomainNetBIOSName
}
if ($PSBoundParameters.ContainsKey('ForestMode'))
{
$installADDSParams['ForestMode'] = $ForestMode
}
Install-ADDSForest @installADDSParams;
Write-Verbose -Message ($script:localizedData.CreatedForest -f $DomainName);
Install-ADDSForest @installADDSParams
Write-Verbose -Message ($script:localizedData.CreatedForest -f $DomainName)
}

'Finished' | Out-File -FilePath (Get-TrackingFilename -DomainName $DomainName) -Force
Expand All @@ -367,4 +367,4 @@ function Set-TargetResource

} #end function Set-TargetResource

Export-ModuleMember -Function *-TargetResource;
Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@ function Get-TargetResource
[System.Management.Automation.CredentialAttribute()]
$Credential
)
Assert-Module -ModuleName 'ActiveDirectory';
Assert-Module -ModuleName 'ActiveDirectory'

$PSBoundParameters['Identity'] = $DomainName;
$getADDefaultDomainPasswordPolicyParams = Get-ADCommonParameters @PSBoundParameters;
Write-Verbose -Message ($script:localizedData.QueryingDomainPasswordPolicy -f $DomainName);
$policy = Get-ADDefaultDomainPasswordPolicy @getADDefaultDomainPasswordPolicyParams;
$PSBoundParameters['Identity'] = $DomainName
$getADDefaultDomainPasswordPolicyParams = Get-ADCommonParameters @PSBoundParameters
Write-Verbose -Message ($script:localizedData.QueryingDomainPasswordPolicy -f $DomainName)
$policy = Get-ADDefaultDomainPasswordPolicy @getADDefaultDomainPasswordPolicyParams
$targetResource = @{
DomainName = $DomainName;
ComplexityEnabled = $policy.ComplexityEnabled;
LockoutDuration = ConvertFrom-Timespan -Timespan $policy.LockoutDuration -TimeSpanType Minutes;
LockoutObservationWindow = ConvertFrom-Timespan -Timespan $policy.LockoutObservationWindow -TimeSpanType Minutes;
LockoutThreshold = $policy.LockoutThreshold;
MinPasswordAge = ConvertFrom-Timespan -Timespan $policy.MinPasswordAge -TimeSpanType Minutes;
MaxPasswordAge = ConvertFrom-Timespan -Timespan $policy.MaxPasswordAge -TimeSpanType Minutes;
MinPasswordLength = $policy.MinPasswordLength;
PasswordHistoryCount = $policy.PasswordHistoryCount;
ReversibleEncryptionEnabled = $policy.ReversibleEncryptionEnabled;
DomainName = $DomainName
ComplexityEnabled = $policy.ComplexityEnabled
LockoutDuration = ConvertFrom-Timespan -Timespan $policy.LockoutDuration -TimeSpanType Minutes
LockoutObservationWindow = ConvertFrom-Timespan -Timespan $policy.LockoutObservationWindow -TimeSpanType Minutes
LockoutThreshold = $policy.LockoutThreshold
MinPasswordAge = ConvertFrom-Timespan -Timespan $policy.MinPasswordAge -TimeSpanType Minutes
MaxPasswordAge = ConvertFrom-Timespan -Timespan $policy.MaxPasswordAge -TimeSpanType Minutes
MinPasswordLength = $policy.MinPasswordLength
PasswordHistoryCount = $policy.PasswordHistoryCount
ReversibleEncryptionEnabled = $policy.ReversibleEncryptionEnabled
}
return $targetResource;
return $targetResource
} #end Get-TargetResource

function Test-TargetResource
Expand Down Expand Up @@ -104,44 +104,44 @@ function Test-TargetResource
$Credential
)
$getTargetResourceParams = @{
DomainName = $DomainName;
DomainName = $DomainName
}
if ($PSBoundParameters.ContainsKey('Credential'))
{
$getTargetResourceParams['Credential'] = $Credential;
$getTargetResourceParams['Credential'] = $Credential
}
if ($PSBoundParameters.ContainsKey('DomainController'))
{
$getTargetResourceParams['DomainController'] = $DomainController;
$getTargetResourceParams['DomainController'] = $DomainController
}
$targetResource = Get-TargetResource @getTargetResourceParams;
$targetResource = Get-TargetResource @getTargetResourceParams

$inDesiredState = $true;
$inDesiredState = $true
foreach ($property in $mutablePropertyMap)
{
$propertyName = $property.Name;
$propertyName = $property.Name
if ($PSBoundParameters.ContainsKey($propertyName))
{
$expectedValue = $PSBoundParameters[$propertyName];
$actualValue = $targetResource[$propertyName];
$expectedValue = $PSBoundParameters[$propertyName]
$actualValue = $targetResource[$propertyName]
if ($expectedValue -ne $actualValue)
{
$valueIncorrectMessage = $script:localizedData.ResourcePropertyValueIncorrect -f $propertyName, $expectedValue, $actualValue;
Write-Verbose -Message $valueIncorrectMessage;
$inDesiredState = $false;
$valueIncorrectMessage = $script:localizedData.ResourcePropertyValueIncorrect -f $propertyName, $expectedValue, $actualValue
Write-Verbose -Message $valueIncorrectMessage
$inDesiredState = $false
}
}
}

if ($inDesiredState)
{
Write-Verbose -Message ($script:localizedData.ResourceInDesiredState -f $DomainName);
return $true;
Write-Verbose -Message ($script:localizedData.ResourceInDesiredState -f $DomainName)
return $true
}
else
{
Write-Verbose -Message ($script:localizedData.ResourceNotInDesiredState -f $DomainName);
return $false;
Write-Verbose -Message ($script:localizedData.ResourceNotInDesiredState -f $DomainName)
return $false
}
} #end Test-TargetResource

Expand Down Expand Up @@ -189,27 +189,27 @@ function Set-TargetResource
[System.Management.Automation.CredentialAttribute()]
$Credential
)
Assert-Module -ModuleName 'ActiveDirectory';
$PSBoundParameters['Identity'] = $DomainName;
$setADDefaultDomainPasswordPolicyParams = Get-ADCommonParameters @PSBoundParameters;
Assert-Module -ModuleName 'ActiveDirectory'
$PSBoundParameters['Identity'] = $DomainName
$setADDefaultDomainPasswordPolicyParams = Get-ADCommonParameters @PSBoundParameters

foreach ($property in $mutablePropertyMap)
{
$propertyName = $property.Name;
$propertyName = $property.Name
if ($PSBoundParameters.ContainsKey($propertyName))
{
$propertyValue = $PSBoundParameters[$propertyName];
$propertyValue = $PSBoundParameters[$propertyName]
if ($property.IsTimeSpan -eq $true)
{
$propertyValue = ConvertTo-TimeSpan -TimeSpan $propertyValue -TimeSpanType Minutes;
$propertyValue = ConvertTo-TimeSpan -TimeSpan $propertyValue -TimeSpanType Minutes
}
$setADDefaultDomainPasswordPolicyParams[$propertyName] = $propertyValue;
Write-Verbose -Message ($script:localizedData.SettingPasswordPolicyValue -f $propertyName, $propertyValue);
$setADDefaultDomainPasswordPolicyParams[$propertyName] = $propertyValue
Write-Verbose -Message ($script:localizedData.SettingPasswordPolicyValue -f $propertyName, $propertyValue)
}
}

Write-Verbose -Message ($script:localizedData.UpdatingDomainPasswordPolicy -f $DomainName);
[ref] $null = Set-ADDefaultDomainPasswordPolicy @setADDefaultDomainPasswordPolicyParams;
Write-Verbose -Message ($script:localizedData.UpdatingDomainPasswordPolicy -f $DomainName)
[ref] $null = Set-ADDefaultDomainPasswordPolicy @setADDefaultDomainPasswordPolicyParams
} #end Set-TargetResource

Export-ModuleMember -Function *-TargetResource;
Export-ModuleMember -Function *-TargetResource
4 changes: 2 additions & 2 deletions DSCResources/MSFT_xADGroup/MSFT_xADGroup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,15 @@ function Set-TargetResource
if ($MembershipAttribute -eq 'DistinguishedName')
{
$AllMembers = $Members + $MembersToInclude + $MembersToExclude
$GroupMemberDomains = @();
$GroupMemberDomains = @()
foreach($member in $AllMembers)
{
$GroupMemberDomains += Get-ADDomainNameFromDistinguishedName -DistinguishedName $member
}
$GroupMemberDomainCount = ($GroupMemberDomains | Select-Object -Unique).count
if( $GroupMemberDomainCount -gt 1 -or ($GroupMemberDomains -ine (Get-DomainName)).Count -gt 0 )
{
Write-Verbose -Message ($script:localizedData.GroupMembershipMultipleDomains -f $GroupMemberDomainCount);
Write-Verbose -Message ($script:localizedData.GroupMembershipMultipleDomains -f $GroupMemberDomainCount)
$MembersInMultipleDomains = $true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Get-TargetResource
[System.String] $Path
)

Assert-Module -ModuleName 'ActiveDirectory';
Assert-Module -ModuleName 'ActiveDirectory'
Write-Verbose ($script:localizedData.RetrievingOU -f $Name)
$ou = Get-ADOrganizationalUnit -Filter { Name -eq $Name } -SearchBase $Path -SearchScope OneLevel -Properties ProtectedFromAccidentalDeletion, Description

Expand Down Expand Up @@ -162,7 +162,7 @@ function Set-TargetResource
$RestoreFromRecycleBin
)

Assert-Module -ModuleName 'ActiveDirectory';
Assert-Module -ModuleName 'ActiveDirectory'
$targetResource = Get-TargetResource -Name $Name -Path $Path

if ($targetResource.Ensure -eq 'Present')
Expand Down
Loading

0 comments on commit 37f3b2e

Please sign in to comment.