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

0
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
}

Found priceless insights in this blog? Support the author’s creativity – buy them a coffee!

Leave a Reply

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