Skip to content

Commit 0f202e5

Browse files
Vasily LarionovVasily Larionov
authored andcommitted
Merged last changes
2 parents 152f20e + e54626d commit 0f202e5

2 files changed

Lines changed: 35 additions & 5 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ xVirtualMemory has the following properties:
119119
## Versions
120120

121121
### Unreleased
122-
- xScheduledTask
122+
* xScheduledTask
123123
- Fixed incorrect TaskPath handling [Fix #45](https://github.com/PowerShell/xComputerManagement/issues/45)
124124

125+
* xComputer: Changed comparision that validates if we are in the correct AD Domain to work correctly if FQDN wasn't used
126+
125127
### 2.0.0.0
126128
* Updated resources
127129
- BREAKING CHANGE: xScheduledTask: Added nearly all available parameters for tasks

0 commit comments

Comments
 (0)