大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
$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 } }