如何找出我所在域的短名称? [英] How do find out short name of domain I'm in?

查看:46
本文介绍了如何找出我所在域的短名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想返回我正在运行的计算机的域的短名称.我不想要 $env:USERDOMAIN 因为这是用户登录的域,它可能与机器所在的域不同.如果我这样做

I want to return the short name of the domain the computer I am running on. I do not want the $env:USERDOMAIN because that is the domain the user is logged on to, which could be different to the domain the machine is in. If I do

(gwmi win32_computersystem).域

这让我获得了 FQDN,但我想要类似的东西来返回短名称(NETBIOS 名称?).我目前正在解析 FQDN,但我知道这会导致以后出现错误.

This gets me the FQDN, but I want something similar to return the short name (NETBIOS name?). I am currently parsing the FQDN, but I know this will lead to bugs later.

我没有安装 Active Directory 模块,公司政策禁止我安装它,所以我不能简单地使用该模块中的 (Get-ADDomain).NetBIOSName.>

I don't have the Active Directory module installed, and company policy prevents me from installing it, so I can't simply use (Get-ADDomain).NetBIOSName from that module.

推荐答案

好的,最后一次尝试.

(net config workstation) -match 'Workstation domain\s+\S+$' -replace '.+?(\S+)$','$1'

这篇关于如何找出我所在域的短名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