#!/bin/bash ## .SYNOPSIS ## HTML Report to consume easily via EMAIL, or from the Report Directory ## ## .DESCRIPTION ## This Script will query the Veeam Backup for Microsoft 365 API and produce a list of Organizations, including if they have Modern Auth enabled or not. Then it saves it into a comfortable HTML, and it is sent over EMAIL ## The Script it is provided as it is, and bear in mind you can not open support Tickets regarding this project. It is a Community Project ## ## .Notes ## NAME: veeam_microsoft365_modernauth_report.sh ## ORIGINAL NAME: veeam_microsoft365_modernauth_report.sh ## LASTEDIT: 14/04/2022 ## VERSION: 1.0 ## KEYWORDS: Veeam, HTML, Report, Microsoft 365 ## .Link ## https://jorgedelacruz.es/ ## https://jorgedelacruz.uk/ # Configurations ## # Endpoint URL for login action veeamUsername="YOURVEEAMBACKUPUSER" veeamPassword="YOURVEEAMBACKUPPASS" veeamRestServer="YOURVEEAMBACKUPFORMICROSOFT365IP" veeamRestPort="4443" #Default Port ## System Variables reportPath="/home/oper/vb365_daily_reports" email_add="CHANGETHISWITHYOUREMAIL" reportDate=$(date "+%A%B%d%Y") ## Login and Token veeamBearer=$(curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" -d "grant_type=password&username=$veeamUsername&password=$veeamPassword&refresh_token=%27%27" "https://$veeamRestServer:$veeamRestPort/v5/token" -k --silent | jq -r '.access_token') ## # Veeam Backup for Microsoft 365 Organization Overview. This part will check the Organizations ## veeamVB365Url="https://$veeamRestServer:$veeamRestPort/v5/Organizations" veeamOrganizationUrl=$(curl -X GET --header "Accept:application/json" --header "Authorization:Bearer $veeamBearer" "$veeamVB365Url" 2>&1 -k --silent) #Generating HTML file html="$reportPath/Microsoft365-ModernAuth-Report-$reportDate.html" echo '' >> $html echo "" >> $html echo "" >> $html echo '' >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html declare -i arrayOrganizations=0 for id in $(echo "$veeamOrganizationUrl" | jq -r '.[].id'); do OrganizationName=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].officeName") OrganizationRegion=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].region") OrganizationServiceAccount=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].exchangeOnlineSettings.account") if [ "$OrganizationServiceAccount" == "" ]; then OrganizationServiceAccount=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].sharePointOnlineSettings.account"); fi OrganizationMAEX=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].exchangeOnlineSettings.useApplicationOnlyAuth") case $OrganizationMAEX in true) fontex="#37872D" ;; false) fontex="#C4162A" ;; esac OrganizationMASP=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].sharePointOnlineSettings.useApplicationOnlyAuth") case $OrganizationMASP in true) fontsp="#37872D" ;; false) fontsp="#C4162A" ;; esac OrganizationLastBackup=$(echo "$veeamOrganizationUrl" | jq --raw-output ".[$arrayOrganizations].lastBackuptime") echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html echo "" >> $html arrayOrganizations=$arrayOrganizations+1 done echo "" >> $html echo "
Organization NameRegionService AccountModern Auth EXModern Auth SPLast Backup
$OrganizationName$OrganizationRegion$OrganizationServiceAccount$OrganizationMAEX$OrganizationMASP$OrganizationLastBackup
" >> $html echo "
" >> $html echo "
" >> $html echo "" >> $html echo "" >> $html #Sending Email to the user cat $html | s-nail -M "text/html" -s "$veeamRestServer - Veeam Backup for Microsoft 365: Organization Modern Auth Report" $email_add