Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Query for interactive RDP session

$
0
0
Hi,

I want to check with a Powershell script if there is anybody logged in (local or via rdp) on a set of XP virtual machines and if not open a rdp session to the next free XP vm. For testing purposes I do not open the rdp session but print out if a vm is taken or free.

However, looking for a local user is not a big deal but to find out if there isany interactive rdp session against the XP becomes an issue for me.

I search the internet but I found not really something that fits to my issue, maybe anybody from you guys have an idea how to handle this problem.

$CompList = d:\logs\xp-vm.txt

foreach($ComputerName in $CompList){
 
$tmplcuser = Gwmi Win32_Computersystem -comp $ComputerName
 
 If($tmplcuser.UserName -eq $null) {  
  Write-Host "$ComputerName is FREE" 
 } Else {
  Write-Host "$ComputerName is TAKEN" 
 }
 }

 

greeeTz, Andi

 


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>