$rcloneOutput = rclone about :drive:/ --drive-service-account-file="$ServiceAccountFile" --drive-team-drive "$TeamDrive" --drive-impersonate "$Impersonate" -vv 2>&1
$targetLine = $rcloneOutput | Where-Object { $_ -match "Google drive root ''" }
if ($targetLine) {
return $targetLine -replace '.*Shared Drive "(.*?)"', '$1'
} else {
Write-Error "Drive name not found in the output."
return
}
Example debug output being parsed:
2025/03/22 16:42:14 DEBUG : Creating backend with remote ":drive:"
2025/03/22 16:42:14 DEBUG : Using config file from "C:\\Program Files\\RClone\\rclone.conf"
2025/03/22 16:42:14 DEBUG : :drive: detected overridden config - adding "{lAMVc}" suffix to name
2025/03/22 16:42:14 DEBUG : fs cache: renaming cache item ":drive:" to be canonical ":drive{lAMVc}:"
2025/03/22 16:42:14 DEBUG : Google drive root '': read info from Shared Drive "Feet"
2025/03/22 16:42:14 DEBUG : 5 go routines active
Currently using something like the following to get the Shared Drive Name to check that the Shared Drive is the one I think it should be when ran interactively, and I'm trying not to rely on direct api calls.
Any better ways to get arbitrary information like this from rclone?
I am not using a config file, this is for an interactive module.