Skip to content

Commit e54626d

Browse files
authored
Merge pull request #76 from BristleBeard/dev
DomainName check validates child without FQDN
2 parents 09d3709 + cac9e3d commit e54626d

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

DSCResources/MSFT_xComputer/MSFT_xComputer.psm1

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,23 @@ function Test-TargetResource
234234
{
235235
throw "Need to specify credentials with domain"
236236
}
237-
237+
238238
try
239239
{
240240
Write-Verbose "Checking if the machine is a member of $DomainName."
241-
return ($DomainName.ToLower() -eq (GetComputerDomain).ToLower())
241+
if ($DomainName.Contains('.'))
242+
{
243+
$getComputerDomainSplat = @{
244+
netbios = $false
245+
}
246+
}
247+
else
248+
{
249+
$getComputerDomainSplat = @{
250+
netbios = $true
251+
}
252+
}
253+
return ($DomainName -eq (GetComputerDomain @getComputerDomainSplat ))
242254
}
243255
catch
244256
{
@@ -268,9 +280,25 @@ function ValidateDomainOrWorkGroup($DomainName, $WorkGroupName)
268280

269281
function GetComputerDomain
270282
{
271-
try
283+
[CmdletBinding()]
284+
param
285+
(
286+
[Parameter()]
287+
[Switch]
288+
$NetBios
289+
)
290+
291+
try
272292
{
273-
return ([System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()).Name
293+
if ($NetBios)
294+
{
295+
$domainName = $ENV:USERDOMAIN
296+
}
297+
else
298+
{
299+
$domainName = ([System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()).Name
300+
}
301+
return $domainName
274302
}
275303
catch [System.Management.Automation.MethodInvocationException]
276304
{

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ xVirtualMemory has the following properties:
119119
## Versions
120120

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

123124
### 2.0.0.0
124125
* Updated resources

0 commit comments

Comments
 (0)