当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

作者:精品下载站 日期:2024-12-14 07:19:01 浏览:13 分类:玩电脑

PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境


Systeminfo 为您提供系统的完美概览。但是您域中的其他系统又如何呢?当然,您可以使用第 3 方工具或 SCCM。但无法使用企业软件的人数比您想象的要多。在本文中,我将介绍如何在不使用第 3 方工具的情况下在所有客户端计算机上运行 systeminfo。

什么是系统信息?

打开 PowerShell。输入系统信息。

systeminfo

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

接下来,目标是获取所有域计算机的有用信息。

在所有域计算机上运行 systeminfo

以域管理员组成员的身份登录域。运行以下命令:

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV}} | ConvertFrom-Csv | Out-GridView

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

这将使您对您的环境有一个完美的概览。但我们面临两个问题。那些红色的不是好东西?

问题1

如果出现错误,则表明您的工作站或服务器之一没有响应。原因可能是多方面的。计算机可能已关闭。

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

为了避免这种情况,请使用参数 -ErrorAction SilentlyContinue 运行 Foreach-Object。

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV} -ErrorAction SilentlyContinue} | ConvertFrom-Csv | Out-GridView

问题2

现在让我们解决下一个问题。让我们删除烦人的标题行。我们只希望所有计算机都有一个标头。

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

要删除多个标头,请运行

(Get-ADComputer -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {systeminfo /FO CSV} -ErrorAction SilentlyContinue | Select-Object -Skip 1} | ConvertFrom-Csv -Header "Host Name","OS","Version","Manufacturer","Configuration","Build Type","Registered Owner","Registered Organization","Product ID","Install Date","Boot Time","System Manufacturer","Model","Type","Processor","Bios","Windows Directory","System Directory","Boot Device","Language","Keyboard","Time Zone","Total Physical Memory","Available Physical Memory","Virtual Memory","Virtual Memory Available","Virtual Memory in Use","Page File","Domain","Logon Server","Hotfix","Network Card","Hyper-V" | Out-GridView

[玩转系统] PowerShell:通过在所有域计算机上运行 systeminfo 来记录您的环境

完美的。 ?

享受记录您的系统的乐趣。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