Disclaimer / Clause de non-responsabilité / Haftungsausschluss:
Use of the code examples is at your own risk!
L’utilisation des exemples de code s’effectue à vos propres risques et périls !
Die Nutzung der Codebeispiele erfolgt auf eigenes Risiko!
The idea is to find the “OneDrive.exe” in three possible installation folders.
Microsoft has restricted the execution of OneDrive.exe directly from PowerShell or via start process in some cases...
<# Owner: marcel.powershell@use.startmail.com
Disclaimer: Use of the code examples is at your own risk!
#>
# PowerShell script to find OneDrive.exe on a Windows 11 computer
Clear-Host
Write-Host "-*-"
$possiblePaths = @(
"$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe", # Benutzerinstallation
"$env:ProgramFiles\Microsoft OneDrive\OneDrive.exe", # Systemweite Installation (64-bit)
"$env:ProgramFiles(x86)\Microsoft OneDrive\OneDrive.exe" # Systemweite Installation (32-bit)
)
Write-Host "Search for OneDrive.exe in the usual paths..." -ForegroundColor Cyan
Write-Host
$found = $false
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
Write-Host "✅ OneDrive.exe found at:" -ForegroundColor Green
Write-Host
Write-Host $path -ForegroundColor Yellow
$found = $true
}
}
Write-Host
if (-not $found) {
Write-Host "❌ OneDrive.exe was not found in the known paths." -ForegroundColor Red
Write-Host
}else{
Set-Clipboard -Value $Path
Write-Host "✅ Set Path to Clipboard!" -ForegroundColor Green
Write-Host
Write-Host "-"
}