PSZoom script downloading the wrong files

Using this template helps us debug your issues more effectively :slight_smile:

Description
I wrote a powershell script using the fantastic PSZoom module created by @maci01 (Profile - maci01 - Zoom Developer Forum) but for reasons inexplicable to me, it gets a randome subset of the available meetings to download.
NOT useful.

Error
No specific error, although I do seem to get an awful lot of “recording does not exist” and I cannot explain that either.

Which App Type (OAuth / Chatbot / JWT / Webhook)?
Oauth for the PSzoom module and JWT for the download link

How To Reproduce (If applicable)
Steps to reproduce the behavior:
run the script:

#pre-reqs, PSZoom powershell module, an admin account on zoom, your oauth set and your JWT Auth set.
#update this to match your environment - you will need a JWT token, and they expire regularly, https://marketplace.zoom.us/develop/apps/[APPID]/feature
#you will need your from and to dates, your download location, 
#and to choose if you want auto delete (change no to yes AND uncomment the remove section on line 38
import-module PSZoom
$Global:ZoomApiKey    = 'REDACTED FOR SAFETY' 
$Global:ZoomApiSecret = 'REDACTED FOR SAFETY'
$base = "C:\working\Testing\"
$fromfile1 = "C:\working\zoomusers_$((Get-Date).ToString('MM-dd-yyyy')).csv"
$fromfile2 = "c:\working\rcdngs_$((Get-Date).ToString('MM-dd-yyyy')).csv"
$fromfile3 = "c:\working\DWNLD_$((Get-Date).ToString('MM-dd-yyyy')).csv"
$downlog = "c:\working\ZoomDownloads_$((Get-Date).ToString('MM-dd-yyyy')).log"
$deletelog = "c:\working\ZoomDelete_$((Get-Date).ToString('MM-dd-yyyy')).log"
$exportPath = 'c:\working\files\'
$jwt='REDACTED FOR SAFETY'
$AToken='/?access_token='
$autodelete= 'NO'
$count=0
$FDATE="2021-11-11"
$TDATE="2022-02-28"

