1

I am using PowerShell for querying Cisco switches for their interface status which is returned as a System.String. I want to convert this string into an object but am not sure how to go about this. If there was a way to break the string down by column width and carriage returns is the only way I can think of but I am not sure how to code that.

The string looks as follows:

Port      Name               Status       Vlan       Duplex  Speed Type
Gi1/0/1   Port-Channel 1     connected    trunk      a-full a-1000 1000BaseLX SFP
Gi1/0/2   Port-Channel 1     connected    trunk      a-full a-1000 1000BaseLX SFP
Gi1/0/3   Port-Channel 28    connected    routed     a-full a-1000 1000BaseLX SFP
Gi1/0/4   Port-Channel 28    connected    routed     a-full a-1000 1000BaseLX SFP
2
  • Hi @Armando - I'm afraid your question is unclear. What code are you using the obtain the resultant string i.e. how are you querying the switches? Commented Jul 10, 2019 at 6:31
  • Try this cmdlet: ConvertFrom-SourceTable. As the table has a right aligned column (Speed) which are in fact not integers, you need ta add the -Literal switch. Example: $YourString | ConvertFrom-SourceTable -Literal Commented Jul 10, 2019 at 6:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.