是否可以使用批处理脚本快速识别计算机是domain
还是workgroup
的成员?如果它是domain
的成员,那么domain
的名称是什么?
答案 0 :(得分:0)
最后,我能够使用PowerShell找到它并在批处理变量中捕获它。
以下是代码
@echo off
REM Bellow logic is to identify "Computer membership"? True=Member of domain | False=Member of Workgroup
for /f %%a in ('powershell "(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain"') do set ComMem=%%a
echo %ComMem%
If %ComMem% Equ True (
GoTo Domainmember
) Else (
GoTo WorkgroupMember
)
REM Bellow logic is will find Domain / Workgroup Name
:Domainmember
for /f %%f in ('powershell "(Get-WmiObject Win32_ComputerSystem).Domain"') do set MemNme=%%f
Pause
GoTo End
:WorkgroupMember
for /f %%f in ('powershell "(Get-WmiObject Win32_ComputerSystem).Workgroup"') do set MemNme=%%f
:End
Echo %MemNme%
pause