Hi,
You can get the version of Office like this
$version = Get-WmiObject -Class Win32_Product -Filter "name like 'Microsoft Office Professional%'" | Select-Object -ExpandProperty Version
If it's Office 365 you can try
$version = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' | Select-Object -ExpandProperty VersionToReport
To create a registry value you can use the New-ItemProperty cmdlet
$version -match '\d+.\d'
$ver = $Matches.Values
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\$ver\Excel\Options" -Name "OPEN" -Value $filename -PropertyType String
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.