简体   繁体   中英

How to get all remote computer's usernames via Powershell?

是否可以通过Powershell获取远程计算机上所有本地用户帐户的列表?

You can get this with a WMI-query.

function Get-LocalUser ($Computername = $env:COMPUTERNAME) {
    Get-WmiObject -Query "Select * from Win32_UserAccount Where LocalAccount = 'True'" -ComputerName $ComputerName |
    Select-Object -ExpandProperty Name 
}

Get-LocalUser -ComputerName "TestPC1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM