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"