Forum Discussion

Sri-Boddupalli's avatar
Sri-Boddupalli
Copper Contributor
Nov 25, 2019

Query User Specific Registry Keys and Export to CSV

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?

Resources