- get-domainPCs
- $comps = Get-DomainPCs
- foreach ($comp in $comps){
- $comp
- Get-WmiObject win32_bios -ComputerName $comp
- Get-WmiObject win32_computuersystem -ComputerName $comp
- }
Wildcard to search Active Directory computers
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Wildcard to search Active Directory computers
I use this function in my profile to list all domain computers. I would like to be able to filter the list with a wildcard search for computers. Is this possible?
Re: Wildcard to search Active Directory computers
That's odd. I can see it in my previous post. I posted it as PoSH code. Here it is as text...
get-domainPCs
$comps = Get-DomainPCs
foreach ($comp in $comps){
$comp
Get-WmiObject win32_bios -ComputerName $comp
Get-WmiObject win32_computuersystem -ComputerName $comp
}
get-domainPCs
$comps = Get-DomainPCs
foreach ($comp in $comps){
$comp
Get-WmiObject win32_bios -ComputerName $comp
Get-WmiObject win32_computuersystem -ComputerName $comp
}
Re: Wildcard to search Active Directory computers
Ahh. I see. It was created as a collapsed block. It shows when expanded.. This is likely because you pasted formatted code.
The code you posted does not get an computers. What is Get-DomainPCs? What does it return?
The code you posted does not get an computers. What is Get-DomainPCs? What does it return?
Re: Wildcard to search Active Directory computers
It queries AD and lists all computer names in the domain
Re: Wildcard to search Active Directory computers
On the computer names, in the list of returned items.
Results:
COMP1
COMP2
PC1
PC3
Wildcard example:
Get-DomainPCs COMP*
COMP1
COMP2
Results:
COMP1
COMP2
PC1
PC3
Wildcard example:
Get-DomainPCs COMP*
COMP1
COMP2
Re: Wildcard to search Active Directory computers
Since we don't know what your GEt-DomainPCs does there is no way to know if that will work. Can you ask the original author for help? Does the CmdLet have help?
Re: Wildcard to search Active Directory computers
function Get-DomainPCs
{
$domainComps =([adsisearcher]'objectCategory=computer').FindAll()|%{$_.Properties['name']}
$domainComps = $domainComps | Sort-Object
$domainComps
}
=============
No help, just that code
{
$domainComps =([adsisearcher]'objectCategory=computer').FindAll()|%{$_.Properties['name']}
$domainComps = $domainComps | Sort-Object
$domainComps
}
=============
No help, just that code
Re: Wildcard to search Active Directory computers
The function cannot use wild cards as it is built to return all computer objects by object type and not by name. Filter the list after the function.