Link to home
Start Free TrialLog in
Avatar of SquigglyMonkey
SquigglyMonkey

asked on

powershell script trouble with 5.1 and get-localgroupmember input

script with powershell 5.1, I need a little help getting the input working the way I'd like, I have this script and it works great with a servers.txt input, or read-host. I'd like the read-host to be able to take several system names, all my efforts keep returning the error:
Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI objects instead of strings.
I tried quotes, commas, double quotes, still get an error that the name is wrong.
$server = Read-host "Enter server names"
#$servers = gc .\servers.txt
foreach ($server in $servers) {
Invoke-Command -computername $server -scriptblock {Get-LocalGroupMember -group "administrators"}
}

Open in new window


What do I need to do to be able to have more than one server from read-host?
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SquigglyMonkey
SquigglyMonkey

ASKER

Perfect, thank you.