Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - need help with Get-QADComputer

Reply
 
Old 03-19-2008   #1 (permalink)
Ben Christian


 
 

need help with Get-QADComputer

so...i'm trying to write a script to poll AD for machines machine a query
that's put in...but i'm not able to get it to return anything...

basically, the input should be the machine suffix, then receive a list of
PCs maching that query...below is what happens (when i manually enter the
commands), and i'm not sure why...any ideas?

I echo $query to ensure that it is accepting it's assigned value properly
and it is...it looks like the problem i'm having is that QADCOmputer doesn't
like taking the variable...

Thanks!!

PS C:\> $wc = read-host "enter the suffix"
enter the suffix: ppm
PS C:\> $query = "*$wc$"
PS C:\> $query
*ppm$
PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=$query)' | select name
PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*$wc$)' | select name
PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*ppm$)' | select name

Name
----
0123456PPM
7654321PPM
1234567PPM


My System SpecsSystem Spec
Old 03-19-2008   #2 (permalink)
Shay Levi


 
 

Re: need help with Get-QADComputer



Two things:

1. The syntax of the ldap filter is OK but the quotes are not, opening and
closing quotes are not from the same type.
2. $query cannot be expanded inside single quotes, you should wrap the filter
with double quotes.


This should do the job:


$query = "*$wc$"
Get-QADComputer -LdapFilter "(SamAccountName=$query)" | select name




-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Quote:

> so...i'm trying to write a script to poll AD for machines machine a
> query that's put in...but i'm not able to get it to return anything...
>
> basically, the input should be the machine suffix, then receive a list
> of PCs maching that query...below is what happens (when i manually
> enter the commands), and i'm not sure why...any ideas?
>
> I echo $query to ensure that it is accepting it's assigned value
> properly and it is...it looks like the problem i'm having is that
> QADCOmputer doesn't like taking the variable...
>
> Thanks!!
>
> PS C:\> $wc = read-host "enter the suffix"
> enter the suffix: ppm
> PS C:\> $query = "*$wc$"
> PS C:\> $query
> *ppm$
> PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=$query)' | select
> name
> PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*$wc$)' | select
> name
> PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*ppm$)' | select
> name
> Name
> ----
> 0123456PPM
> 7654321PPM
> 1234567PPM

My System SpecsSystem Spec
Old 03-19-2008   #3 (permalink)
Ben Christian


 
 

Re: need help with Get-QADComputer

Thanks once more Shay! Silly me...

"Shay Levi" wrote:
Quote:

>
>
> Two things:
>
> 1. The syntax of the ldap filter is OK but the quotes are not, opening and
> closing quotes are not from the same type.
> 2. $query cannot be expanded inside single quotes, you should wrap the filter
> with double quotes.
>
>
> This should do the job:
>
>
> $query = "*$wc$"
> Get-QADComputer -LdapFilter "(SamAccountName=$query)" | select name
>
>
>
>
> -----
> Shay Levi
> $cript Fanatic
> http://scriptolog.blogspot.com
>
Quote:

> > so...i'm trying to write a script to poll AD for machines machine a
> > query that's put in...but i'm not able to get it to return anything...
> >
> > basically, the input should be the machine suffix, then receive a list
> > of PCs maching that query...below is what happens (when i manually
> > enter the commands), and i'm not sure why...any ideas?
> >
> > I echo $query to ensure that it is accepting it's assigned value
> > properly and it is...it looks like the problem i'm having is that
> > QADCOmputer doesn't like taking the variable...
> >
> > Thanks!!
> >
> > PS C:\> $wc = read-host "enter the suffix"
> > enter the suffix: ppm
> > PS C:\> $query = "*$wc$"
> > PS C:\> $query
> > *ppm$
> > PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=$query)' | select
> > name
> > PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*$wc$)' | select
> > name
> > PS C:\> Get-QADComputer -LdapFilter `(SamAccountName=*ppm$)' | select
> > name
> > Name
> > ----
> > 0123456PPM
> > 7654321PPM
> > 1234567PPM
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Inherent *problem* in AD / qet-qadcomputer PowerShell
Working with Get-QadComputer PowerShell
quest cmdlet : get-qadcomputer PowerShell
Get-QADComputer PowerShell
Get-qadcomputer PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46