Created
August 27, 2025 23:07
-
-
Save SkyLeach/e5686e48fd39161d7ef6de5db830666e to your computer and use it in GitHub Desktop.
Table data showing windows version information. Shows how to get version information inside powershell and display that information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [CmdletBinding()] | |
| Param ( | |
| [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true)] | |
| [string[]]$ComputerName = $env:COMPUTERNAME | |
| ) | |
| Begin { | |
| $Table = New-Object System.Data.DataTable | |
| $Table.Columns.AddRange(@("ComputerName","Windows Edition","Version","OS Build")) | |
| } Process { | |
| Foreach ($Computer in $ComputerName) | |
| { | |
| $Code = { | |
| $ProductName = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' –Name ProductName).ProductName | |
| Try | |
| { | |
| $Version = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' –Name ReleaseID –ErrorAction Stop).ReleaseID | |
| } | |
| Catch | |
| { | |
| $Version = "N/A" | |
| } | |
| $CurrentBuild = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' –Name CurrentBuild).CurrentBuild | |
| $UBR = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' –Name UBR).UBR | |
| $OSVersion = $CurrentBuild + "." + $UBR | |
| $TempTable = New-Object System.Data.DataTable | |
| $TempTable.Columns.AddRange(@("ComputerName","Windows Edition","Version","OS Build")) | |
| [void]$TempTable.Rows.Add($env:COMPUTERNAME,$ProductName,$Version,$OSVersion) | |
| Return $TempTable | |
| } | |
| If ($Computer -eq $env:COMPUTERNAME) | |
| { | |
| $Result = Invoke-Command –ScriptBlock $Code | |
| [void]$Table.Rows.Add($Result.Computername,$Result.'Windows Edition',$Result.Version,$Result.'OS Build') | |
| } | |
| Else | |
| { | |
| Try | |
| { | |
| $Result = Invoke-Command –ComputerName $Computer –ScriptBlock $Code –ErrorAction Stop | |
| [void]$Table.Rows.Add($Result.Computername,$Result.'Windows Edition',$Result.Version,$Result.'OS Build') | |
| } | |
| Catch | |
| { | |
| $_ | |
| } | |
| } | |
| } | |
| } End { | |
| Return $Table | |
| } | |
| # 4/30/2025 11:46:04 PM - Added Set-Alias record | |
| # Set-Alias -name ll -value "\Users\mattg\src\powershell_maint\colorized_dir_or_getchilditem.ps1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment