Good stuff....actually I was looking for the Citrix session ID, not the
"real" session ID, which is where I was going wrong in my head :-)

I realized I could just strip it from the end of the %sessionname% variable
after the # - loads simpler!

I will steal your snippet for when I actually need the "real" ID in future
:-)

On 24 April 2013 11:17, Webster <webs...@carlwebster.com> wrote:

>  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:kz2...@googlemail.com]
> *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****
>
> ~ 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 listmana...@lyris.sunbeltsoftware.com
> 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 listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>



-- 
*James Rankin*
Technical Consultant (ACA, CCA, MCTS)
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 listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to