Check if a computer is a member of a domain or workgroup via PowerShell

Check if a computer is member of a domain or workgroup via PowerShell

Basic bit of code to achieve this as below

if ((gwmi win32_computersystem).partofdomain -eq $true) {
write-host “Server is part of a Domain, continuing with script!” -ForegroundColor Green
} else {
write-host “Server is not part of a Domain, continuing with script!” -ForegroundColor Red
}

If you found this article helpful, would you consider buying me a Coffee?

Leave a Reply

Your email address will not be published. Required fields are marked *