Automate direct domain enrollment across Windows versions
This commit is contained in:
@@ -32,7 +32,16 @@ if (-not $before.IsValid) {
|
||||
}
|
||||
|
||||
$computer = Get-CimInstance Win32_ComputerSystem
|
||||
$domainReady = $false
|
||||
if ($computer.PartOfDomain) {
|
||||
try {
|
||||
$domainReady = [bool](Test-ComputerSecureChannel -ErrorAction Stop)
|
||||
}
|
||||
catch {
|
||||
$domainReady = $false
|
||||
}
|
||||
}
|
||||
if ($domainReady) {
|
||||
& $remoteAccessScript `
|
||||
-RemoteDesktopPrincipal ([string]$configuration.RemoteDesktopPrincipal) `
|
||||
-EnableAdministrativeFirewallGroups | Out-Null
|
||||
@@ -45,7 +54,7 @@ if ($configuration.RustDeskServerAddress -and $configuration.RustDeskServerPubli
|
||||
}
|
||||
|
||||
$verificationParams = @{}
|
||||
if ($computer.PartOfDomain) {
|
||||
if ($domainReady) {
|
||||
$verificationParams.RequireDomainJoined = $true
|
||||
$verificationParams.RequireRemoteAccess = $true
|
||||
$verificationParams.RemoteDesktopPrincipal = [string]$configuration.RemoteDesktopPrincipal
|
||||
|
||||
Reference in New Issue
Block a user