FYI, from what MBS did for my Word based scripts:

#find out our session (usually "1" except on TS/RDC or Citrix)
$SessionID = (Get-Process -PID $PID).SessionId

#Find out if winword is running in our session
[bool]$wordrunning = ((Get-Process 'WinWord' -ea 0)|?{$_.SessionId -eq 
$SessionID}) -ne $null
if ($wordrunning)
{
                Write-Host "Please close all instances of Microsoft Word before 
running this report."
                exit
}


Thanks


Webster

From: James Rankin [mailto:[email protected]]
Sent: Wednesday, April 24, 2013 4:29 AM
To: NT System Admin Issues
Subject: As we're becoming a PowerShell-focused list :-)

Any idea how I would go about extracting the SessionId from PowerShell? By 
SessionId I mean the one that you see in tasklist and query session? I've tried 
messing about with Get-XaSession which is a Citrix PS cmdlet but the output is 
so long from this, I can't help but think I must be missing an easier way to 
output what I'm looking for which is probably sitting right under my nose.

TIA,



--
James Rankin
Technical Consultant (ACA, CCA, MCTS)
http://appsensebigot.blogspot.co.uk<http://appsensebigot.blogspot.co.uk/>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to