Query User Specific Registry Keys and Export to CSV

Copper Contributor

I have a task to query the OneDrive HKCU registry key(HKCU:\Software\Microsoft\OneDrive\Accounts) and export those key properties and its values to some network location for evaluation

 

So I wrote a general PS script like below to do the job. And this needs to be executed only when user is logged in and in SCCM UserContext

 

 

 

 

Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Business1 -Name userfolder,username,useremail | Export-Csv \abcd\efgh\ijkl\OneDrive.Csv -NoTypeInformation -Append -Force

Get-ItemProperty -Path HKCU:\Software\Microsoft\OneDrive\Accounts\Personal -Name userfolder,username,useremail | Export-Csv \abcd\efgh\ijkl\OneDrive.Csv -NoTypeInformation -Append -Force

 

 

 

 if any users does not have those keys or properties, how to stop them from seeing some error message in PowerShell window?

1 Reply

@Sri-Boddupalli 

you can try adding -ErrorAction SilentlyContinue to your Get-ItemProperty command