JoinDomain check

This commit is contained in:
2025-10-14 01:47:49 -05:00
parent a8af307fea
commit 3f9175317c

View File

@@ -10,6 +10,13 @@ Start-Transcript -Path "$MDTPath\_Logs\$CompName-JoinDomain.log" -Append
$CompType = $args[0] $CompType = $args[0]
$SubType = $args[1] $SubType = $args[1]
# Check if we're already in the domain
if ((gwmi win32_computersystem).partofdomain -eq $true) {
write-host -ForegroundColor Green "Already in the domain! Exiting."
Stop-Transcript
exit 0
}
if ($CompType -like "WKS") { if ($CompType -like "WKS") {
New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\LSA" -Name NetJoinLegacyAccountReuse -Value 1 New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\LSA" -Name NetJoinLegacyAccountReuse -Value 1
$PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-"))) $PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))