首页 > 解决方案 > 将 System.String 转换为对象

问题描述

我正在使用 PowerShell 查询 Cisco 交换机的接口状态,该状态以System.String. 我想将此字符串转换为一个对象,但不知道如何去做。如果有办法按列宽分解字符串,回车是我能想到的唯一方法,但我不知道如何编码。

字符串如下所示:

端口名称 状态 Vlan 双工速度类型
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 端口通道 28 连接路由 a-full a-1000 1000BaseLX SFP
Gi1/0/4 端口通道 28 连接路由 a-full a-1000 1000BaseLX SFP

标签: powershell

解决方案


推荐阅读