0

I have a command Get-Aduser -Filter 'Surname -like "Doe"' -properties * | Format-List, but I'd like to use it with a Read-Host cmdlet using inline syntax. Something similar to

Get-Aduser -Filter 'Surname -like "{Read-Host -prompt "User surname?"}"' -properties * | Format-List

What is a correct syntax to do so? or the proper way to do so is to use a one-liners and the pipeline?

1 Answer 1

2

This is it

Get-Aduser -Filter "Surname -like ""$(read-host -prompt "User surname?")""" -properties * | Format-List
Sign up to request clarification or add additional context in comments.

1 Comment

Easier way to do it is "Surname -like '$(Read-Host -Prompt 'User surname?')'". Doesn't require triple " to close it.

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.