Powershell找到服务器操作系统 [英] Powershell to find Server Operating system
问题描述
这是一个简单的命令;希望它可以帮助别人。
请随意使用它并修改它。如果您有任何问题,请告诉我们。
这给了您所拥有的操作系统的类型。我只基于Windows Server和活动的计算机帐户进行筛选。然后按名称进行排序,并选择唯一的操作系统。
$ b $ pre $ Get-ADComputer -Filter {(OperatingSystem-like* windows * server * )和(Enabled -eqTrue))} - 属性OperatingSystem |排序名称| select -Unique OperatingSystem
输出:
OperatingSystem
---------------
Windows Server 2012 R2 Standard
Windows Server 2008 R2 Standard
Windows Server 2012 R2标准评估
Windows Server 2008 R2企业
下一个命令是获取所有的服务器,并显示其操作系统。再次,我基于Windows服务器操作系统和活动计算机帐户进行筛选。我正在通过操作系统对我的列表进行排序:
Get-ADComputer -Filter {(OperatingSystem-like* windows * server * )和(Enabled -eqTrue))} - 属性OperatingSystem |对OperatingSystem |进行排序ft DNSHostName,OperatingSystem
您也可以将上述内容保存到一个变量中,每个操作系统类别:
$ $ p $ code $ = Get-ADComputer -Filter {(OperatingSystem-like* windows * server *) - 和(已启用-eqTrue)} - 属性OperatingSystem |排序名称
$ servers | group operatingsystem
I had a task to find Operating System of all the servers we had in AD for some Microsoft Licenses requirement.
It's a simple command; hopefully, it helps someone.
Please feel free to use it and modify it. If you have questions, let me know.
This gives you the type of operating systems you have. I am filtering based on Windows Server only and computer accounts that are active. Then sort by name and select unique OS.
Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")} -Properties OperatingSystem | Sort Name | select -Unique OperatingSystem
Output:
OperatingSystem
---------------
Windows Server 2012 R2 Standard
Windows Server 2008 R2 Standard
Windows Server 2012 R2 Standard Evaluation
Windows Server 2008 R2 Enterprise
Next command is to get all the servers and show their Operating System. Again, I am filtering based on Windows server OS and Active computer accounts. I am sorting my list by Operating system:
Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")} -Properties OperatingSystem | sort OperatingSystem | ft DNSHostName, OperatingSystem
You can also save the above in a variable and then get the count of Servers in each operating system category:
$Servers = Get-ADComputer -Filter {(OperatingSystem -like "*windows*server*") -and (Enabled -eq "True")} -Properties OperatingSystem | Sort Name
$servers | group operatingsystem
这篇关于Powershell找到服务器操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!