[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] 【wmic硬件检测-gfd5.3】新手发帖:简单获取电脑信息并保存,慢慢完善更新

本帖最后由 gfd 于 2024-1-17 11:54 编辑

我一直在用的代码,不定时更新。
主要用途:获取电脑的序列号、配置信息,然后保存到文件中。我是卖电脑的,收集这些信息可以记录电脑序列,销售日期,方便后期的保修查询等。
代码都是东拼西凑弄来的,大神有更好的建议欢迎提出,谢谢。
  1. @echo off&color e&title gfd硬件检测_5.2
  2. mode con cols=110 lines=70
  3. setlocal enabledelayedexpansion
  4. echo 信息提取时间:%date%      时间 %Time%
  5. for /f "tokens=1* delims=:=" %%a in ('"wmic os get Caption,InstallDate,OSArchitecture,Version /Format:List"') do (
  6.     IF /I "%%a"=="Caption" set Caption=%%b
  7.     IF /I "%%a"=="InstallDate" set InstallDate=%%b
  8.     IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
  9.     IF /I "%%a"=="Version" set Version=%%b
  10. )
  11. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  12. echo.
  13. echo 主版:
  14. for /f "tokens=1* delims==" %%a in ('"wmic csproduct get IdentifyingNumber,Name,Vendor,Version /value|more +2"') do (
  15.     IF /I "%%a"=="IdentifyingNumber" set IdentifyingNumber=%%b
  16.     IF /I "%%a"=="Name" set Name=%%b
  17.     IF /I "%%a"=="Vendor" set Vendor=%%b
  18.     IF /I "%%a"=="Version" set VersionZ=%%b
  19. )
  20. echo     供应商:%Vendor%
  21. echo     系  列:%Name%
  22. echo     型  号:%VersionZ%
  23. echo     序列号:%IdentifyingNumber%&echo.&echo.
  24. REM 处理器
  25. for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
  26. echo CPU :【%CPUQuantity% 颗】
  27. for /f "tokens=1* delims==" %%a in ('"wmic cpu get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
  28.     IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
  29.     IF /I "%%a"=="Name" set NameC=%%b
  30.     IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
  31.     IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
  32. )
  33. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
  34. echo     主  频:%MaxClockSpeed%&echo.&echo.
  35. REM 内存
  36. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
  37. echo 内存:【%MemoryQuantity% 条】
  38. for /f "tokens=2 delims==" %%a in ('"wmic memorychip get Capacity /value"') do (
  39.     set "Capacity=%%a"
  40.     for /f "tokens=1 delims=." %%b in ("!Capacity:~,-7!/1073") do set /a m+=%%b
  41.     )
  42. call echo     总容量:%%m%% GB
  43. for /f "tokens=1* delims==" %%a in ('"wmic memorychip get ConfiguredClockSpeed /value"') do (
  44.     IF /I "%%a" == "ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
  45. )
  46. echo     频  率:%ConfiguredClockSpeed%&echo.&echo.
  47. REM 硬盘
  48. for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Caption /value"') do set /a DiskQuantity+=1
  49. echo 硬盘:【%DiskQuantity% 块】
  50. set "Model=   型  号:"&set "SerialNumber=   序列号:"&set "size=   容  量:"
  51. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Model,SerialNumber,Size /value|more +2"') do echo. !%%a!%%b
  52. echo 显示:
  53. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
  54.     IF /I "%%a"=="CurrentRefreshRate" (
  55.         echo.    当前刷新率: %%b)
  56.     IF /I "%%a"=="DeviceID" (
  57.         echo.    设  备  ID: %%b)
  58.     IF /I "%%a"=="MaxRefreshRate" (
  59.         echo.    最高刷新率: %%b)
  60.     IF /I "%%a"=="MinRefreshRate" (
  61.         echo.    最低刷新率: %%b)
  62.     IF /I "%%a"=="Name" (
  63.         echo.    显卡  名称: %%b)
  64.     IF /I "%%a"=="VideoModeDescription" (
  65.         echo.    当前分辨率: %%b
  66.         echo ----------------------------)
  67. )
  68. echo.&echo.
  69. echo BIOS:
  70. for /f "tokens=1* delims=:=" %%a in ('"wmic bios get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /Format:List"') do (
  71.     IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
  72.     IF /I "%%a"=="SerialNumber" set SerialNumberB=%%b
  73.     IF /I "%%a"=="Manufacturer" set Manufacturer=%%b
  74.     IF /I "%%a"=="Name" set NameB=%%b
  75.     IF /I "%%a"=="Version" set VersionB=%%b
  76.     IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
  77.     IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
  78. )
  79. echo     制  造  商:%Manufacturer%
  80. echo     名      称:%NameB%
  81. echo     版      本:%VersionB%
  82. echo     BIOS  版本:%BIOSVersion%
  83. echo     SMBIOS版本:%SMBIOSBIOSVersion%
  84. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  85. echo     序  列  号:%SerialNumberB%
  86. echo.
  87. echo 信息提取完成,按任意键保存到文本中。
  88. pause>nul
  89. REM ==========保存信息到文件中,如果不需要,删除下面所有==========
  90. echo 信息提取时间:%date%      时间 %Time%>>wmic硬件信息gfd.txt
  91. echo Windows_信息:%Caption%%Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒>>wmic硬件信息gfd.txt
  92. echo.>>wmic硬件信息gfd.txt
  93. echo 主版:>>wmic硬件信息gfd.txt
  94. echo     供应商:%Vendor%>>wmic硬件信息gfd.txt
  95. echo     系  列:%Name%>>wmic硬件信息gfd.txt
  96. echo     型  号:%VersionZ%>>wmic硬件信息gfd.txt
  97. echo     序列号:%IdentifyingNumber%>>wmic硬件信息gfd.txt
  98. echo. >>wmic硬件信息gfd.txt
  99. echo. >>wmic硬件信息gfd.txt
  100. REM 处理器
  101. echo CPU :【%CPUQuantity% 颗】>>wmic硬件信息gfd.txt
  102. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>wmic硬件信息gfd.txt
  103. echo     主  频:%MaxClockSpeed%>>wmic硬件信息gfd.txt
  104. echo. >>wmic硬件信息gfd.txt
  105. echo. >>wmic硬件信息gfd.txt
  106. REM 内存
  107. echo 内存:【%MemoryQuantity% 条】>>wmic硬件信息gfd.txt
  108. echo     总容量:%m% GB>>wmic硬件信息gfd.txt
  109. echo     频  率:%ConfiguredClockSpeed%>>wmic硬件信息gfd.txt
  110. echo. >>wmic硬件信息gfd.txt
  111. echo. >>wmic硬件信息gfd.txt
  112. REM 硬盘
  113. echo 硬盘:【%DiskQuantity% 块】>>wmic硬件信息gfd.txt
  114. set "Model=   型  号:"&set "SerialNumber=   序列号:"&set "size=   容  量:"
  115. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' get Model,SerialNumber,Size /value|more +2"') do echo. !%%a!%%b>>wmic硬件信息gfd.txt
  116. echo 显示:>>wmic硬件信息gfd.txt
  117. for /f "tokens=1* delims==" %%a in ('"wmic path Win32_VideoController get CurrentRefreshRate,DeviceID,MaxRefreshRate,MinRefreshRate,Name,VideoModeDescription /value"') do (
  118.     IF /I "%%a"=="CurrentRefreshRate" (
  119.         echo.    当前刷新率: %%b>>wmic硬件信息gfd.txt)
  120.     IF /I "%%a"=="DeviceID" (
  121.         echo.    设  备  ID: %%b>>wmic硬件信息gfd.txt)
  122.     IF /I "%%a"=="MaxRefreshRate" (
  123.         echo.    最高刷新率: %%b>>wmic硬件信息gfd.txt)
  124.     IF /I "%%a"=="MinRefreshRate" (
  125.         echo.    最低刷新率: %%b>>wmic硬件信息gfd.txt)
  126.     IF /I "%%a"=="Name" (
  127.         echo.    显卡  名称: %%b>>wmic硬件信息gfd.txt)
  128.     IF /I "%%a"=="VideoModeDescription" (
  129.         echo.    当前分辨率: %%b>>wmic硬件信息gfd.txt
  130.         echo ---------------------------->>wmic硬件信息gfd.txt)
  131. )
  132. echo. >>wmic硬件信息gfd.txt
  133. echo. >>wmic硬件信息gfd.txt
  134. echo BIOS:>>wmic硬件信息gfd.txt
  135. echo     制  造  商:%Manufacturer%>>wmic硬件信息gfd.txt
  136. echo     名      称:%NameB%>>wmic硬件信息gfd.txt
  137. echo     版      本:%VersionB%>>wmic硬件信息gfd.txt
  138. echo     BIOS  版本:%BIOSVersion%>>wmic硬件信息gfd.txt
  139. echo     SMBIOS版本:%SMBIOSBIOSVersion%>>wmic硬件信息gfd.txt
  140. echo     固件  日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日>>wmic硬件信息gfd.txt
  141. echo     序  列  号:%SerialNumberB%>>wmic硬件信息gfd.txt
  142. echo   ****************************************页尾****************************************>>wmic硬件信息gfd.txt
