# Token laden $token = Get-Content ".\token.json" | ConvertFrom-Json $accessToken = $token.access_token $folder = "C:\Temp\git\PS-SetEtikettSorte" # 👉 HIER deine Google Drive Folder ID eintragen $DriveFolderId = "1kEmjnVL414XYLRfN597K7YKuiFs-FRBv" $files = Get-ChildItem $folder -Filter "*A4*.jpg" foreach ($file in $files) { Write-Host "Upload: $($file.Name)" $boundary = [System.Guid]::NewGuid().ToString() $LF = "`r`n" # 🔥 HIER angepasst $metadata = @{ name = $file.Name parents = @($DriveFolderId) } | ConvertTo-Json $fileBytes = [System.IO.File]::ReadAllBytes($file.FullName) $body = ( "--$boundary$LF" + "Content-Type: application/json; charset=UTF-8$LF$LF" + "$metadata$LF" + "--$boundary$LF" + "Content-Type: image/jpeg$LF$LF" ) $bodyBytes = [System.Text.Encoding]::UTF8.GetBytes($body) $footer = "$LF--$boundary--$LF" $footerBytes = [System.Text.Encoding]::UTF8.GetBytes($footer) $finalBody = New-Object System.IO.MemoryStream $finalBody.Write($bodyBytes, 0, $bodyBytes.Length) $finalBody.Write($fileBytes, 0, $fileBytes.Length) $finalBody.Write($footerBytes, 0, $footerBytes.Length) $finalBody.Position = 0 Invoke-RestMethod ` -Uri "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart" ` -Method Post ` -Headers @{ Authorization = "Bearer $accessToken" } ` -ContentType "multipart/related; boundary=$boundary" ` -Body $finalBody Write-Host "Fertig: $($file.Name)" }