如何使用 PowerShell 6.x 或更高版本确定当前的 macOS 版本?
How do I Determine the Current Version of macOS Using PowerShell 6.x or Newer?
在 macOS 上的 PowerShell 6.x 或更高版本 运行 中使用 PowerShell 脚本,如何以编程方式确定 macOS 的版本号?
编辑:
也许像这个答案,加上字符串解析?:
最简单的方法:
sw_vers -productVersion
10.12.6
或者用
做点什么
system_profiler SPSoftwareDataType -xml
喜欢:
[xml]$xml = system_profiler SPSoftwareDataType -xml
$xml.plist.array.dict.array.dict.string -match 'macos'
macOS 10.12.6 (16G1510)
在 macOS 上的 PowerShell 6.x 或更高版本 运行 中使用 PowerShell 脚本,如何以编程方式确定 macOS 的版本号?
编辑: 也许像这个答案,加上字符串解析?:
最简单的方法:
sw_vers -productVersion
10.12.6
或者用
做点什么system_profiler SPSoftwareDataType -xml
喜欢:
[xml]$xml = system_profiler SPSoftwareDataType -xml
$xml.plist.array.dict.array.dict.string -match 'macos'
macOS 10.12.6 (16G1510)