Skip to content

Commit c569c50

Browse files
v2.45.0
1 parent c6563a3 commit c569c50

File tree

6 files changed

+88
-58
lines changed

6 files changed

+88
-58
lines changed

PSScriptTools.psd1

0 Bytes
Binary file not shown.

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,18 @@ The output has a default table view but there are other properties you might wan
388388
PS C:\> Get-WindowsVersion | Select-Object *
389389
390390
391-
ProductName : Windows 10 Pro
392-
EditionID : Professional
393-
ReleaseID : 2009
394-
Build : 19042.906
395-
Branch : vb_release
396-
InstalledUTC : 10/16/2020 3:09:01 PM
397-
Computername : PROSPERO
391+
ProductName : Microsoft Windows 11 Pro
392+
ReleaseVersion : 22H2
393+
EditionID : Professional
394+
ReleaseID : 2009
395+
Build : 22622.598
396+
Branch : ni_release
397+
InstalledUTC : 5/12/2022 1:01:53 PM
398+
Computername : WINDESK11
398399
```
399400

401+
Beginning with version 2.45.0, `Get-WindowsVersion` will use the command-line tool `systeminfo.exe` to retrieve the operating system name. If this fails, then the registry value will be used. Windows 11 systems don't yet reflect with Windows 11 name in the registry.
402+
400403
#### [Get-WindowsVersionString](docs/Get-WindowsVersionString.md)
401404

402405
This command is a variation of `Get-WindowsVersion` that returns a formatted string with version information.
@@ -483,12 +486,12 @@ This command will provide a summary of relevant information for the current user
483486
```dos
484487
PS C:\> Get-PSWho
485488
486-
User : BOVINE320\Jeff
489+
User : WINDESK11\Art
487490
Elevated : True
488-
Computername : BOVINE320
489-
OperatingSystem : Microsoft Windows 10 Pro [64-bit]
490-
OSVersion : 10.0.18363
491-
PSVersion : 5.1.18362.145
491+
Computername : WINDESK11
492+
OperatingSystem : Microsoft Windows 11 Pro [64-bit]
493+
OSVersion : 10.0.22622
494+
PSVersion : 5.1.22621.436
492495
Edition : Desktop
493496
PSHost : ConsoleHost
494497
WSMan : 3.0
@@ -2585,7 +2588,7 @@ If you find this module useful, you might also want to look at my PowerShell too
25852588
+ [Managing scheduled jobs](https://github.com/jdhitsolutions/ScheduledJobTools)
25862589
+ [Running remote commands outside of PowerShell Remoting](https://github.com/jdhitsolutions/PSRemoteOperations).
25872590
+ [Automating the PowerShell scripting process](https://github.com/jdhitsolutions/PSFunctionTools)
2588-
+ [A simple command-line task and to-do manager](https://github.com/jdhitsolutions/MyTasks)
2591+
+ [A simple command-line task and to-do manager](https://github.com/jdhitsolutions/PSWorkItem)
25892592

25902593
## Compatibility
25912594

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
This file contains the most recent change history for the PSScriptTools module.
44

5+
## v2.45.0
6+
7+
+ Fixed help typo for `Get-PSUnique` [PR 133](https://github.com/jdhitsolutions/PSScriptTools/pull/133). Thank you @fiala-sns.
8+
+ Updated `Get-WindowsVersion` to inlcude `DisplayVersion`, e.g. `22H2`.
9+
+ Modified format file `windowsversion.format.ps1xml` to replace `ReleaseID` with the `DisplayVersion` value.
10+
+ Revised `Get-WindowsVersion` to use `systeminfo` to retrieve the operating system name and if that fails, fall back to using the registry entry. The registry entry for Windows 11 typically still shows Windows 10.
11+
+ Help updates.
12+
+ Updated `README.md`.
13+
514
## v2.44.0
615

716
+ Updated `Show-ANSISequence` to fix a bug where foreground samples where included when specifying background. [Issue #130](https://github.com/jdhitsolutions/PSScriptTools/issues/130)

docs/Get-WindowsVersion.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This is a PowerShell version of the winver.exe utility. This command uses PowerS
2424

2525
If you are querying the local computer, all other parameters will be ignored.
2626

27+
This command is an alternative to using Get-CimInstance and querying the Win32_OperatingSystem.
28+
2729
## EXAMPLES
2830

2931
### EXAMPLE 1
@@ -32,11 +34,11 @@ If you are querying the local computer, all other parameters will be ignored.
3234
PS C:\>Get-WindowsVersion
3335
3436
35-
Computername: DESK109
37+
Computername: WINDESK11
3638
37-
ProductName EditionID ReleaseID Build InstalledUTC
38-
----------- --------- --------- ----- ------------
39-
Windows 10 Pro Professional 2009 19042 10/16/2020 3:09:01 PM
39+
ProductName EditionID Release Build InstalledUTC
40+
----------- --------- ------- ----- ------------
41+
Microsoft Windows 11 Pro Professional 22H2 22622 5/12/2022 1:01:53 PM
4042
```
4143

4244
Query the local host.
@@ -48,24 +50,25 @@ PS C:\> Get-WindowsVersion -Computername srv1,srv2,win10 -Credential $art
4850
4951
Computername: WIN10
5052
51-
ProductName EditionID ReleaseID Build InstalledUTC
52-
----------- --------- --------- ----- ------------
53-
Windows 10 Enterprise Enterprise 1903 18362 2/6/2020 5:28:34 PM
53+
ProductName EditionID Release Build InstalledUTC
54+
----------- --------- ------- ----- ------------
55+
Microsoft Windows 10 Enterprise 21H2 19044 8/26/2022 4:25:49 PM
56+
Enterprise
5457
5558
56-
Computername: SRV1
59+
Computername: SRV2
5760
58-
ProductName EditionID ReleaseID Build InstalledUTC
59-
----------- --------- --------- ----- ------------
60-
Windows Server 2016 ServerStandard 1607 14393 2/6/2020 5:27:42 PM
61+
ProductName EditionID Release Build InstalledUTC
62+
----------- --------- ------- ----- ------------
63+
Microsoft Windows Server 2016 ServerStandard 14393 8/26/2022 4:26:00 PM
6164
Standard
6265
6366
64-
Computername: SRV2
67+
Computername: SRV1
6568
66-
ProductName EditionID ReleaseID Build InstalledUTC
67-
----------- --------- --------- ----- ------------
68-
Windows Server 2016 ServerStandard 1607 14393 2/6/2020 6:47:12 PM
69+
ProductName EditionID Release Build InstalledUTC
70+
----------- --------- ------- ----- ------------
71+
Microsoft Windows Server 2016 ServerStandard 14393 8/26/2022 4:25:54 PM
6972
Standard
7073
```
7174

@@ -76,13 +79,14 @@ Get Windows version information from remote computers using an alternate credent
7679
```powershell
7780
PS C:\> Get-WindowsVersion -Computername Dom1 | Select-Object *
7881
79-
ProductName : Windows Server 2016 Standard Evaluation
80-
EditionID : ServerStandardEval
81-
ReleaseID : 1607
82-
Build : 14393.3474
83-
Branch : rs1_release
84-
InstalledUTC : 2/6/2020 5:18:50 PM
85-
Computername : DOM1
82+
ProductName : Microsoft Windows Server 2016 Standard
83+
ReleaseVersion :
84+
EditionID : ServerStandard
85+
ReleaseID : 1607
86+
Build : 14393.693
87+
Branch : rs1_release
88+
InstalledUTC : 8/26/2022 4:17:05 PM
89+
Computername : DOM1
8690
```
8791

8892
## PARAMETERS
@@ -224,4 +228,6 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
224228
225229
[WinVer.exe]()
226230
231+
[SystemInfo.exe]()
232+
227233
[Invoke-Command]()

formats/windowsversion.format.ps1xml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
format type data generated 02/20/2019 16:16:06
4-
by BOVINE320\Jeff
5-
-->
62
<Configuration>
73
<ViewDefinitions>
84
<View>
@@ -30,9 +26,9 @@ by BOVINE320\Jeff
3026
<Alignment>left</Alignment>
3127
</TableColumnHeader>
3228
<TableColumnHeader>
33-
<Label>ReleaseID</Label>
34-
<Width>10</Width>
35-
<Alignment>left</Alignment>
29+
<Label>Release</Label>
30+
<Width>8</Width>
31+
<Alignment>right</Alignment>
3632
</TableColumnHeader>
3733
<TableColumnHeader>
3834
<Label>Build</Label>
@@ -56,7 +52,7 @@ by BOVINE320\Jeff
5652
<PropertyName>EditionID</PropertyName>
5753
</TableColumnItem>
5854
<TableColumnItem>
59-
<PropertyName>ReleaseID</PropertyName>
55+
<PropertyName>ReleaseVersion</PropertyName>
6056
</TableColumnItem>
6157
<TableColumnItem>
6258
<Scriptblock>($_.Build -split "\.")[0]</Scriptblock>

functions/Get-WindowsVersion.ps1

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Modified 9/29/2020 so that Invoke-Command doesn't attempt to create a remoting s
66
Function Get-WindowsVersion {
77

88
[cmdletbinding()]
9-
[OutputType("custom object")]
9+
[OutputType("WindowsVersion")]
1010
[alias('wver')]
1111

1212
Param (
@@ -27,11 +27,26 @@ Function Get-WindowsVersion {
2727

2828
$sb = {
2929
$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\'
30-
31-
Get-ItemProperty -Path $RegPath | Select-Object -Property ProductName, EditionID, ReleaseID, BuildBranch,
32-
@{Name = "Build"; Expression = {"$($_.CurrentBuild).$($_.UBR)"}},
33-
@{Name = "InstalledUTC"; Expression = { ([datetime]"1/1/1601").AddTicks($_.InstallTime) }},
34-
@{Name = "Computername"; Expression = {$env:computername}}
30+
<#
31+
9/15/2022 JDH
32+
Revised to use `ysteminfo to retrieve the operating system name and
33+
if that fails, fall back to using the registry entry.
34+
The registry entry for Windows 11 typically still shows Windows 10.
35+
#>
36+
$regData = Get-ItemProperty -Path $RegPath
37+
$tmpCsv = [system.io.path]::GetTempFileName()
38+
Start-Process systeminfo -ArgumentList "/fo csv" -wait -WindowStyle Hidden -RedirectStandardOutput $tmpCSV
39+
if ((Get-Item $tmpCSV).Length -gt 0) {
40+
$osName = Import-CSV $tmpCsv | Select-Object -expand "OS Name"
41+
Remove-Item -Path $tmpCsv
42+
}
43+
else {
44+
$osName = $regData.ProductName
45+
}
46+
$regData | Select-Object -Property @{Name="ProductName";Expression={$osname}}, EditionID, ReleaseID, BuildBranch,
47+
@{Name = "Build"; Expression = { "$($_.CurrentBuild).$($_.UBR)" } }, DisplayVersion,
48+
@{Name = "InstalledUTC"; Expression = { ([datetime]"1/1/1601").AddTicks($_.InstallTime) } },
49+
@{Name = "Computername"; Expression = { $env:computername } }
3550

3651
} #close scriptblock
3752

@@ -46,7 +61,7 @@ Function Get-WindowsVersion {
4661
if ($Computername -eq $ENV:Computername) {
4762
Write-Verbose "[$((Get-Date).TimeOfDay) PROCESS] Processing the local host"
4863
#remove all any passed parameters
49-
"Credential","UseSSL","ThrottleLimit","Authentication" | foreach-object {
64+
"Credential", "UseSSL", "ThrottleLimit", "Authentication" | ForEach-Object {
5065
if ($psboundparameters.ContainsKey($_)) {
5166
Write-Verbose "[$((Get-Date).TimeOfDay) PROCESS] Removing parameter $_"
5267
[void]($PSBoundparameters.Remove($_))
@@ -64,14 +79,15 @@ Function Get-WindowsVersion {
6479
foreach ($item in $results) {
6580

6681
[pscustomobject]@{
67-
PSTypeName = "WindowsVersion"
68-
ProductName = $item.ProductName
69-
EditionID = $item.EditionID
70-
ReleaseID = $item.ReleaseID
71-
Build = $item.Build
72-
Branch = $item.BuildBranch
73-
InstalledUTC = $item.InstalledUTC
74-
Computername = $item.Computername
82+
PSTypeName = "WindowsVersion"
83+
ProductName = $item.ProductName
84+
ReleaseVersion = $item.DisplayVersion
85+
EditionID = $item.EditionID
86+
ReleaseID = $item.ReleaseID
87+
Build = $item.Build
88+
Branch = $item.BuildBranch
89+
InstalledUTC = $item.InstalledUTC
90+
Computername = $item.Computername
7591
}
7692
}
7793
}

0 commit comments

Comments
 (0)