1. 程式人生 > >收集域中電腦信息

收集域中電腦信息

mic oob tin rod get 中央處理器 repl for bject

$Date=(Get-Date).ToString("yyyyMMdd") Write-Output ("計算機名稱,MAC地址,使用者,主板型號,中央處理器,物理內存(GB),操作系統,IP") |` Out-File -FilePath C:\LDM-PC$Date.csv -Encoding UTF8 $LDM_PC=(Get-ADComputer -Filter * | Where-Object {$_.Name -like "lmpc*" -or $_.Name -like "lmlap*" }).Name | Sort-Object ForEach($PC_Info in $LDM_PC){ IF ((Test-Connection -ComputerName $PC_Info -Count 1 -ErrorAction SilentlyContinue ).statuscode -eq 0) { $ComObject=Get-WmiObject -ComputerName $PC_Info -Class Win32_ComputerSystem $Name=$ComObject.Name $UserName=$ComObject.UserName $FullName=(Get-WmiObject Win32_UserAccount| Where-Object {$_.Caption -eq $UserName }).FullName $Memory="{0:N0}" -f ($ComObject.TotalPhysicalMemory/1GB) $NetObject=Get-WmiObject -ComputerName $PC_Info -Class Win32_NetWorkAdapterConfiguration -Filter "IPEnabled='True'" $MACAddress=$NetObject.MACAddress -replace ":","-" $IPAddress=$NetObject.IPAddress -like "*.*.*.*" $ProObject=Get-WmiObject -ComputerName $PC_Info -Class Win32_Processor $CPU=$ProObject.Name $OpeObject=Get-WmiObject -ComputerName $PC_Info -Class Win32_OperatingSystem $OpeName=$OpeObject.Caption $BasObject=Get-WmiObject -ComputerName $PC_Info -Class Win32_BaseBoard $BaseModel=$BasObject.Product $SerialNumber=$BasObject.SerialNumber if ($BaseModel -eq "0T1D10 ") {$BaseModel="Dell Vostro3800(大機箱)"} #註意此處空格 if ($BaseModel -eq "0RYP79") {$BaseModel="Dell Vostro 3267(小機箱)"} if ($BaseModel -eq "0JP3NX") {$BaseModel="Dell OptiPlex 3050 Micro(迷你機箱)"} if ($BaseModel -eq "0GG04X") {$BaseModel="Dell OptiPlex 3050 SFF(大機箱)"} if ($BaseModel -eq "B250M-D3H-CF") {$BaseModel="技嘉 B250M-D3H-CF"} if ($BaseModel -eq "MS-H110D4L FS M.2") {$BaseModel="銘瑄 MS-H110D4L FS M.2"} if ($BaseModel -eq "B150M-ET SERIES") {$BaseModel="華碩 B150M-ET SERIES"} if ($BaseModel -eq "B85M-F") {$BaseModel="華碩 B85M-F"} if ($BaseModel -eq "B85M-D2V-SI") {$BaseModel="技嘉 B85M-D2V-SI"} if ($BaseModel -eq "H81M-DS2") {$BaseModel="技嘉 H81M-DS2"} if ($BaseModel -eq "C.H81M PRO") {$BaseModel="七彩虹 C.H81M PRO"} if ($BaseModel -eq "C.B75K") {$BaseModel="七彩虹 C.B75K"} if ($BaseModel -eq "MS-H81IL FS") {$BaseModel="銘瑄 MS-H81IL FS"} if ($BaseModel -eq "H81M-VG4 R2.0") {$BaseModel="華擎 H81M-VG4 R2.0"} if ($SerialNumber -eq "/4MP1KL2/CNPE10078C05EZ/") {$FullName="會議室1"} if ($SerialNumber -eq "/4MK1KL2/CNPE10078B06OX/") {$FullName="會議室2"} if ($SerialNumber -eq "/4MD3KL2/CNPE1007860LI5/") {$FullName="會議室3"} Write-Output("`"$Name`",`"$MACAddress`",`"$FullName`",`"$BaseModel`",`"$CPU`",`"$Memory`",`"$OpeName`",`"$IPAddress`"") | Out-File -FilePath C:\LDM-PC$Date.csv -Append -Encoding UTF8 } }


收集域中電腦信息