The Win32_ComputerSystem
class represents a computer system operating in a Win32 environment. You can find more information here.
Win32_ComputerSystem
has a PartOfDomain
property that indicates whether the computer is part of domain or not. There is also a workgroup property – that should be blank if the computer is on a domain.
The Get-wmiObject cmdlet
has its own alias as gwmi
.
if ((gwmi win32_computersystem).partofdomain -eq $true) { write-host -fore green "The server/computer in Domain!" } else { write-host -fore red "The server/computer is not in domain." }