# Define function to uninstall Google Drive
function Uninstall-GoogleDrive {
$userFolders = Get-ChildItem -Path "C:\Users" -Directory -Exclude "Public", "Default", "Default User" # Exclude system folders
foreach ($userFolder in $userFolders) {
$googleDrivePath = Join-Path -Path $userFolder.FullName -ChildPath "AppData\Local\Google\Drive"
if (Test-Path $googleDrivePath) {
# Uninstall Google Drive if it exists for the user
$null = Start-Process "C:\Program Files\Google\Drive\uninstall.exe" -ArgumentList "/S" -Wait -PassThru
Remove-Item -Path $googleDrivePath -Recurse -Force
Write-Host "Google Drive uninstalled for user: $($userFolder.Name)"
} else {
Write-Host "Google Drive not found for user: $($userFolder.Name)"
}
}
}
# Call the function to uninstall Google Drive
Uninstall-GoogleDrive