复制代码
1

评分人数

    • 77七: 感谢分享技术 + 1

加 nvme 识别
newswan 发表于 2024-1-17 20:52



    纯新手,可不可以弄个完整版的呀,这个不会用

TOP

正找这个呢,楼主辛苦了,感谢分享!

TOP

运行环境,收集局域网内所有电脑配置(批处理放置在共享文件夹内,双击运行之后把生成的电脑配置文件复制到共享文件夹内。)(问题,按任意键保存时批处理不自动关闭。麻烦给修改一下。)
  1. @echo off&setlocal enabledelayedexpansion&title gfd硬件检测_5.3
  2. REM 日期时间
  3. for /f "tokens=1* delims=:=" %%a in ('"wmic os Get Caption,InstallDate,OSArchitecture,Version /value"') do (
  4.     IF /I "%%a"=="Caption" set Caption=%%b
  5.     IF /I "%%a"=="InstallDate" set InstallDate=%%b
  6.     IF /I "%%a"=="OSArchitecture" set OSArchitecture=%%b
  7.     IF /I "%%a"=="Version" set Version=%%b
  8. )
  9. echo 信息提取时间:%date%      时间 %Time%
  10. echo Windows_信息:%Caption% %Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  11. echo.
  12. REM 产品 csproduct
  13. for /f "tokens=1* delims==" %%a in ('"wmic csproduct Get IdentifyingNumber,Name,Vendor,Version /value"') do (
  14.     IF /I "%%a"=="IdentifyingNumber" set IdenCS=%%b
  15.     IF /I "%%a"=="Name" set NameCS=%%b
  16.     IF /I "%%a"=="Vendor" set VendCS=%%b
  17.     IF /I "%%a"=="Version" set VersCS=%%b
  18. )
  19. REM 主板 baseboard
  20. for /f "tokens=1* delims=:=" %%i in ('"wmic baseboard get Manufacturer,Product,SerialNumber /value"') do (
  21.     IF /I "%%i"=="Manufacturer" set ManuZB=%%j
  22.     IF /I "%%i"=="Product" set ProdZB=%%j
  23.     IF /I "%%i"=="SerialNumber" set SeriZB=%%j
  24. )
  25. REM 系统管理 ComputerSystem
  26. for /f "tokens=1* delims=:=" %%i in ('"wmic ComputerSystem get Manufacturer,SystemFamily,SystemSKUNumber /value"') do (
  27.     IF /I "%%i"=="Manufacturer" set ManuSY=%%j
  28.     IF /I "%%i"=="SystemFamily" set FamiSY=%%j
  29.     IF /I "%%i"=="SystemSKUNumber" set SKUNSY=%%j
  30. )
  31. echo 计算机名: %computername%
  32. echo 主板出厂日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  33. echo 主板型号:%ManuZB%  %ProdZB%  序列号:%SeriZB%
  34. REM 处理器
  35. for /f "tokens=2 delims==" %%a in ('"wmic cpu Get DeviceID /value"') do set /a CPUQuantity+=1
  36. for /f "tokens=1* delims==" %%a in ('"wmic cpu Get MaxClockSpeed,Name,NumberOfCores,NumberOfLogicalProcessors /value"') do (
  37.     IF /I "%%a"=="MaxClockSpeed" set MaxClockSpeed=%%b
  38.     IF /I "%%a"=="Name" set NameC=%%b
  39.     IF /I "%%a"=="NumberOfCores" set NumberOfCores=%%b
  40.     IF /I "%%a"=="NumberOfLogicalProcessors" set NumberOfLogicalProcessors=%%b
  41. )
  42. echo CPU :【%CPUQuantity% 颗】
  43. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】
  44. REM 内存
  45. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Tag /value"') do set /a MemoryQuantity+=1
  46. for /f "tokens=2 delims==" %%a in ('"wmic memorychip Get Capacity /value"') do (
  47.     set Capacity=%%a
  48.     set /a NCG=!Capacity:~,-7!/1073
  49.     set /a m+=!NCG!
  50. )
  51. for /f "tokens=1* delims==" %%a in ('"wmic memorychip where Tag='Physical Memory 0' Get ConfiguredClockSpeed /value"') do (
  52.     IF /I "%%a"=="ConfiguredClockSpeed" set ConfiguredClockSpeed=%%b
  53. )
  54. echo 内存:【%MemoryQuantity% 条】
  55. echo     总容量:!m! GB  【当前频率:%ConfiguredClockSpeed% MHz】
  56. echo     ----------------------------
  57. for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
  58.     IF /I "%%a"=="Capacity" (
  59.         set Capacity=%%b
  60.         set /a NCG=!Capacity:~,-7!/1073
  61.         set /a NC+=1
  62.         echo.          内存!NC! :%NCG% GB)
  63.     IF /I "%%a"=="Manufacturer" (
  64.         echo.        品    牌:%%b)
  65.     IF /I "%%a"=="SerialNumber" (
  66.         echo.        序 列 号:%%b)
  67.     IF /I "%%a"=="Speed" (
  68.         echo.        最高频率:%%b
  69.         echo     ----------------------------)
  70. )
  71. echo.&echo.
  72. REM 硬盘
  73. for /f "tokens=2 delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Caption /value"') do set /a DiskQuantity+=1
  74. echo 硬盘:【%DiskQuantity% 块】
  75. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
  76.     IF /I "%%a"=="Model" (
  77.         set /a YP+=1
  78.         echo.    硬盘 !YP!:%%b)
  79.     IF /I "%%a"=="SerialNumber" (
  80.         echo.    序列号:%%b)
  81.     IF /I "%%a"=="Size" (
  82.         set Size=%%b
  83.         echo.    容  量:!Size:~,-10! GB
  84.         echo     ----------------------------)
  85. )
  86. echo.&echo.
  87. REM BIOS
  88. for /f "tokens=1* delims=:=" %%a in ('"wmic bios Get BIOSVersion,Manufacturer,Name,ReleaseDate,SerialNumber,SMBIOSBIOSVersion,Version /value"') do (
  89.     IF /I "%%a"=="ReleaseDate" set ReleaseDate=%%b
  90.     IF /I "%%a"=="SerialNumber" set SeriBI=%%b
  91.     IF /I "%%a"=="Manufacturer" set ManuBI=%%b
  92.     IF /I "%%a"=="Name" set NameBI=%%b
  93.     IF /I "%%a"=="Version" set VersBI=%%b
  94.     IF /I "%%a"=="BIOSVersion" set BIOSVersion=%%b
  95.     IF /I "%%a"=="SMBIOSBIOSVersion" set SMBIOSBIOSVersion=%%b
  96. )
  97. echo.
  98. echo 信息提取完成,按任意键保存到文本中。
  99. pause>nul
  100. REM ==========保存信息到文件中,如果不需要,删除下面所有==========
  101. set dept=部门名-测试名
  102. (echo 信息提取时间:%date%      时间 %Time%
  103. echo Windows_信息:%Caption% %Version% 【%OSArchitecture%】 安装日期:%InstallDate:~0,4%年%InstallDate:~4,2%月%InstallDate:~6,2%日_%InstallDate:~8,2%点%InstallDate:~10,2%分%InstallDate:~12,2%秒
  104. echo.
  105. echo 计算机名: %computername%
  106. echo 主板出厂日期:%ReleaseDate:~0,4%年%ReleaseDate:~4,2%月%ReleaseDate:~6,2%日
  107. echo 主板型号:%ManuZB%  %ProdZB%  序列号:%SeriZB%
  108. echo.)>>"!dept!-%computername%.txt"
  109. echo CPU :【%CPUQuantity% 颗】>>"!dept!-%computername%.txt"
  110. echo     名  称:%NameC%【%NumberOfCores%核%NumberOfLogicalProcessors%线程】>>"!dept!-%computername%.txt"
  111. echo.>>"!dept!-%computername%.txt"
  112. echo 内存:【%MemoryQuantity% 条】>>"!dept!-%computername%.txt"
  113. echo     总容量:%m% GB  【当前频率:%ConfiguredClockSpeed% MHz】>>"!dept!-%computername%.txt"
  114. echo     ---------------------------->>"!dept!-%computername%.txt"
  115. for /f "tokens=1* delims==" %%a in ('"wmic memorychip Get Capacity,Manufacturer,SerialNumber,Speed /value"') do (
  116.     IF /I "%%a"=="Capacity" (
  117.         set CapaTXT=%%b
  118.         set /a NCG=!CapaTXT:~,-7!/1073
  119.         set /a NCTXT+=1
  120.         echo.          内存!NCTXT! :%NCG% GB>>"!dept!-%computername%.txt")
  121.     IF /I "%%a"=="Manufacturer" (
  122.         echo.        品    牌:%%b>>"!dept!-%computername%.txt")
  123.     IF /I "%%a"=="SerialNumber" (
  124.         echo.        序 列 号:%%b>>"!dept!-%computername%.txt")
  125.     IF /I "%%a"=="Speed" (
  126.         echo.        最高频率:%%b>>"!dept!-%computername%.txt"
  127.         echo     ---------------------------->>"!dept!-%computername%.txt"))
  128. (echo.
  129. echo 硬盘:【%DiskQuantity% 块】)>>"!dept!-%computername%.txt"
  130. for /f "tokens=1* delims==" %%a in ('"wmic DiskDrive where MediaType='Fixed hard disk media' Get Model,SerialNumber,Size /value"') do (
  131.     IF /I "%%a"=="Model" (
  132.         set /a YPTXT+=1
  133.         echo.    硬盘 !YPTXT!:%%b>>"!dept!-%computername%.txt")
  134.     IF /I "%%a"=="SerialNumber" (
  135.         echo.    序列号:%%b>>"!dept!-%computername%.txt")
  136.     IF /I "%%a"=="Size" (
  137.         set Size=%%b
  138.         echo.    容  量:!Size:~,-10! GB>>"!dept!-%computername%.txt"
  139.         echo     ---------------------------->>"!dept!-%computername%.txt"))
  140. (echo.
  141. echo   ****************************************页尾****************************************
  142. )>>"!dept!-%computername%.txt"
  143. xcopy /s /y c:\windows\%dept%-%computername%.txt \\win2008r2\硬件信息\
  144. echo.&echo 已保存,稍后自动退出。&echo.
  145. timeout /T 3 >nul
