my instance uses port 8443, so to get the script to connect, i have to add hostname:8443 and the export-csv bombs out because it uses the hostname in the filename. May i suggest changing the export-csv to the following to account for port values:
$name = $hostname.Split(":")[0]
$filename = "{0}_{1:yyyy-MM-ddThhmmss}_TaskActivityReport.csv" -f $name, (Get-Date)
$taskReport | Export-Csv -Path $filename