|
Re: Variable issues within pipeline using wmi "Adam Murray" <muzzar78@msn.com> wrote in message
news:Ot4O9CGCHHA.204@TK2MSFTNGP04.phx.gbl...
> I have been messing around with trying to create a single line command to
> list logged on users to a machine. I think this should be quiet easy but I
> am struggling with the way powershell is handling my variable expansion
> within the pipeline.
>
> I expect this command to work, however it doesn't seem to expand the
> variable correctly.
>
> gwmi -query "Select logonid from Win32_LogonSession where logontype = 2 or
> logontype = 10" -computername aupoza510 | foreach {gwmi -computername
> aupoza510 -query 'Associators of {Win32_LogonSession.LogonId=$_.logonid}
> Where AssocClass=Win32_LoggedOnUser Role=Dependent'}
Using single quotes tells PowerShell to not perform variable substituion.
So on that last query (where you use $_.logonid) you probably want to use
double qoutes.
--
Keith |