How to find if the local computer is in a domain?

前端 未结 3 1894
失恋的感觉
失恋的感觉 2021-02-07 00:48

Is there an easy and fast way to find out if the local computer is joined to a domain with PowerShell?

I find lots of stuff about getting the current wo

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-07 01:16

    This is simple. Works because if a computer is not in a domain, the default userdomain is the local computer

    if ($env:computername  -eq $env:userdomain) { echo " no AD domain" } 
    else { echo "must be in AD"}
    

提交回复
热议问题