I want to remove localhost from the string but the following commands are not working. Any ideas why not?
option 1:
[string[]]$Servers = '"localhost","tbhserver"'
$Servers = $servers | Where-Object {$_ -ne "localhost"}
option 2:
[string[]]$Servers = '"localhost","tbhserver"'
$Servers
[System.Collections.ArrayList]$servers = $servers
$servers.Remove("localhost")
It looks to me like you’re only assigning one string, ‘”localhost”,”tbhserver”‘, to $Servers, rather than a list of two.
Does this work?
I’m not at a Windows machine right now, so I cannot test this.