新手问题在这里。我在下面有这个用于 powershell 的脚本,它为我提供了来自 AD 的 PC 信息。但我一直无法将结果导出到 csv。还如何获取 ipv4 ip 地址而不包括 ipv6?并说如果 PC 处于离线状态,是否可以再给我一列以显示如果它处于离线状态,它会返回 RPC 服务器不可用或离线。在此处输入图像描述 感谢帮助。
$ArrComputers = Get-Content "C:\Temp\computers-systeminfo.txt"
#Specify the list of PC names in the line above. "." means local system
Clear-Host
foreach ($Computer in $ArrComputers)
{
$computerSystem = get-wmiobject Win32_ComputerSystem -Computer $Computer
$computerBIOS = get-wmiobject Win32_BIOS -Computer $Computer
$computerOS = get-wmiobject Win32_OperatingSystem -Computer $Computer
$computerCPU = get-wmiobject Win32_Processor -Computer $Computer
$computerHDD = Get-WmiObject Win32_LogicalDisk -ComputerName $Computer -Filter drivetype=3
$computerIPv4 = Get-WmiObject WIn32_NetworkAdapterConfiguration -Computer $Computer
write-host "System Information for: " $computerSystem.Name -BackgroundColor DarkCyan
"-------------------------------------------------------"
"Manufacturer: " + $computerSystem.Manufacturer
"Model: " + $computerSystem.SystemFamily
"Machine Name: " + $computerSystem.DNSHostName
"IP Address: " + $computerIPv4.Ipaddress
"Serial Number: " + $computerBIOS.SerialNumber
"CPU: " + $computerCPU.Name
"HDD Capacity: " + "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
"HDD Space: " + "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size) + " Free (" + "{0:N2}" -f ($computerHDD.FreeSpace/1GB) + "GB)"
"RAM: " + "{0:N2}" -f ($computerSystem.TotalPhysicalMemory/1GB) + "GB"
"Operating System: " + $computerOS.caption + " "+ $computerOS.BuildNumber
"User logged In: " + $computerSystem.UserName
"Last Reboot: " + $computerOS.ConvertToDateTime($computerOS.LastBootUpTime)
""
"-------------------------------------------------------"
}