Skip to content

Commit

Permalink
v2.45.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Sep 16, 2022
1 parent 9683dde commit e967cd9
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 58 deletions.
Binary file modified PSScriptTools.psd1
Binary file not shown.
Binary file modified PSScriptToolsManual.pdf
Binary file not shown.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,18 @@ The output has a default table view but there are other properties you might wan
PS C:\> Get-WindowsVersion | Select-Object *
ProductName : Windows 10 Pro
EditionID : Professional
ReleaseID : 2009
Build : 19042.906
Branch : vb_release
InstalledUTC : 10/16/2020 3:09:01 PM
Computername : PROSPERO
ProductName : Microsoft Windows 11 Pro
ReleaseVersion : 22H2
EditionID : Professional
ReleaseID : 2009
Build : 22622.598
Branch : ni_release
InstalledUTC : 5/12/2022 1:01:53 PM
Computername : WINDESK11
```

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.

#### [Get-WindowsVersionString](docs/Get-WindowsVersionString.md)

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

## Compatibility

Expand Down
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

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

## v2.45.0

+ Fixed help typo for `Get-PSUnique` [PR 133](https://github.com/jdhitsolutions/PSScriptTools/pull/133). Thank you @fiala-sns.
+ Updated `Get-WindowsVersion` to inlcude `DisplayVersion`, e.g. `22H2`.
+ Modified format file `windowsversion.format.ps1xml` to replace `ReleaseID` with the `DisplayVersion` value.
+ 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.
+ Help updates.
+ Updated `README.md`.

## v2.44.0

+ Updated `Show-ANSISequence` to fix a bug where foreground samples where included when specifying background. [Issue #130](https://github.com/jdhitsolutions/PSScriptTools/issues/130)
Expand Down
50 changes: 28 additions & 22 deletions docs/Get-WindowsVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ This is a PowerShell version of the winver.exe utility. This command uses PowerS

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

This command is an alternative to using Get-CimInstance and querying the Win32_OperatingSystem.

## EXAMPLES

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

Query the local host.
Expand All @@ -48,24 +50,25 @@ PS C:\> Get-WindowsVersion -Computername srv1,srv2,win10 -Credential $art
Computername: WIN10
ProductName EditionID ReleaseID Build InstalledUTC
----------- --------- --------- ----- ------------
Windows 10 Enterprise Enterprise 1903 18362 2/6/2020 5:28:34 PM
ProductName EditionID Release Build InstalledUTC
----------- --------- ------- ----- ------------
Microsoft Windows 10 Enterprise 21H2 19044 8/26/2022 4:25:49 PM
Enterprise
Computername: SRV1
Computername: SRV2
ProductName EditionID ReleaseID Build InstalledUTC
----------- --------- --------- ----- ------------
Windows Server 2016 ServerStandard 1607 14393 2/6/2020 5:27:42 PM
ProductName EditionID Release Build InstalledUTC
----------- --------- ------- ----- ------------
Microsoft Windows Server 2016 ServerStandard 14393 8/26/2022 4:26:00 PM
Standard
Computername: SRV2
Computername: SRV1
ProductName EditionID ReleaseID Build InstalledUTC
----------- --------- --------- ----- ------------
Windows Server 2016 ServerStandard 1607 14393 2/6/2020 6:47:12 PM
ProductName EditionID Release Build InstalledUTC
----------- --------- ------- ----- ------------
Microsoft Windows Server 2016 ServerStandard 14393 8/26/2022 4:25:54 PM
Standard
```

Expand All @@ -76,13 +79,14 @@ Get Windows version information from remote computers using an alternate credent
```powershell
PS C:\> Get-WindowsVersion -Computername Dom1 | Select-Object *
ProductName : Windows Server 2016 Standard Evaluation
EditionID : ServerStandardEval
ReleaseID : 1607
Build : 14393.3474
Branch : rs1_release
InstalledUTC : 2/6/2020 5:18:50 PM
Computername : DOM1
ProductName : Microsoft Windows Server 2016 Standard
ReleaseVersion :
EditionID : ServerStandard
ReleaseID : 1607
Build : 14393.693
Branch : rs1_release
InstalledUTC : 8/26/2022 4:17:05 PM
Computername : DOM1
```

