批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[转载代码] [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:
  1. function Get-LoggedOnUser
  2. {
  3.   param([String[]]$ComputerName = $env:COMPUTERNAME)
  4.     $ComputerName | ForEach-Object {
  5.       (quser /SERVER:$_) -replace '\s{2,}', ',' |
  6.         ConvertFrom-CSV |
  7.         Add-Member -MemberType NoteProperty -Name ComputerName -Value $_ -PassThru
  8.   }
  9. }
复制代码
http://powershell.com/cs/blogs/tips/archive/2014/01/15/finding-logged-on-user-on-remote-machine.aspx

返回列表