标题: [转载代码] [PowerShell每日技巧]查看远程机器上登录的用户(20140115) [打印本页]
作者: DAIC 时间: 2014-1-20 13:26 标题: [PowerShell每日技巧]查看远程机器上登录的用户(20140115)
In a previous tip we used quser.exe to find the currently logged-on user on the local machine. Here is now a function that also allows us to find the currently logged-on user on a remote machine. As an extra benefit, the returned information is appended by a property called "ComputerName", so when you query multiple machines, you will know where the results came from:- function Get-LoggedOnUser
- {
- param([String[]]$ComputerName = $env:COMPUTERNAME)
-
- $ComputerName | ForEach-Object {
- (quser /SERVER:$_) -replace '\s{2,}', ',' |
- ConvertFrom-CSV |
- Add-Member -MemberType NoteProperty -Name ComputerName -Value $_ -PassThru
- }
- }
复制代码
http://powershell.com/cs/blogs/tips/archive/2014/01/15/finding-logged-on-user-on-remote-machine.aspx
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |