0

I'm trying to filter for Name and Operating system.

I can do name or operating system. But I cannot do both.

How do I get this working

Get-Content "C:\test.txt" | foreach {((Get-ADComputer $_ -Server:"Server 123"-Properties name,operatingsystem).name)}

Get-Content "C:\test.txt" | foreach {((Get-ADComputer $_ -Server:"Server 123"-Properties name,operatingsystem).operating system)}

Both work above.

Get-Content "C:\test.txt" | foreach {((Get-ADComputer $_ -Server:"Server 123"-Properties name,operatingsystem).name.operating system)}

Error

1

1 Answer 1

1

Use Select-Object to select the properties you need.

Get-ADComputer -Identity $ComputerName -Properties Name, OperatingSystem | Select-Object -Property Name, OperatingSystem
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.