【问题标题】:Get Username from computer name using powershell and sccm使用 powershell 和 sccm 从计算机名称中获取用户名
【发布时间】:2018-09-27 20:25:30
【问题描述】:

我正在尝试执行以下操作:

使用 Powershell 向 SCCM 查询计算机名称,然后在其输出中获取用户名。

现在,我正在使用:

Get-CMDevice -name <computername>

这将返回整个记录。其中有一个名为“用户名”的项目。这就是我要提取的内容。

自从使用 powershell 已经很长时间了,更不用说 SCCM 插件了。

【问题讨论】:

    标签: powershell sccm


    【解决方案1】:

    要么使用成员引用运算符(.):

    (Get-CMDevice -Name AComputerName).UserName
    

    或使用Select-Object -ExpandProperty:

    Get-CMDevice -Name AComputerName |Select-Object -ExpandProperty UserName
    

    【讨论】:

      【解决方案2】:

      下午,

      您应该可以将命令放在括号中并直接选择属性,如下所示:

      (Get-CMDevice -name <computername>).UserName
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-01-01
        • 2022-10-17
        • 1970-01-01
        • 2015-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多