您可以使用 PowerShell 查找您的用户登录的位置。不过,您将需要 Active Directory cmdlet:
# Import the Active Directory module for the Get-ADComputer CmdLet
Import-Module ActiveDirectory
# Query Active Directory for computers running a Server operating system
$Servers = Get-ADComputer -Filter {OperatingSystem -like "*server*"}
# Loop through the list to query each server for login sessions
ForEach ($Server in $Servers) {
$ServerName = $Server.Name
# When running interactively, uncomment the Write-Host line below to show which server is being queried
# Write-Host "Querying $ServerName"
# Run the qwinsta.exe and parse the output
$queryResults = (qwinsta /server:$ServerName | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)
# Pull the session information from each instance
ForEach ($queryResult in $queryResults) {
$RDPUser = $queryResult.USERNAME
$sessionType = $queryResult.SESSIONNAME
# We only want to display where a "person" is logged in. Otherwise unused sessions show up as USERNAME as a number
If (($RDPUser -match "[a-z]") -and ($RDPUser -ne $NULL)) {
# When running interactively, uncomment the Write-Host line below to show the output to screen
# Write-Host $ServerName logged in by $RDPUser on $sessionType
$SessionList = $SessionList + "`n`n" + $ServerName + " logged in by " + $RDPUser + " on " + $sessionType
}
}
}
# When running interactively, uncomment the Write-Host line below to see the full list on screen
$SessionList
您可以使用 PowerShell 查找您的用户登录的位置。不过,您将需要 Active Directory cmdlet:
您只需要根据您的情况进行调整。(即计算机和服务器,而不仅仅是服务器)
不,这不是它的工作方式;没有什么比
IsLoggedOnTo
附加到 AD 中的用户对象的 ~ 属性更好的了。记录的用户列表是每台计算机的属性/属性,因此您必须单独查询每台计算机。我 [可能] 使用 PowerShell 和 TS Manager/Remote Desktop Services MMC 管理单元来解决这个问题......如果只是记住或养成注销的习惯,而不是更容易的话关闭我的 RDP 窗口。
所以 - 获取域中所有服务器的列表(和/或任何可能有问题的机器。)将其放入名为 servers.txt 的文件中。跑 :
-- txt 文件示例 --