Script to detect if software is installed in Local AppData

Hello,

I created a script which should check if Google Chrome is installed in a users Local AppData folder. In order to do that, it checks if the registry key in HKEY_USERS\UserSID\Software\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome is there.

When running the script manually on a Test-VM as administrator, the output gets written into a text file.

However, I would like to let a GPO do the work and make it scan every computer to check if Chrome is installed in the Local AppData.

Does anyone know what I would have to add in my script? Something with iteration probably? Unfortunately I just started with Powershell so I don’t know how to continue with it.

Thank you in advance!

 $registryPath = "Registry::HKEY_USERS\*\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome"
    
    
    $outputFile = "\\FileShare\NewFolder\Chrome.txt"
    
    if (Test-Path $registryPath) {
        $InstallLocation = (Get-ItemProperty -Path $registryPath -Name InstallLocation).InstallLocation
        $displayVersion = (Get-ItemProperty -Path $registryPath -Name DisplayVersion).DisplayVersion
        
    
        $output = "$($env:COMPUTERNAME), $InstallLocation, $displayVersion, $(Get-Date -Format ""dd-MM-yyyy HH:mm:ss"")"
        $output | Out-File -Append -FilePath $outputFile
    
        Write-Host "Checking ready."
    } else {
        #Registry key not found
        Write-Error "Can't find the registry"
    }

If the script is working then I would say this is a GPO question rather than Powershell. I would suggest a scheduled task created via GPO with whatever frequency you require. This way the scheduled task can be configured with an account that has access to the share you are trying to send the output to versus opening up share permissions.

Another approach would be to run a simple script from the DC against all computers in the domain.