## PARAMETERS
Expand Down Expand Up @@ -224,4 +228,6 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell
[WinVer.exe]()
[SystemInfo.exe]()
[Invoke-Command]()
12 changes: 4 additions & 8 deletions formats/windowsversion.format.ps1xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
format type data generated 02/20/2019 16:16:06
by BOVINE320\Jeff
-->
<Configuration>
<ViewDefinitions>
<View>
Expand Down Expand Up @@ -30,9 +26,9 @@ by BOVINE320\Jeff
<Alignment>left</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>ReleaseID</Label>
<Width>10</Width>
<Alignment>left</Alignment>
<Label>Release</Label>
<Width>8</Width>
<Alignment>right</Alignment>
</TableColumnHeader>
<TableColumnHeader>
<Label>Build</Label>
Expand All @@ -56,7 +52,7 @@ by BOVINE320\Jeff
<PropertyName>EditionID</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>ReleaseID</PropertyName>
<PropertyName>ReleaseVersion</PropertyName>
</TableColumnItem>
<TableColumnItem>
<Scriptblock>($_.Build -split "\.")[0]</Scriptblock>
Expand Down
46 changes: 31 additions & 15 deletions functions/Get-WindowsVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Modified 9/29/2020 so that Invoke-Command doesn't attempt to create a remoting s
Function Get-WindowsVersion {

[cmdletbinding()]
[OutputType("custom object")]
[OutputType("WindowsVersion")]
[alias('wver')]

Param (
Expand All @@ -27,11 +27,26 @@ Function Get-WindowsVersion {

$sb = {
$RegPath = 'HKLM:\SOFTWARE\Microsoft\Windows nt\CurrentVersion\'

Get-ItemProperty -Path $RegPath | Select-Object -Property ProductName, EditionID, ReleaseID, BuildBranch,
@{Name = "Build"; Expression = {"$($_.CurrentBuild).$($_.UBR)"}},
@{Name = "InstalledUTC"; Expression = { ([datetime]"1/1/1601").AddTicks($_.InstallTime) }},
@{Name = "Computername"; Expression = {$env:computername}}
<#
9/15/2022 JDH
Revised to use `ysteminfo 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.
#>
$regData = Get-ItemProperty -Path $RegPath
$tmpCsv = [system.io.path]::GetTempFileName()
Start-Process systeminfo -ArgumentList "/fo csv" -wait -WindowStyle Hidden -RedirectStandardOutput $tmpCSV
if ((Get-Item $tmpCSV).Length -gt 0) {
$osName = Import-CSV $tmpCsv | Select-Object -expand "OS Name"
Remove-Item -Path $tmpCsv
}
else {
$osName = $regData.ProductName
}
$regData | Select-Object -Property @{Name="ProductName";Expression={$osname}}, EditionID, ReleaseID, BuildBranch,
@{Name = "Build"; Expression = { "$($_.CurrentBuild).$($_.UBR)" } }, DisplayVersion,
@{Name = "InstalledUTC"; Expression = { ([datetime]"1/1/1601").AddTicks($_.InstallTime) } },
@{Name = "Computername"; Expression = { $env:computername } }

} #close scriptblock

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

[pscustomobject]@{
PSTypeName = "WindowsVersion"
ProductName = $item.ProductName
EditionID = $item.EditionID
ReleaseID = $item.ReleaseID
Build = $item.Build
Branch = $item.BuildBranch
InstalledUTC = $item.InstalledUTC
Computername = $item.Computername
PSTypeName = "WindowsVersion"
ProductName = $item.ProductName
ReleaseVersion = $item.DisplayVersion
EditionID = $item.EditionID
ReleaseID = $item.ReleaseID
Build = $item.Build
Branch = $item.BuildBranch
InstalledUTC = $item.InstalledUTC
Computername = $item.Computername
}
}
}
Expand Down

0 comments on commit e967cd9

Please sign in to comment.