3

This script work but the output to the .csv in the release id field is everything associated with the registry key. All I want in the field is the release id number (1909, 1809, 1709). How to I edit this script just to write only that information to the output file? Below is a sample of the output I now get. Below that is the script I am using.

The output I get now.

@{ReleaseId=1909; PSPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion; PSParentPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT; PSChildName=CurrentVersion; PS

The script I am using is below.

$Computers = get-content "C:\Temp\computers.txt"

$( foreach ($Computer in $Computers) 
  {
        $result = Invoke-Command -ComputerName $Computer -scriptBlock { Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' -Name ReleaseId } 
            
        [PSCustomObject]@{
            ComputerName = $Computer
            ReleaseID = $Result
        }
        
    } ) | Export-Csv "C:\Temp\GetReleaseID.csv" -NoType

Invoke-Item "C:\Temp\GetReleaseID.csv"
webby68
  • 227
  • 1
  • 3
  • 17
  • 1
    [Your script is awfully complicated.](https://superuser.com/questions/1519110/how-to-get-the-actual-version-number-for-windows-10-from-command-line-not-buil/1519122#1519122) – Ramhound Oct 06 '20 at 00:10
  • By the way ReleaseID won’t contain (1909, 2004, etc) once October 2020 update is released. – Ramhound Oct 06 '20 at 00:17
  • @Ramhound thank you for the update about ReleaseID. – webby68 Oct 06 '20 at 13:29
  • @Ramhound could you please provide a link to where that information is at? I can't seem to find anything on it in searching Google and Microsoft updates information. – webby68 Oct 06 '20 at 16:46
  • The information came directly off Microsoft's development blog for Windows 10 – Ramhound Oct 06 '20 at 16:50

1 Answers1

3

Use Select-Object to select object properties.

Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' -Name ReleaseId | Select-Object -ExpandProperty ReleaseId 

For more information on this cmdlet run Get-Help Select-Object -Full

jfrmilner
  • 1,917
  • 18
  • 16