【发布时间】:2018-09-27 20:25:30
【问题描述】:
我正在尝试执行以下操作:
使用 Powershell 向 SCCM 查询计算机名称,然后在其输出中获取用户名。
现在,我正在使用:
Get-CMDevice -name <computername>
这将返回整个记录。其中有一个名为“用户名”的项目。这就是我要提取的内容。
自从使用 powershell 已经很长时间了,更不用说 SCCM 插件了。
【问题讨论】:
标签: powershell sccm
我正在尝试执行以下操作:
使用 Powershell 向 SCCM 查询计算机名称,然后在其输出中获取用户名。
现在,我正在使用:
Get-CMDevice -name <computername>
这将返回整个记录。其中有一个名为“用户名”的项目。这就是我要提取的内容。
自从使用 powershell 已经很长时间了,更不用说 SCCM 插件了。
【问题讨论】:
标签: powershell sccm
要么使用成员引用运算符(.):
(Get-CMDevice -Name AComputerName).UserName
或使用Select-Object -ExpandProperty:
Get-CMDevice -Name AComputerName |Select-Object -ExpandProperty UserName
【讨论】:
下午,
您应该可以将命令放在括号中并直接选择属性,如下所示:
(Get-CMDevice -name <computername>).UserName
【讨论】: