Yes, it works locally Mr. Vierra.jvierra wrote: ↑Thu Aug 09, 2018 7:57 amCode: Select all
function Get-OfficeVersion{ param( [string]$ComputerName = $env:COMPUTERNAME ) # code to extract Word/Office version $hive = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('localmachine',$ComputerName) if($key = $hive.OpenSubKey('Software\Classes\Word.Application\CurVer')){ $wordApp = $key.GetValue($null) } switch ($wordApp){ 'Word.Application.17' {'Office 2019'} 'Word.Application.16' {'Office 2016'} 'Word.Application.15' {'Office 2013'} 'Word.Application.14' {'Office 2010'} 'Word.Application.12' {'Office 2007'} 'Word.Application.11' {'Office 2003'} default {'Not found'} } }
Unable to query remote registry using PowerShell script
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- ITEngineer
- Posts: 216
- Last visit: Thu Mar 23, 2023 5:45 pm
- Has voted: 4 times
Re: Unable to query remote registry using PowerShell script
/* IT Engineer */
- ITEngineer
- Posts: 216
- Last visit: Thu Mar 23, 2023 5:45 pm
- Has voted: 4 times
Re: Unable to query remote registry using PowerShell script
So how is it possible to show the column name of the Computer after modifying the script like below:
The first column for Computername is missing.
Code: Select all
Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "DC=Domain,DC=com" |
Where-Object {Test-Connection $_.Name -Count 1 -Quiet} |
Select-Object -Property Name |
ForEach-Object {
Get-OfficeVersion $_.Name
} | Export-Csv -Path C:\OfficeVersion.csv -NoTypeInformation -UseCulture
/* IT Engineer */
Re: Unable to query remote registry using PowerShell script
Code: Select all
[pscustomobject]@{
ComputerName = $_.Name
OfficeVersion = Get-OfficeVersion $_.Name
}