Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-ADComputer variables in SearchBase and Filter

$
0
0

Hi guys,

Please help with the following question.

I have the code in my script and it is working.

$servers = (Get-ADComputer -SearchBase "OU=CRMBilling,OU=Servers,OU=KYIV,DC=corp,DC=ukrtelecom,DC=loc" -Filter { OperatingSystem -Like "*Windows Server*" -and dnshostname -like "kv-crm*" })

But if I am using

$ServersFilter    = "{ OperatingSystem -Like `"*Windows Server*`" -and dnshostname -like `"kv-crmapp*`"}"

$SearchBaseAD = "OU=CRMBilling,OU=Servers,OU=KYIV,DC=corp,DC=ukrtelecom,DC=loc"

$servers = (Get-ADComputer -SearchBase "'$SearchBaseAD'" -Filter "'$ServersFilter'")

It is not work.

How I can use variables in SearchBase and Filter?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>