Get-ZoomUsers -AllPages -status active | Where-Object {$_.type -eq "2"} |Select-Object id,first_name,last_name,email,pmi | export-csv $fromfile1 -NoTypeInformation
write-host "obtained users"
$Users = Import-Csv -Path $FromFile1
Write-Host "getting recording list"
foreach ($user in $Users) {
Get-zoomRecordings -userId $user.email -From $FDATE -PageSize 300 -To $TDATE |Select-Object -ExpandProperty meetings| export-csv -append $fromfile2 -NoTypeInformation 
$MIDS = Import-Csv -Path $fromfile2
foreach ($MID in $MIDS) {
Get-ZoomMeetingRecordings -MeetingId $MID.uuid | Select-Object -property topic,start_time -ExpandProperty recording_files| Select-Object -property topic,start_time,meeting_id,download_url| export-csv $fromfile3 -Append -NoTypeInformation
$count=$count+1
} 
}
write-host "got recording list, $count items long"
Write-Host "converting to download links, and begining downloads"
$Links = Import-Csv -Path $fromfile3
foreach ($Link in $Links) {
$MTD = $Link.start_time.substring(0,10)
$path = ($base + $Link.topic)
If(!(test-path $path))
{
      New-Item -ItemType Directory -Force -Path $path
}
$uri= ($link.download_url + $AToken + $jwt)
$inc = 1
$file=($path + "\" + $mtd + "-" + $inc + ".mp4")
If(!(test-path $file)) {
$wc=New-Object System.Net.WebClient
$wc.DownloadFile($uri,$file)  
Write-Output "downloading $file" | out-file $downlog -append}
else {
$items=(Get-ChildItem $path | Measure-Object).Count
$inc=$inc+$items
$file=($path + "\" + $mtd + "-" + $inc + ".mp4")
$wc=New-Object System.Net.WebClient
$wc.DownloadFile($uri,$file)  
Write-Output "downloading $file" | out-file $downlog -append}

if($autodelete -eq 'YES'){
    #Remove-ZoomMeetingRecordings -MeetingId $link.meeting_id -Action delete
    Write-Output ($link.topic + " on " + $MTD + " was succesfully delted on $((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss'))") | out-file $deletelog -append
    }
}

Screenshots (If applicable)
This is what Zoom shows I have for recordings, 68 items.
(Dev Forums says I cant embed media items)
but the script outputs only 4 downloadable items (sometimes 2, sometimes 6, but nothing specific), regardless of time frame chosen.

Additional context
What am i doing wrong?

I was able to (with the help of a powershell pro) refine my script some… but I am STILL getting nonsensical answers from the API.
What am i doing wrong? Why does the website show 72 recorded meetings between 2021-11-16 and today, but my script find zero?
Its not the user list, I tried all users, I tried subset… Its not the completed portion, I tried with and without that…
FYI, this is the line I am using to find download links:

$Result = foreach ($ZoomUser in $AllZoomUserList) {
$ZoomRecordingList =  Get-zoomRecordings -userId $ZoomUser.email -From $FDATE -PageSize 300 -To $TDATE | Select-Object -ExpandProperty meetings | select-object topic -ExpandProperty recording_files | Where-Object {$_.status -eq "completed"} | where-object {$_.file_type -eq "MP4"} | select-object -property topic, recording_start, meeting_id, download_url, file_type, status 

Which in my original testing worked just fine… but now… not so much. so what am I missing on how I am gathering meetings to download that it only gets a small subset of what is there…?

Full code is here:

import-module PSZoom
$Global:ZoomApiKey    = 'redacted'  
$Global:ZoomApiSecret = 'redacted'
$base = "C:\working\Testing\"
$downlog = "c:\working\ZoomDownloads_$((Get-Date).ToString('MM-dd-yyyy')).log"
$deletelog = "c:\working\ZoomDelete_$((Get-Date).ToString('MM-dd-yyyy')).log"
$exportPath = 'c:\working\files\'
$jwt='redacted'
$AToken='/?access_token='
$autodelete= 'NO'
$FDATE="2021-11-16"
$TDATE="2022-02-28"
$counter=0
Write-output "starting at $((Get-Date -DisplayHint time).tostring()) and autodelete is set to $autodelete" | out-file $downlog -append
$AllZoomUserList = Get-ZoomUsers -AllPages -status active | Where-Object { $_.type -eq '2' } 
write-output "Obtained $($AllZoomUserList.count) user accounts"
write-output "Obtained $($AllZoomUserList.count) user accounts" | out-file $downlog -append
$Result = foreach ($ZoomUser in $AllZoomUserList) {
$ZoomRecordingList =  Get-zoomRecordings -userId $ZoomUser.email -From $FDATE -PageSize 300 -To $TDATE | Select-Object -ExpandProperty meetings | select-object topic -ExpandProperty recording_files | Where-Object {$_.status -eq "completed"} | where-object {$_.file_type -eq "MP4"} | select-object -property topic, recording_start, meeting_id, download_url, file_type, status 
foreach ($ZoomRecording in $ZoomRecordingList) {
$MTD = $ZoomRecording.recording_start.ToString().substring(0,10) -replace '[\W]', '_'
$path = ($base + $ZoomRecording.topic)
If(!(test-path $path))
{
      New-Item -ItemType Directory -Force -Path $path
}
$uri= ($ZoomRecording.download_url + $AToken + $jwt)
$inc = 1
$file=($path + "\" + $mtd + "-" + $inc + ".mp4")
If(!(test-path $file)) {
Write-output "downloading $file"
$wc=New-Object System.Net.WebClient
$wc.DownloadFile($uri,$file)  
Write-Output "downloaded $file"
Write-Output "$((Get-Date).ToString('hh-mm-ss')) downloaded $file" | out-file $downlog -append
$counter= ($counter + 1)
Write-output "completed $counter files"}
else {
$items=(Get-ChildItem $path | Measure-Object).Count
$inc=$inc+$items
$file=($path + "\" + $mtd + "-" + $inc + ".mp4")
Write-output "downloading $file"
$wc=New-Object System.Net.WebClient
$wc.DownloadFile($uri,$file)  
Write-Output "downloaded $file"
Write-Output "$((Get-Date).ToString('hh-mm-ss')) downloaded $file" | out-file $downlog -append
$counter= ($counter + 1)
Write-output "completed $counter files"}
if($autodelete -eq 'YES'){
    #Remove-ZoomMeetingRecordings -MeetingId $link.meeting_id -Action delete
    Write-Output ($link.topic + " on " + $MTD + " was succesfully delted on $((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss'))") 
    Write-Output ($link.topic + " on " + $MTD + " was succesfully delted on $((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss'))") | out-file $deletelog -append
    }
}
}
write-output "attempted download on $counter recordings"
write-output "finished at $((Get-Date).ToString('hh-mm-ss')) attempted download on $counter recordings" | out-file $downlog -append

How do you have $ZoomRecording defined outside of this code sample please? The endpoint is expecting a request to the following so just double checking:

https://{{base-domain}}/recording/download/{{path-to-file-download}}?access_token={{JWT-token}}

Thanks,
Gianni

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.