-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMisc-Functions.ps1
More file actions
30 lines (29 loc) · 1.03 KB
/
Misc-Functions.ps1
File metadata and controls
30 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# A list of misc functions that can be plugged in to other scripts as needed
function Get-ADJoinType {
<#
.SYNOPSIS
Checks local system for domain join type
.OUTPUTS
One of the following string values:
Hybrid
AzureADNative
AD
Workgroup
Unknown
#>
try {
$AzureADJoinedRaw = & dsregcmd /status | findstr AzureAdJoined
$DomainJoinedRaw = & dsregcmd /status | findstr DomainJoined
$AzureADJoined = ($AzureADJoinedRaw.Trim() -split ":")[1].Trim() -eq "YES"
$DomainJoined = ($DomainJoinedRaw.Trim() -split ":")[1].Trim() -eq "YES"
}
catch { Write-Error "Unable to parse dsregcmd output" -ErrorAction Stop }
if ($AzureADJoined -and $DomainJoined) { "Hybrid" }
elseif ($AzureADJoined -and !$DomainJoined) { "AzureADNative" }
elseif (!$AzureADJoined -and $DomainJoined) { "AD" }
elseif (!$AzureADJoined -and !$DomainJoined) { "Workgroup" }
else {
Write-Error "Unable to determine join type" -ErrorAction Continue
"Unknown"
}
}