![]() |
|
|
#1 |
|
Guest
Posts: n/a
|
Subexpression
Hello,
I tried to query informations within a single command. To achieve this I tried with subexpression, but it does not work. I wanted to get all recipients within a Exchange addresslist. Unfortunatly this does not work: Get-Recipient -Filter {AddressListMembership -eq $((Get-addresslist TestAddresslist).DistinguishedName)} Anybody who knows a solution? If possible I want a single command not a script! Thanks a lot.. Alex |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Subexpression
Try: Get-Recipient -filter "AddressListMembership -eq '$((Get-AddressList TestAddresslist).DistinguishedName)'" --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com A> Hello, A> A> I tried to query informations within a single command. To achieve A> this I A> tried with subexpression, but it does not work. A> I wanted to get all recipients within a Exchange addresslist. A> Unfortunatly this does not work: A> Get-Recipient -Filter {AddressListMembership -eq $((Get-addresslist A> TestAddresslist).DistinguishedName)} A> Anybody who knows a solution? If possible I want a single command not A> a script! A> A> Thanks a lot.. A> A> Alex A> |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Subexpression
Thanks a lot, this works!!!!
Would you be so kind to explain, why the quotes are necessary and what they do? I know that $() is a subexpression, but why must this be quoted? Alex "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag news:89228ed2325378caa4f77123755a@news.microsoft.c om... > > Try: > > Get-Recipient -filter "AddressListMembership -eq '$((Get-AddressList > TestAddresslist).DistinguishedName)'" > > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > A> Hello, > A> A> I tried to query informations within a single command. To achieve > A> this I > A> tried with subexpression, but it does not work. > A> I wanted to get all recipients within a Exchange addresslist. > A> Unfortunatly this does not work: > A> Get-Recipient -Filter {AddressListMembership -eq $((Get-addresslist > A> TestAddresslist).DistinguishedName)} > A> Anybody who knows a solution? If possible I want a single command not > A> a script! > A> A> Thanks a lot.. > A> A> Alex > A> > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Subexpression
Hi Alex,
Say you want to get a service using get-wmiobject and the filter parameter, such expression should look like: PS > gwmi win32_service -filter "name=alerter" That query won't work, you'll get an error ('Invalid query'). That's were the quotes comes into play. The service name comparison is against a string and strings should be enclosed with quotes: PS > gwmi win32_service -filter "name='alerter'" Same thing when you generate the service name using a command, this gives an error: PS > gwmi win32_service -filter "name=$(get-service alerter).name)" Get-WmiObject : Invalid query At line:1 char:5 + gwmi <<<< win32_service -filter "name=$(get-service alerter).name)" This is not: PS > gwmi win32_service -filter "name='$((get-service alerter).name)'" ExitCode : 1077 Name : Alerter ProcessId : 0 StartMode : Disabled State : Stopped Status : OK I hope it's clear enough now ![]() --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com A> Thanks a lot, this works!!!! A> A> Would you be so kind to explain, why the quotes are necessary and A> what they do? A> A> I know that $() is a subexpression, but why must this be quoted? A> A> Alex A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag A> news:89228ed2325378caa4f77123755a@news.microsoft.c om... A> >> Try: >> >> Get-Recipient -filter "AddressListMembership -eq '$((Get-AddressList >> TestAddresslist).DistinguishedName)'" >> >> --- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com >> A> Hello, >> A> A> I tried to query informations within a single command. To >> achieve >> A> this I >> A> tried with subexpression, but it does not work. >> A> I wanted to get all recipients within a Exchange addresslist. >> A> Unfortunatly this does not work: >> A> Get-Recipient -Filter {AddressListMembership -eq >> $((Get-addresslist >> A> TestAddresslist).DistinguishedName)} >> A> Anybody who knows a solution? If possible I want a single command >> not >> A> a script! >> A> A> Thanks a lot.. >> A> A> Alex >> A> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Subexpression
Yes, Thanks, it's almost clear now.
One last question: What is the difference between the single and double quotes (' and ") When to choose which one? Thanks a lot! Alex "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag news:95d808933255a8caa51bde845310@news.microsoft.c om... > Hi Alex, > > > Say you want to get a service using get-wmiobject and the filter > parameter, such expression should look like: > > PS > gwmi win32_service -filter "name=alerter" > > That query won't work, you'll get an error ('Invalid query'). That's were > the quotes comes into play. > The service name comparison is against a string and strings should be > enclosed with quotes: > > PS > gwmi win32_service -filter "name='alerter'" > > > > Same thing when you generate the service name using a command, this gives > an error: > > > > PS > gwmi win32_service -filter "name=$(get-service alerter).name)" > Get-WmiObject : Invalid query > At line:1 char:5 > + gwmi <<<< win32_service -filter "name=$(get-service alerter).name)" > > > > This is not: > > PS > gwmi win32_service -filter "name='$((get-service alerter).name)'" > > ExitCode : 1077 > Name : Alerter > ProcessId : 0 > StartMode : Disabled > State : Stopped > Status : OK > > > > I hope it's clear enough now ![]() > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > A> Thanks a lot, this works!!!! > A> A> Would you be so kind to explain, why the quotes are necessary and > A> what they do? > A> A> I know that $() is a subexpression, but why must this be quoted? > A> A> Alex > A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag > A> news:89228ed2325378caa4f77123755a@news.microsoft.c om... > A> >>> Try: >>> >>> Get-Recipient -filter "AddressListMembership -eq '$((Get-AddressList >>> TestAddresslist).DistinguishedName)'" >>> >>> --- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>> A> Hello, >>> A> A> I tried to query informations within a single command. To >>> achieve >>> A> this I >>> A> tried with subexpression, but it does not work. >>> A> I wanted to get all recipients within a Exchange addresslist. >>> A> Unfortunatly this does not work: >>> A> Get-Recipient -Filter {AddressListMembership -eq >>> $((Get-addresslist >>> A> TestAddresslist).DistinguishedName)} >>> A> Anybody who knows a solution? If possible I want a single command >>> not >>> A> a script! >>> A> A> Thanks a lot.. >>> A> A> Alex >>> A> > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Re: Subexpression
There's a special help file just for that ![]() help about_Quoting_rules --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com A> Yes, Thanks, it's almost clear now. A> A> One last question: What is the difference between the single and A> double quotes (' and ") A> A> When to choose which one? A> A> Thanks a lot! A> A> Alex A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag A> news:95d808933255a8caa51bde845310@news.microsoft.c om... A> >> Hi Alex, >> >> Say you want to get a service using get-wmiobject and the filter >> parameter, such expression should look like: >> >> PS > gwmi win32_service -filter "name=alerter" >> >> That query won't work, you'll get an error ('Invalid query'). That's >> were >> the quotes comes into play. >> The service name comparison is against a string and strings should be >> enclosed with quotes: >> PS > gwmi win32_service -filter "name='alerter'" >> >> Same thing when you generate the service name using a command, this >> gives an error: >> >> PS > gwmi win32_service -filter "name=$(get-service alerter).name)" >> Get-WmiObject : Invalid query >> At line:1 char:5 >> + gwmi <<<< win32_service -filter "name=$(get-service >> alerter).name)" >> This is not: >> >> PS > gwmi win32_service -filter "name='$((get-service >> alerter).name)'" >> >> ExitCode : 1077 >> Name : Alerter >> ProcessId : 0 >> StartMode : Disabled >> State : Stopped >> Status : OK >> I hope it's clear enough now ![]() >> >> --- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com >> A> Thanks a lot, this works!!!! >> A> A> Would you be so kind to explain, why the quotes are necessary >> and >> A> what they do? >> A> A> I know that $() is a subexpression, but why must this be >> quoted? >> A> A> Alex >> A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag >> A> news:89228ed2325378caa4f77123755a@news.microsoft.c om... >> A> >>>> Try: >>>> >>>> Get-Recipient -filter "AddressListMembership -eq >>>> '$((Get-AddressList TestAddresslist).DistinguishedName)'" >>>> >>>> --- >>>> Shay Levi >>>> $cript Fanatic >>>> http://scriptolog.blogspot.com >>>> A> Hello, >>>> A> A> I tried to query informations within a single command. To >>>> achieve >>>> A> this I >>>> A> tried with subexpression, but it does not work. >>>> A> I wanted to get all recipients within a Exchange addresslist. >>>> A> Unfortunatly this does not work: >>>> A> Get-Recipient -Filter {AddressListMembership -eq >>>> $((Get-addresslist >>>> A> TestAddresslist).DistinguishedName)} >>>> A> Anybody who knows a solution? If possible I want a single >>>> command >>>> not >>>> A> a script! >>>> A> A> Thanks a lot.. >>>> A> A> Alex >>>> A> |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Re: Subexpression
Alex wrote:
> Yes, Thanks, it's almost clear now. > > One last question: What is the difference between the single and double > quotes (' and ") > > When to choose which one? Briefly, if you're trying out the v2 CTP, this will directly apply: http://www.microsoft.com/technet/scr...h/quoting.mspx Even if you're not using the v2 CTP, they discuss the difference. Marco -- Microsoft MVP - Windows PowerShell http://www.microsoft.com/mvp PowerGadgets MVP http://www.powergadgets.com/mvp Blog: http://marcoshaw.blogspot.com |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Re: Subexpression
Thanks a lot !!!!
"Shay Levi" <no@addre.ss> schrieb im Newsbeitrag news:95d80893326668caa51eafeb95b0@news.microsoft.c om... > > > There's a special help file just for that ![]() > > help about_Quoting_rules > > > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > > A> Yes, Thanks, it's almost clear now. > A> A> One last question: What is the difference between the single and > A> double quotes (' and ") > A> A> When to choose which one? > A> A> Thanks a lot! > A> A> Alex > A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag > A> news:95d808933255a8caa51bde845310@news.microsoft.c om... > A> >>> Hi Alex, >>> >>> Say you want to get a service using get-wmiobject and the filter >>> parameter, such expression should look like: >>> >>> PS > gwmi win32_service -filter "name=alerter" >>> >>> That query won't work, you'll get an error ('Invalid query'). That's >>> were >>> the quotes comes into play. >>> The service name comparison is against a string and strings should be >>> enclosed with quotes: >>> PS > gwmi win32_service -filter "name='alerter'" >>> >>> Same thing when you generate the service name using a command, this >>> gives an error: >>> >>> PS > gwmi win32_service -filter "name=$(get-service alerter).name)" >>> Get-WmiObject : Invalid query >>> At line:1 char:5 >>> + gwmi <<<< win32_service -filter "name=$(get-service >>> alerter).name)" >>> This is not: >>> >>> PS > gwmi win32_service -filter "name='$((get-service >>> alerter).name)'" >>> >>> ExitCode : 1077 >>> Name : Alerter >>> ProcessId : 0 >>> StartMode : Disabled >>> State : Stopped >>> Status : OK >>> I hope it's clear enough now ![]() >>> >>> --- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>> A> Thanks a lot, this works!!!! >>> A> A> Would you be so kind to explain, why the quotes are necessary >>> and >>> A> what they do? >>> A> A> I know that $() is a subexpression, but why must this be >>> quoted? >>> A> A> Alex >>> A> A> "Shay Levi" <no@addre.ss> schrieb im Newsbeitrag >>> A> news:89228ed2325378caa4f77123755a@news.microsoft.c om... >>> A> >>>>> Try: >>>>> >>>>> Get-Recipient -filter "AddressListMembership -eq >>>>> '$((Get-AddressList TestAddresslist).DistinguishedName)'" >>>>> >>>>> --- >>>>> Shay Levi >>>>> $cript Fanatic >>>>> http://scriptolog.blogspot.com >>>>> A> Hello, >>>>> A> A> I tried to query informations within a single command. To >>>>> achieve >>>>> A> this I >>>>> A> tried with subexpression, but it does not work. >>>>> A> I wanted to get all recipients within a Exchange addresslist. >>>>> A> Unfortunatly this does not work: >>>>> A> Get-Recipient -Filter {AddressListMembership -eq >>>>> $((Get-addresslist >>>>> A> TestAddresslist).DistinguishedName)} >>>>> A> Anybody who knows a solution? If possible I want a single >>>>> command >>>>> not >>>>> A> a script! >>>>> A> A> Thanks a lot.. >>>>> A> A> Alex >>>>> A> > > |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|