This is a simple one liner to detect whether or not OneDrive is installed.
You would add your code where the Write-Host is at.
if( Test-Path "$env:LOCALAPPDATA\Microsoft\Onedrive\OneDrive.exe" ) {Write-Host "installed"} exit 0
Lab Core | The Lab of MrNetTek
A blog about IT, technical solutions, and code.