欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PowerShell 获取系统信息的函数

程序员文章站 2022-07-04 23:35:08
复制代码 代码如下:function get-systeminfo{  param($computername = $env:computername) &nb...

复制代码 代码如下:

function get-systeminfo
{
  param($computername = $env:computername)

  $header = 'hostname','osname','osversion','osmanufacturer','osconfiguration','os build type','registeredowner','registeredorganization','product id','original install date','system boot time','system manufacturer','system model','system type','processor(s)','bios version','windows directory','system directory','boot device','system locale','input locale','time zone','total physical memory','available physical memory','virtual memory: max size','virtual memory: available','virtual memory: in use','page file location(s)','domain','logon server','hotfix(s)','network card(s)'

  systeminfo.exe /fo csv /s $computername |
    select-object -skip 1 |
    convertfrom-csv -header $header
}



运行结果:

PowerShell 获取系统信息的函数
你可以把结果存在变量中,这样你可以轻松的访问里面的信息
PowerShell 获取系统信息的函数