-2
我有这样的代码,当我EXCUTE这个PowerShell代码:字符串和PowerShell提取用户名
Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object UserName
我会得到:
UserName
--------
DESKTOP-JBJN9QA\joli
我怎么能只提取名称阿邦 谢谢
我有这样的代码,当我EXCUTE这个PowerShell代码:字符串和PowerShell提取用户名
Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object UserName
我会得到:
UserName
--------
DESKTOP-JBJN9QA\joli
我怎么能只提取名称阿邦 谢谢
-Expandproperty UserName
不为我工作 - 如果你不想
Get-CimInstance –ClassName Win32_ComputerSystem | Select-Object PrimaryOwnerName
尝试
(Get-CimInstance –ClassName Win32_ComputerSystem).UserName.split('\')[1]
谢谢很多 其解决 –
'选择-对象-ExpandProperty UserName' –