Create a powershell script to check what version of excel is install and set a report to open when excel start

Fahad Noaman 171 Reputation points
2021-04-15T08:49:23.017+00:00

Can you help me to build a script which will check the version of excel install using registry and set to open a application report where excel start.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,561 questions
{count} votes

Accepted answer
  1. Ian Xue 37,711 Reputation points Microsoft Vendor
    2021-04-16T09:42:49.35+00:00

    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.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.