Suppress GET-ADComputer output

Ask your PowerShell-related questions, including questions on cmdlet development!
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.
This topic is 8 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
waynecierkowski
Posts: 28
Last visit: Mon Jul 10, 2023 10:51 am

Suppress GET-ADComputer output

Post by waynecierkowski »

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: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Suppress GET-ADComputer output

Post by davidc »

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.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Suppress GET-ADComputer output

Post by jvierra »

What Output is it that you don't want?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Suppress GET-ADComputer output

Post by jvierra »

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
Last visit: Fri Apr 08, 2016 7:55 am

Re: Suppress GET-ADComputer output

Post by cogenc »

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: 28
Last visit: Mon Jul 10, 2023 10:51 am

Re: Suppress GET-ADComputer output

Post by waynecierkowski »

Thanks I'll give that a try and let you know...
This topic is 8 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked