Skip to content

Commit 0a53790

Browse files
committed
2 parents a11b744 + e54626d commit 0a53790

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
@@ -160,6 +160,7 @@ xVirtualMemory has the following properties:
160160
## Versions
161161

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

164165
* Updated AppVeyor.yml to use AppVeyor.psm1 module in DSCResource.Tests.
165166
* Removed Markdown.md errors.

0 commit comments

Comments
 (0)