复制代码

TOP

回复 18# newswan


    谢谢,我学习学习。

TOP

  1. function Get_CurrentDateTime() {
  2. [void]$info.add( "信息提取时间:" + (Get-Date).ToString('yyyy-MM-dd HH:mm:ss') )
  3. [void]$info.add( "" )
  4. }
  5. # 获取操作系统信息
  6. function Get_Info_system() {
  7. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  8. [void]$info.add( "OS:" )
  9. [void]$info.add( "    Name      :$( $osInfo.Caption ) 【 $( $osInfo.OSArchitecture ) 】" )
  10. [void]$info.add( "    Version   :$( $osInfo.Version )" )
  11. [void]$info.add( "    安装日期  :$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )" )
  12. [void]$info.add( "    BIOS Mode : $env:firmware_type" )
  13. [void]$info.add( "" )
  14. }
  15. # 获取产品信息
  16. function Get_Info_Product() {
  17. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  18. [void]$info.add( "产品:" )
  19. [void]$info.add( "    供应商:" + $productInfo.Vendor )
  20. [void]$info.add( "    系列  :" + $productInfo.Name )
  21. [void]$info.add( "    型号  :" + $productInfo.Version )
  22. [void]$info.add( "    序列号:" + $productInfo.IdentifyingNumber )
  23. [void]$info.add( "" )
  24. }
  25. # 获取主板信息
  26. function Get_Info_BaseBoard() {
  27. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  28. [void]$info.add( "主板:" )
  29. [void]$info.add( "    制造商:" + $baseboardInfo.Manufacturer )
  30. [void]$info.add( "    产品  :" + $baseboardInfo.Product )
  31. [void]$info.add( "    序列号:" + $baseboardInfo.SerialNumber )
  32. [void]$info.add( "" )
  33. }
  34. # 获取处理器信息
  35. function Get_Info_Processor() {
  36. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  37. [void]$info.add( "CPU :【 $( ($processorInfo | Measure-Object).Count ) 】" )
  38. foreach ($processor in $processorInfo) {
  39. [void]$info.add( "    名称: $( $processor.Name ) 【 $( $processor.NumberOfCores ) 核 $( $processor.NumberOfLogicalProcessors ) 线程 】" )
  40. [void]$info.add( "    主频:" + $processor.MaxClockSpeed )
  41. }
  42. [void]$info.add( "" )
  43. }
  44. # 获取内存信息
  45. function Get_Info_Memory() {
  46. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  47. [void]$info.add( "内存:【 $( ($memoryInfo | Measure-Object).Count ) 】" )
  48. [void]$info.add( "    总容量: {0} GB" -f $( ( $memoryInfo | Measure-Object -Property Capacity -Sum ).Sum / 1GB ) )
  49. foreach ($memory in $memoryInfo) {
  50. #$( $memory.BankLabel )
  51. [void]$info.add( "    #   插槽    : $( $memory.DeviceLocator )" )
  52. [void]$info.add( "        品牌    : $( $memory.Manufacturer )" )
  53. [void]$info.add( "        序列号  : $( $memory.SerialNumber )" )
  54. [void]$info.add( "        容量    : $( $memory.Capacity / 1GB ) GB" )
  55. [void]$info.add( "        最高频率: $( $memory.Speed )" )
  56. }
  57. [void]$info.add( "" )
  58. }
  59. # 获取硬盘信息
  60. function Get_Info_Disk() {
  61. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  62. foreach ($disk in $diskInfo) {
  63. $physicalDisk = Get-PhysicalDisk | Where-Object { ('\\.\PHYSICALDRIVE' + $_.DeviceID ) -eq $disk.DeviceID }
  64. Add-Member -InputObject $disk -MemberType NoteProperty -Name BusType -Value $physicalDisk.BusType
  65. }
  66. [void]$info.add( "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 】" )
  67. foreach ($disk in $diskInfo) {
  68. [void]$info.add( "    #   DeviceID: $( $disk.DeviceID )" )
  69. [void]$info.add( "        BusType : $( $disk.BusType )" )
  70. [void]$info.add( "        型号    : $( $disk.Model )" )
  71. [void]$info.add( "        序列号  : $( $disk.SerialNumber )" )
  72. [void]$info.add( "        容量    : $( [int]($disk.Size / 1GB) ) GB" )
  73. }
  74. [void]$info.add( "" )
  75. }
  76. # 获取显示信息
  77. function Get_Info_Video() {
  78. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  79. [void]$info.add( "显示适配器:" )
  80. foreach ($video in $videoInfo) {
  81. [void]$info.add( "    #   名称      : " + $video.Name )
  82. [void]$info.add( "        显存      : " + $( $video.AdapterRAM / 1GB ) + " GB" )
  83. [void]$info.add( "        当前刷新率: " + $video.CurrentRefreshRate )
  84. [void]$info.add( "        最高刷新率: " + $video.MaxRefreshRate )
  85. [void]$info.add( "        当前分辨率: " + $video.VideoModeDescription )
  86. }
  87. [void]$info.add( "" )
  88. }
  89. # 获取网卡信息
  90. function Get_Info_NetAdapter() {
  91. $nicInfo = Get-NetAdapter -Physical
  92. [void]$info.add( "网络适配器:【 $( ($nicInfo | Measure-Object).Count ) 】" )
  93. foreach ( $nic in $nicInfo ) {
  94. [void]$info.add( "    #   名称      : $( $nic.DriverDescription )" )
  95. [void]$info.add( "        MacAddress: $( $nic.MacAddress )" )
  96. }
  97. [void]$info.add( "" )
  98. }
  99. # 获取BIOS信息
  100. function Get_Info_BIOS() {
  101. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  102. [void]$info.add( "BIOS:" )
  103. [void]$info.add( "    制造商    : " + $biosInfo.Manufacturer )
  104. [void]$info.add( "    名称      : " + $biosInfo.Name )
  105. [void]$info.add( "    版本      : " + $biosInfo.Version )
  106. [void]$info.add( "    BIOS  版本: " + $biosInfo.BIOSVersion )
  107. [void]$info.add( "    SMBIOS版本: " + $biosInfo.SMBIOSBIOSVersion )
  108. [void]$info.add( "    固件日期  : " + $biosInfo.ReleaseDate.ToString('yyyy-MM-dd') )
  109. [void]$info.add( "    序列号    : " + $biosInfo.SerialNumber )
  110. [void]$info.add( "" )
  111. }
  112. $info = [System.Collections.ArrayList]@()
  113. Get_CurrentDateTime
  114. Get_Info_system
  115. Get_Info_Product
  116. Get_Info_BaseBoard
  117. Get_Info_BIOS
  118. Get_Info_Processor
  119. Get_Info_Memory
  120. Get_Info_Disk
  121. Get_Info_NetAdapter
  122. Get_Info_Video
  123. $info | Out-File "info.txt"
  124. pause
