如何在 PowerShell 中获取变量数据类型?
powershellmicrosoft technologiessoftware & coding
变量有不同的数据类型,例如 Byte、Int32、Float、String 等。要获取变量类型,我们需要使用 GetType() 方法。
示例
$x = 10 $x.GetType()
输出
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Int32 System.ValueType
要仅获取变量数据类型,请使用 Name属性。
$x.GetType().Name
Int32

