Support Forums

Suppress GET-ADComputer output

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.
User avatar
waynecierkowski
Posts: 17
Joined: Wed May 14, 2014 11:40 am

Suppress GET-ADComputer output

Postby waynecierkowski » Tue Nov 10, 2015 2:54 pm

Product, version and build: PowerShell Studio 2015
32 or 64 bit version of product: 64 bit
Operating system: Windows 8.1
32 or 64 bit OS: 64 bit

Hi,

I am creating a Backup Audit for my company and to get all the known Servers in our organization I am going against Active Directory. I have imported the Active Directory module into my program. I then issue the Get-ADComputer cmdlet and store the results into a variable that I can work with.

When the command runs after I build my program I have output coming out which looks like a AD Structure.

Sample:

Issuing Get-ADComputers command
CN=HCUSSB300,OU=Domain Controllers,DC=hcpna,DC=dmz CN=HCUSSC313,OU=GroupPolicyExclusions,DC=hcpna,DC=dmz CN=HCUSSC323,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC322,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSB301,OU=Domain Controllers,DC=hcpna,DC=dmz CN=HCUSSC326,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC309,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC303,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC302,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC325,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC308,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC320,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSC306,CN=Computers,DC=hcpna,DC=dmz CN=HCUSSB399,OU=DMZMemberServers,DC=hcpna,DC=dmz CN=HCUSSB193,OU=DMZMemberServers,DC=hcpna,DC=dmz CN=HCUSSB302,OU=DMZMemberServers,DC=hcpna,DC=dmz CN=HCUSSB310,OU=DMZMemberServers,DC=hcpna,DC=dmz

Actual command being issued:

$HCPServers = Get-ADComputer -Filter { OperatingSystem -Like "Windows Server*" } -Property *

Is there a way to suppress this output?

TIA...

Wayne
User avatar
davidc
Posts: 4448
Joined: Thu Aug 18, 2011 4:56 am

Re: Suppress GET-ADComputer output

Postby davidc » Fri Nov 13, 2015 2:51 pm

I moved this over to the Windows PowerShell forum so that an community expert in AD can provide assistance as to where this output is coming from.

David
David
SAPIEN Technologies, Inc.
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Suppress GET-ADComputer output

Postby jvierra » Fri Nov 13, 2015 3:19 pm

What Output is it that you don't want?
User avatar
jvierra
Posts: 10021
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Suppress GET-ADComputer output

Postby jvierra » Fri Nov 13, 2015 6:01 pm

I cannot reproduce you issue in any normal way.
If I run your line of code I get no output. It I run the code like this I get your output:

$HCPServers = Get-ADComputer -Filter { OperatingSystem -Like "Windows Server*" } -Property *

$HCPServers | %{"$_"}
That will produce your output and it is correct.

What is the code that you are using?
User avatar
cogenc
Posts: 2
Joined: Tue Nov 17, 2015 4:55 am

Re: Suppress GET-ADComputer output

Postby cogenc » Tue Nov 17, 2015 5:20 am

Try piping it to Out-Null. This should accomplish what you're trying to do. If it doesn't, let me know. I'm pretty familiar with the ActiveDirectory Module and am happy to help.
User avatar
waynecierkowski
Posts: 17
Joined: Wed May 14, 2014 11:40 am

Re: Suppress GET-ADComputer output

Postby waynecierkowski » Wed Dec 02, 2015 2:17 pm

Thanks I'll give that a try and let you know...

Return to “Windows PowerShell”

Who is online

Users browsing this forum: No registered users and 3 guests