Kasper Katzmann
asked on
PowerShell and inline Read-Host
Just a little thought... Is it possible to a Read-Host in the same line as ie. Get-ADUser?
Something like this:
Regards
Kasper
Something like this:
$inp = read-host "User" | get-aduser $inp
I know the abowe isn't possible, but is there another way to keep it all in the same line?Regards
Kasper
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This one works:
read-host "User" | get-aduser
This one doesn't return anything:
$inp = read-host "User" get-aduser $inp
$inp = read-host "User" get-aduser $inp will not work..
$inp = read-host "User" | get-aduser will work. It will not return anything because the result is saved in var $inp
If you run $inp , then you will get the saved value..
$inp = read-host "User" | get-aduser will work. It will not return anything because the result is saved in var $inp
If you run $inp , then you will get the saved value..
ASKER
Exactly
To complete the answer:
$inp = read-host "User" | get-aduser
is the same as
$inp = (read-host "User" | get-aduser)
and not
($inp = read-host "User") | get-aduser
Another way to execute is
get-aduser (read-host "User")
$inp = read-host "User" | get-aduser
is the same as
$inp = (read-host "User" | get-aduser)
and not
($inp = read-host "User") | get-aduser
Another way to execute is
get-aduser (read-host "User")
$inp = read-host "User"
get-aduser $inp
do it at the command line or in a script.