Skip to content

Commit

Permalink
Merge pull request #76 from BristleBeard/dev
Browse files Browse the repository at this point in the history
DomainName check validates child without FQDN
  • Loading branch information
PlagueHO authored Jul 16, 2017
2 parents 09d3709 + cac9e3d commit e54626d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
36 changes: 32 additions & 4 deletions DSCResources/MSFT_xComputer/MSFT_xComputer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,23 @@ function Test-TargetResource
{
throw "Need to specify credentials with domain"
}

try
{
Write-Verbose "Checking if the machine is a member of $DomainName."
return ($DomainName.ToLower() -eq (GetComputerDomain).ToLower())
if ($DomainName.Contains('.'))
{
$getComputerDomainSplat = @{
netbios = $false
}
}
else
{
$getComputerDomainSplat = @{
netbios = $true
}
}
return ($DomainName -eq (GetComputerDomain @getComputerDomainSplat ))
}
catch
{
Expand Down Expand Up @@ -268,9 +280,25 @@ function ValidateDomainOrWorkGroup($DomainName, $WorkGroupName)

function GetComputerDomain
{
try
[CmdletBinding()]
param
(
[Parameter()]
[Switch]
$NetBios
)

try
{
return ([System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()).Name
if ($NetBios)
{
$domainName = $ENV:USERDOMAIN
}
else
{
$domainName = ([System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()).Name
}
return $domainName
}
catch [System.Management.Automation.MethodInvocationException]
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ xVirtualMemory has the following properties:
## Versions

### Unreleased
* xComputer: Changed comparision that validates if we are in the correct AD Domain to work correctly if FQDN wasn't used

### 2.0.0.0
* Updated resources
Expand Down

0 comments on commit e54626d

Please sign in to comment.