ndalmolin_13
asked on
Help extracting text from a string
Hello Powershell Gurus,
Here is my powershell question for the day. If I run the following command:
Get-WmiObject -Class Win32_NetworkAdapterConfig uration -ComputerName fs01 | Select-Object dnsserversearchorder
I get the following output (which is correct):
dnsserversearchorder
--------------------
{172.16.1.19, 172.16.1.20}
I ran the get-member on the Get-WmiObject -Class Win32_NetworkAdapterConfig uration command and learned that the dnsserversearchorder property is a string. How can I extract the two IP addresses from the string?
Thanks in advance.
Regards,
Nick
Here is my powershell question for the day. If I run the following command:
Get-WmiObject -Class Win32_NetworkAdapterConfig
I get the following output (which is correct):
dnsserversearchorder
--------------------
{172.16.1.19, 172.16.1.20}
I ran the get-member on the Get-WmiObject -Class Win32_NetworkAdapterConfig
Thanks in advance.
Regards,
Nick
ASKER
How would I do this?
I tried the following:
$dns = Get-Wmiobject -Class Win32_NetworkAdapterConfig uration -ComputerName fs01 | Select-Object dnsserversearchorder
$dns.split(",")
I received an error stating:
Method invocation failed because [System.Object[]] doesn't contain a method named 'split'.
At :line:2 char:10
+ $dns.split <<<< (",")
I tried the following:
$dns = Get-Wmiobject -Class Win32_NetworkAdapterConfig
$dns.split(",")
I received an error stating:
Method invocation failed because [System.Object[]] doesn't contain a method named 'split'.
At :line:2 char:10
+ $dns.split <<<< (",")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help!
$string.Split(",")
Split on the comma and you will split the string into (2) IP addresses