Getting Data In

This script shows all servers with any RDC sessions open. i need it to just show me a specific username that is logged into any of the listed servers. Could someone help me?

chadkfranks
Engager
$servers = get-content “C:\scripts\servers.txt”

foreach ($server in $servers)

{

$server

$command = “quser /server:” + $server

invoke-expression $command

}
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

You'll probably get a better response at a Powershell-specific forum like powershell.com or Microsoft Technet.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

halr9000
Motivator

Agreed with Rich, since this is very specific to PowerShell, not Splunk. But I'll give you a hint real quick. You need to look at two areas: filtering, and working with objects generally. You can use a variety of methods to filter input. One is the Where-Object cmdlet. But when working with PowerShell, it's best to convert text strings into objects, as it's much easier to work with them that way. This script that I found real quick (I googled for "powershell query rdc") shows a technique to use the qwinsta.exe command, but then converting the output to CSV, and then using the ConvertFrom-CSV to turn it into objects.

HTH

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You'll probably get a better response at a Powershell-specific forum like powershell.com or Microsoft Technet.

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...