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
ConvertFrom-SourceTable. As the table has a right aligned column (Speed) which are in fact not integers, you need ta add the-Literalswitch. Example:$YourString | ConvertFrom-SourceTable -Literal