![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||