src/Public/Delete-DebugLogs.ps1
function Delete-DebugLogs { [CmdletBinding()] Param( [Parameter(Mandatory = $true)][Alias("o")]$orgAlias, [Parameter(Mandatory = $false)][bool][Alias("a")]$allOrg = $false ) # Get the user info from org sf org display user -o $orgAlias --json | ConvertFrom-Json | Tee-Object -variable userOrgResult # Set the query string if ($allOrg) { $queryStr = "SELECT Id FROM ApexLog" } else { $queryStr = "SELECT Id FROM ApexLog WHERE LogUserId = '$($userOrgResult.result.Id)'" } # Run the query and delete the logs $tmp = New-TemporaryFile sf data query --query $queryStr -o $orgAlias -r csv | ConvertFrom-Csv | Export-Csv -NoTypeInformation -Path $tmp.FullName sf data delete bulk -o $orgAlias --sobject ApexLog --file $tmp.FullName --wait 100 } |