PowerShell 技能连载 - 改变操作系统描述

每个 Windows 操作系统都有一个描述,您可以使用以下命令查看(和更改)该描述:

1
PS> control sysdm.cpl

要通过 PowerShell 自动执行此操作,请使用以下命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
# change operating system description
# (requires admin privileges)
$values = @{
Description = 'My Computer'
}
Set-CimInstance -Query 'Select * from Win32_OperatingSystem' -Property $values

# read description
# (no admin privileges required)
$description = Get-CimInstance -ClassName Win32_OperatingSystem |
Select-Object -ExpandProperty Description

"OS Description: $description"
评论