0
我需要創建一個PowerShell腳本,您可以雙擊(64位計算機),它會輸出到與PowerShell腳本相同位置的.txt文件以生成以下信息:powershell計算機信息腳本
- 計算機名/型號/序列號。
- C盤大小的C盤
- 哪個版本的操作系統的計算機上正在運行/可用磁盤空間
- 誰是目前登錄到計算機
到目前爲止(但它並不完全工作)我有:
$computerSystem = get-wmiobject Win32_ComputerSystem
$computerOS = get-wmiobject Win32_OperatingSystem
$computerHDD = Get-WmiObject Win32_LogicalDisk -Filter drivetype=3
$txtObject = New-Object PSObject -property @{
'PCName' = $computerSystem.Name
'Model' = $computerSystem.Model
'SerialNumber' = $computerBIOS.SerialNumber
'HDDSize' = "{0:N2}" -f ($computerHDD.Size/1GB)
'HDDFree' = "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size)
'OS' = $computerOS.caption
'SP' = $computerOS.ServicePackMajorVersion
'User' = $computerSystem.UserName
}
$txtObject | Select PCName, Model, SerialNumber, HDDSize, HDDFree, OS, SP, User | Get-Process | Out-File 'system-info.txt' -NoTypeInformation -Append