Sep 6 2011 11:29AM GMT
Posted by: Richard Siddaway
Active Directory, PowerShell v2, WMI
Test for domain membership
Posted by: Richard Siddaway
Quick function to determine if a given machine is in a domain or workgroup
function test-domain{ [CmdletBinding()] param ( [parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$computer="." ) BEGIN{}#begin PROCESS{ Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | select Name, Domain }#process END{}#end }
Feed the function a computer name or IP address and it will return the name and domain. If the computer is in the domain we get the full domain name – if its in a workgroup we get the workgroup name (WORKGROUP by default)




