|
Re: Variable issues within pipeline using wmi "Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message
news:%23517AtHCHHA.4464@TK2MSFTNGP06.phx.gbl...
> "Adam Murray" <muzzar78@msn.com> wrote in message
> news:Ot4O9CGCHHA.204@TK2MSFTNGP04.phx.gbl...
>> 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.
Oh yeah, to not only expand variables but then to reference a property on
that variable you need to do this:
$($_.logonid)
That tells PowerShell to evaluate the entire expression in $(...) instead of
evaluating $_ and then appending the string ".logonid" to it.
--
Keith |