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