Reputation: 53
I'm trying to replace one piece of text in a config file if it doesn't match a parameter. I read in the file for the key phrase
$list = @((get-content client.cfg) | where { $_ -match "node_name(.*)" } )
$s = $list.split()
I'm borrowing the parse configuration, but have no idea what class $list is. The split() function gives an error but $s is assigned. The assignment is weird. The regex should give two results but the the $s array has too many fields and I get a system object error.
How can I just $list as a simple text array with the two matches of the regex?
Upvotes: 1
Views: 1440
Reputation: 7489
To find out what methods are available, and to determine what type of object you're working with, use the Get-Member cmdlet:
$list | gm
In this case, it's probably a string.
The .split() method on a string needs some sort of argument, as far as I'm aware. See the documentation on MSDN:
http://msdn.microsoft.com/en-us/library/system.string.split.aspx
Upvotes: 2