From 3f9175317c2b2b6b8a396c8d6751d2eee4e3c4d1 Mon Sep 17 00:00:00 2001 From: iRaven4522 Date: Tue, 14 Oct 2025 01:47:49 -0500 Subject: [PATCH] JoinDomain check --- MDT-JoinDomain.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MDT-JoinDomain.ps1 b/MDT-JoinDomain.ps1 index d6bee57..62e773a 100644 --- a/MDT-JoinDomain.ps1 +++ b/MDT-JoinDomain.ps1 @@ -10,6 +10,13 @@ Start-Transcript -Path "$MDTPath\_Logs\$CompName-JoinDomain.log" -Append $CompType = $args[0] $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") { New-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\LSA" -Name NetJoinLegacyAccountReuse -Value 1 $PCNamePrefix = ($CompName.Substring(0,$CompName.IndexOf("-")))