-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' –