String 字符串和powershell从数组中提取用户名
我有此代码,当我执行此powershell代码时:String 字符串和powershell从数组中提取用户名,string,powershell,String,Powershell,我有此代码,当我执行此powershell代码时: Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object UserName 我会得到: UserName -------- DESKTOP-JBJN9QA\joli 我怎样才能只提取joli这个名字 谢谢你-Expandproperty用户名对我不起作用-如果你不想 Get-CimInstance –Class
Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object UserName
我会得到:
UserName
--------
DESKTOP-JBJN9QA\joli
我怎样才能只提取joli这个名字
谢谢你
-Expandproperty用户名
对我不起作用-如果你不想
Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object PrimaryOwnerName
试一试
选择对象-ExpandProperty用户名
(Get-CimInstance –ClassName Win32_ComputerSystem).UserName.split('\')[1]