复制代码

TOP

可以保存文件,其他有空了再来

TOP

  1. function Get_CurrentDateTime() {
  2. $str = [System.Collections.ArrayList]@()
  3. $str += "信息提取时间:"  + (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
  4. $str += ""
  5. return $str
  6. }
  7. # 获取操作系统信息
  8. function Get_Info_system() {
  9. $str = [System.Collections.ArrayList]@()
  10. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  11. $str += "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
  12. $str += "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
  13. $str += ""
  14. return $str
  15. }
  16. # 获取产品信息
  17. function Get_Info_Product() {
  18. $str = [System.Collections.ArrayList]@()
  19. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  20. $str += "产品:"
  21. $str += "    供应商:" + $productInfo.Vendor
  22. $str += "    系  列:" + $productInfo.Name
  23. $str += "    型  号:" + $productInfo.Version
  24. $str += "    序列号:" + $productInfo.IdentifyingNumber
  25. $str += ""
  26. return $str
  27. }
  28. # 获取主板信息
  29. function Get_Info_BaseBoard() {
  30. $str = [System.Collections.ArrayList]@()
  31. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  32. $str += "主板:"
  33. $str += "    制造商:" + $baseboardInfo.Manufacturer
  34. $str += "    产  品:" + $baseboardInfo.Product
  35. $str += "    序列号:" + $baseboardInfo.SerialNumber
  36. $str += ""
  37. return $str
  38. }
  39. # 获取处理器信息
  40. function Get_Info_Processor() {
  41. $str = [System.Collections.ArrayList]@()
  42. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  43. $str += "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
  44. foreach ($processor in $processorInfo) {
  45. $str += "    名  称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
  46. $str += "    主  频:" + $processor.MaxClockSpeed
  47. }
  48. $str += ""
  49. return $str
  50. }
  51. # 获取内存信息
  52. function Get_Info_Memory() {
  53. $str = [System.Collections.ArrayList]@()
  54. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  55. $str += "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
  56. $str += "    总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
  57. foreach ($memory in $memoryInfo) {
  58. $str += "    内存: $($memory.Capacity / 1GB) GB"
  59. $str += "        品    牌: $($memory.Manufacturer)"
  60. $str += "        序 列 号: $($memory.SerialNumber)"
  61. $str += "        最高频率: $($memory.Speed)"
  62. }
  63. $str += ""
  64. return $str
  65. }
  66. # 获取硬盘信息
  67. function Get_Info_Disk() {
  68. $str = [System.Collections.ArrayList]@()
  69. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  70. foreach ($disk in $diskInfo) {
  71. $physicalDisk = Get-PhysicalDisk | Where-Object { $_.DeviceID -eq $disk.DeviceID.Substring(17) }
  72. Add-Member -InputObject $disk -MemberType NoteProperty -Name BusType -Value $physicalDisk.BusType
  73. }
  74. $str += "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
  75. foreach ($disk in $diskInfo) {
  76. $str += "    DeviceID: $($DeviceID)"
  77. $str += "    BusType: $($BusType)"
  78. $str += "    硬  盘: $($disk.Model)"
  79. $str += "    序列号: $($disk.SerialNumber)"
  80. $str += "    容  量: $($disk.Size / 1GB) GB"
  81. }
  82. $str += ""
  83. return $str
  84. }
  85. # 获取显示信息
  86. function Get_Info_Video() {
  87. $str = [System.Collections.ArrayList]@()
  88. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  89. $str += "显示:"
  90. foreach ($video in $videoInfo) {
  91. $str += "    当前刷新率: " + $video.CurrentRefreshRate
  92. $str += "    最高刷新率: " + $video.MaxRefreshRate
  93. $str += "    显卡  名称: " + $video.Name
  94. $str += "    当前分辨率: " + $video.VideoModeDescription
  95. }
  96. $str += ""
  97. return $str
  98. }
  99. # 获取BIOS信息
  100. function Get_Info_BIOS() {
  101. $str = [System.Collections.ArrayList]@()
  102. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  103. $str += "BIOS:"
  104. $str += "    制  造  商: " + $biosInfo.Manufacturer
  105. $str += "    名      称: " + $biosInfo.Name
  106. $str += "    版      本: " + $biosInfo.Version
  107. $str += "    BIOS  版本: " + $biosInfo.BIOSVersion
  108. $str += "    SMBIOS版本: " + $biosInfo.SMBIOSBIOSVersion
  109. $str += "    固件  日期: " + $biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
  110. $str += "    序  列  号: " + $biosInfo.SerialNumber
  111. $str += ""
  112. return $str
  113. }
  114. $info = [System.Collections.ArrayList]@()
  115. $info += Get_CurrentDateTime
  116. $info += Get_Info_system
  117. $info += Get_Info_Product
  118. $info += Get_Info_BaseBoard
  119. $info += Get_Info_BIOS
  120. $info += Get_Info_Processor
  121. $info += Get_Info_Memory
  122. $info += Get_Info_Disk
  123. $info += Get_Info_Video
  124. $info | Out-File "info.txt"
  125. pause
复制代码

TOP

加 nvme 识别
  1. Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
  2. Write-Host ""
  3. # 获取操作系统信息
  4. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  5. Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
  6. Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
  7. Write-Host ""
  8. # 获取产品信息
  9. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  10. Write-Host "产品:"
  11. Write-Host "    供应商:" $productInfo.Vendor
  12. Write-Host "    系  列:" $productInfo.Name
  13. Write-Host "    型  号:" $productInfo.Version
  14. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  15. Write-Host ""
  16. # 获取主板信息
  17. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  18. Write-Host "主板:"
  19. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  20. Write-Host "    产  品:" $baseboardInfo.Product
  21. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  22. Write-Host ""
  23. # 获取处理器信息
  24. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  25. Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
  26. foreach ($processor in $processorInfo) {
  27.     Write-Host "    名  称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
  28.     Write-Host "    主  频:" $processor.MaxClockSpeed
  29. }
  30. Write-Host ""
  31. # 获取内存信息
  32. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  33. Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
  34. Write-Host "    总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存: $($memory.Capacity / 1GB) GB"
  37.     Write-Host "        品    牌: $($memory.Manufacturer)"
  38.     Write-Host "        序 列 号: $($memory.SerialNumber)"
  39.     Write-Host "        最高频率: $($memory.Speed)"
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. foreach ($disk in $diskInfo) {
  45.     $physicalDisk = Get-PhysicalDisk | Where-Object { $_.DeviceID -eq $disk.DeviceID.Substring(17) }
  46.     Add-Member -InputObject $disk -MemberType NoteProperty -Name BusType -Value $physicalDisk.BusType
  47. }
  48. Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
  49. foreach ($disk in $diskInfo) {
  50.     Write-Host "    BusType: $($BusType)"
  51.     Write-Host "    硬  盘: $($disk.Model)"
  52.     Write-Host "    序列号: $($disk.SerialNumber)"
  53.     Write-Host "    容  量: $($disk.Size / 1GB) GB"
  54. }
  55. Write-Host ""
  56. # 获取显示信息
  57. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  58. Write-Host "显示:"
  59. foreach ($video in $videoInfo) {
  60.     Write-Host "    当前刷新率: "$video.CurrentRefreshRate
  61.     Write-Host "    最高刷新率: "$video.MaxRefreshRate
  62.     Write-Host "    显卡  名称: "$video.Name
  63.     Write-Host "    当前分辨率: "$video.VideoModeDescription
  64. }
  65. Write-Host ""
  66. # 获取BIOS信息
  67. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  68. Write-Host "BIOS:"
  69. Write-Host "    制  造  商: "$biosInfo.Manufacturer
  70. Write-Host "    名      称: "$biosInfo.Name
  71. Write-Host "    版      本: "$biosInfo.Version
  72. Write-Host "    BIOS  版本: "$biosInfo.BIOSVersion
  73. Write-Host "    SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
  74. Write-Host "    固件  日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
  75. Write-Host "    序  列  号: "$biosInfo.SerialNumber
  76. Write-Host ""
  77. pause
复制代码

TOP

本帖最后由 gfd 于 2024-1-17 20:26 编辑

回复 12# newswan


    很好。
获取时间比批处理慢一些。
内存和硬盘不显示序列号(硬盘1、硬盘2……)再加上判定硬盘机械?固态?
能不能获取显卡显存容量(cmd显存最大4G),还有显示器品牌型号的信息
怎么保存到文件中?

TOP

回复 12# newswan


    谢谢,我试试。

TOP

整理过的
  1. Write-Host "信息提取时间:" (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
  2. Write-Host ""
  3. # 获取操作系统信息
  4. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
  5. Write-Host "系统版本:$($osInfo.Caption) $($osInfo.Version) 【 $($osInfo.OSArchitecture) 】"
  6. Write-Host "安装日期:$( $osInfo.InstallDate.ToString('yyyy-MM-dd') )"
  7. Write-Host ""
  8. # 获取产品信息
  9. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct
  10. Write-Host "产品:"
  11. Write-Host "    供应商:" $productInfo.Vendor
  12. Write-Host "    系  列:" $productInfo.Name
  13. Write-Host "    型  号:" $productInfo.Version
  14. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  15. Write-Host ""
  16. # 获取主板信息
  17. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard
  18. Write-Host "主板:"
  19. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  20. Write-Host "    产  品:" $baseboardInfo.Product
  21. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  22. Write-Host ""
  23. # 获取处理器信息
  24. $processorInfo = Get-CimInstance -ClassName Win32_Processor
  25. Write-Host "CPU :【 $( ($processorInfo | Measure-Object).Count ) 颗 】"
  26. foreach ($processor in $processorInfo) {
  27.     Write-Host "    名  称: $($processor.Name) 【 $($processor.NumberOfCores) 核 $($processor.NumberOfLogicalProcessors) 线程 】"
  28.     Write-Host "    主  频:" $processor.MaxClockSpeed
  29. }
  30. Write-Host ""
  31. # 获取内存信息
  32. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  33. Write-Host "内存:【 $( ($memoryInfo | Measure-Object).Count ) 条 】"
  34. Write-Host "    总容量: $(($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB) GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存: $($memory.Capacity / 1GB) GB"
  37.     Write-Host "        品    牌: $($memory.Manufacturer)"
  38.     Write-Host "        序 列 号: $($memory.SerialNumber)"
  39.     Write-Host "        最高频率: $($memory.Speed)"
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. Write-Host "硬盘:【 $( ($diskInfo | Measure-Object).Count ) 块 】"
  45. foreach ($disk in $diskInfo) {
  46.     Write-Host "    硬盘: $($disk.Model)"
  47.     Write-Host "    序列号: $($disk.SerialNumber)"
  48.     Write-Host "    容  量: $($disk.Size / 1GB) GB"
  49. }
  50. Write-Host ""
  51. # 获取显示信息
  52. $videoInfo = Get-CimInstance -ClassName Win32_VideoController
  53. Write-Host "显示:"
  54. foreach ($video in $videoInfo) {
  55.     Write-Host "    当前刷新率: "$video.CurrentRefreshRate
  56.     Write-Host "    最高刷新率: "$video.MaxRefreshRate
  57.     Write-Host "    显卡  名称: "$video.Name
  58.     Write-Host "    当前分辨率: "$video.VideoModeDescription
  59. }
  60. Write-Host ""
  61. # 获取BIOS信息
  62. $biosInfo = Get-CimInstance -ClassName Win32_BIOS
  63. Write-Host "BIOS:"
  64. Write-Host "    制  造  商: "$biosInfo.Manufacturer
  65. Write-Host "    名      称: "$biosInfo.Name
  66. Write-Host "    版      本: "$biosInfo.Version
  67. Write-Host "    BIOS  版本: "$biosInfo.BIOSVersion
  68. Write-Host "    SMBIOS版本: "$biosInfo.SMBIOSBIOSVersion
  69. Write-Host "    固件  日期: "$biosInfo.ReleaseDate.ToString('yyyy-MM-dd')
  70. Write-Host "    序  列  号: "$biosInfo.SerialNumber
  71. Write-Host ""
  72. pause
复制代码

TOP

上面的是 ai 改写的

TOP

  1. # 获取操作系统信息
  2. $osInfo = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, InstallDate, OSArchitecture, Version
  3. $osInfo.InstallDate = $osInfo.InstallDate.ToString("yyyyMMddHHmmss")
  4. Write-Host "信息提取时间:" (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
  5. Write-Host "Windows_信息:" ($osInfo.Caption + $osInfo.Version) + " 【" + $osInfo.OSArchitecture + "】 安装日期:" + $osInfo.InstallDate.Substring(0, 4) + "年" + $osInfo.InstallDate.Substring(4, 2) + "月" + $osInfo.InstallDate.Substring(6, 2) + "日_" + $osInfo.InstallDate.Substring(8, 2) + "点" + $osInfo.InstallDate.Substring(10, 2) + "分" + $osInfo.InstallDate.Substring(12, 2) + "秒"
  6. Write-Host ""
  7. # 获取产品信息
  8. $productInfo = Get-CimInstance -ClassName Win32_ComputerSystemProduct | Select-Object IdentifyingNumber, Name, Vendor, Version
  9. Write-Host "产品:"
  10. Write-Host "    供应商:" $productInfo.Vendor
  11. Write-Host "    系  列:" $productInfo.Name
  12. Write-Host "    型  号:" $productInfo.Version
  13. Write-Host "    序列号:" $productInfo.IdentifyingNumber
  14. Write-Host ""
  15. # 获取主板信息
  16. $baseboardInfo = Get-CimInstance -ClassName Win32_BaseBoard | Select-Object Manufacturer, Product, SerialNumber
  17. Write-Host "主板:"
  18. Write-Host "    制造商:" $baseboardInfo.Manufacturer
  19. Write-Host "    产  品:" $baseboardInfo.Product
  20. Write-Host "    序列号:" $baseboardInfo.SerialNumber
  21. Write-Host ""
  22. # 获取处理器信息
  23. $processorInfo = Get-CimInstance -ClassName Win32_Processor | Select-Object Name, MaxClockSpeed, NumberOfCores, NumberOfLogicalProcessors
  24. Write-Host "CPU :【" + ($processorInfo.Count) + " 颗】"
  25. foreach ($processor in $processorInfo) {
  26.     Write-Host "    名  称:" $processor.Name + "【" + $processor.NumberOfCores + "核" + $processor.NumberOfLogicalProcessors + "线程】"
  27.     Write-Host "    主  频:" $processor.MaxClockSpeed
  28. }
  29. Write-Host ""
  30. # 获取内存信息
  31. $memoryInfo = Get-CimInstance -ClassName Win32_PhysicalMemory
  32. Write-Host "内存:【" + ($memoryInfo.Count) + " 条】"
  33. $totalMemory = ($memoryInfo | Measure-Object -Property Capacity -Sum).Sum / 1GB
  34. Write-Host "    总容量:" $totalMemory "GB"
  35. foreach ($memory in $memoryInfo) {
  36.     Write-Host "    内存:" ($memory.Capacity / 1GB) "GB"
  37.     Write-Host "        品    牌:" $memory.Manufacturer
  38.     Write-Host "        序 列 号:" $memory.SerialNumber
  39.     Write-Host "        最高频率:" $memory.Speed
  40. }
  41. Write-Host ""
  42. # 获取硬盘信息
  43. $diskInfo = Get-CimInstance -ClassName Win32_DiskDrive | Where-Object { $_.MediaType -eq 'Fixed hard disk media' }
  44. Write-Host "硬盘:【" + ($diskInfo.Count) + " 块】"
  45. foreach ($disk in $diskInfo) {
  46.     Write-Host "    硬盘:" $disk.Model
  47.     Write-Host "    序列号:" $disk.SerialNumber
  48.     Write-Host "    容  量:" ($disk.Size / 1GB) "GB"
  49. }
  50. Write-Host ""
  51. # 获取显示信息
  52. $videoInfo = Get-CimInstance -ClassName Win32_VideoController | Select-Object CurrentRefreshRate, MaxRefreshRate, Name, VideoModeDescription
  53. Write-Host "显示:"
  54. foreach ($video in $videoInfo) {
  55.     Write-Host "    当前刷新率:" $video.CurrentRefreshRate
  56.     Write-Host "    最高刷新率:" $video.MaxRefreshRate
  57.     Write-Host "    显卡  名称:" $video.Name
  58.     Write-Host "    当前分辨率:" $video.VideoModeDescription
  59. }
  60. Write-Host ""
  61. # 获取BIOS信息
  62. $biosInfo = Get-CimInstance -ClassName Win32_BIOS | Select-Object BIOSVersion, Manufacturer, Name, ReleaseDate, SerialNumber, SMBIOSBIOSVersion, Version
  63. $biosInfo.ReleaseDate = $biosInfo.ReleaseDate.ToString("yyyyMMdd")
  64. Write-Host "BIOS:"
  65. Write-Host "    制  造  商:" $biosInfo.Manufacturer
  66. Write-Host "    名      称:" $biosInfo.Name
  67. Write-Host "    版      本:" $biosInfo.Version
  68. Write-Host "    BIOS  版本:" $biosInfo.BIOSVersion
  69. Write-Host "    SMBIOS版本:" $biosInfo.SMBIOSBIOSVersion
  70. Write-Host "    固件  日期:" $biosInfo.ReleaseDate.Substring(0, 4) + "年" + $biosInfo.ReleaseDate.Substring(4, 2) + "月" + $biosInfo.ReleaseDate.Substring(6, 2) + "日"
  71. Write-Host "    序  列  号:" $biosInfo.SerialNumber
复制代码

TOP

  1. PowerShell脚本相对于批处理脚本具有许多优势和劣势。
  2. 优势:
  3. 强大的对象模型:PowerShell是基于对象的脚本语言,可以轻松地处理和操作对象,而不仅仅是文本流。
  4. 内置的.NET集成:PowerShell可以直接访问.NET Framework,因此可以利用.NET库中的丰富功能。
  5. 更丰富的功能:PowerShell具有更多的内置功能和命令,可以更轻松地执行系统管理任务。
  6. 更好的错误处理:PowerShell提供了更强大的错误处理和调试功能,使得编写和调试脚本更加容易。
  7. 更好的安全性:PowerShell具有更多的安全功能和策略,可以更好地控制脚本的执行和访问权限。
  8. 劣势:
  9. 学习曲线:对于习惯了批处理脚本的用户来说,学习PowerShell可能需要一些时间。
  10. 兼容性:某些较旧的Windows系统可能不支持PowerShell,因此在这些系统上可能无法运行PowerShell脚本。
  11. 执行速度:相对于简单的批处理脚本,PowerShell脚本可能会有更长的启动时间和执行时间。
  12. 总的来说,PowerShell脚本在系统管理和自动化方面具有更多的优势,但对于简单的任务和较旧的系统,批处理脚本可能仍然是一个更简单和直接的选择。
复制代码

TOP

返回列表