-
Notifications
You must be signed in to change notification settings - Fork 247
ASD Remote Domain Configuration Check
Version: 1.0
Last Updated: 11-04-2025
Author: CIAOPS
- Overview
- System Requirements
- Installation
- Parameters
- Usage Examples
- How It Works
- Output Files
- Baseline Configuration
- Compliance Checks
- Progress Indicators
- Detailed Logging
- Troubleshooting
- Reference
The ASD Remote Domain Check script validates Exchange Online Default Remote Domain configuration against the Australian Signals Directorate (ASD) Blueprint for Secure Cloud requirements. It helps organizations ensure their email security settings comply with government security standards.
- ✅ Connects to Exchange Online
- ✅ Retrieves Default Remote Domain configuration
- ✅ Compares settings against ASD Blueprint requirements
- ✅ Generates detailed HTML compliance report
- ✅ Optionally exports results to CSV
- ✅ Optionally logs all operations to file
- ✅ Downloads latest baseline from GitHub by default
| Feature | Description |
|---|---|
| Automated Compliance Checking | Validates 10 security settings automatically |
| Cloud-Based Baselines | Downloads latest ASD requirements from GitHub |
| Professional Reports | Generates beautiful HTML reports with compliance metrics |
| Progress Tracking | Real-time progress indicators during execution |
| Permission Validation | Checks user permissions before attempting operations |
| Detailed Logging | Optional comprehensive logging for audit trails |
| Flexible Configuration | Supports custom baselines and output locations |
Important Note: This script checks the 'Default' remote domain which applies to all external domains unless specific remote domains are configured in Exchange Online.
| Component | Requirement | Notes |
|---|---|---|
| PowerShell Version | 5.1 or PowerShell 7+ | Windows PowerShell or PowerShell Core |
| Operating System | Windows 10/11, Windows Server 2016+ | Or any OS supporting PowerShell 7+ |
| Internet Connection | Required | For GitHub baseline download and Exchange Online connection |
# Install ExchangeOnlineManagement module
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -ForceThe account running the script must have one of the following roles:
- Exchange Administrator
- Global Administrator
- Global Reader
- View-Only Organization Management
- Compliance Administrator
Note: Read-only permissions are sufficient. The script does not make any changes to your Exchange Online configuration.
-
Download the Script
# Clone the repository git clone https://github.com/directorcia/office365.git # Or download directly Invoke-WebRequest -Uri "https://raw.githubusercontent.com/directorcia/office365/master/asd-remotedomain-get.ps1" -OutFile "asd-remotedomain-get.ps1"
-
Install Required Module
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -Force
-
Verify Installation
Get-Module -ListAvailable -Name ExchangeOnlineManagement
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
-ExportToCSV |
Switch | No | False | Export results to CSV file in addition to HTML report |
-CSVPath |
String | No | Parent directory with timestamp | Custom path for CSV export |
-BaselinePath |
String | No | GitHub URL | Path or URL to custom baseline JSON file |
-DetailedLogging |
Switch | No | False | Enable detailed logging to file for audit trails |
-LogPath |
String | No | Parent directory with timestamp | Custom path for log file |
Enables CSV export of compliance check results alongside the HTML report.
.\asd-remotedomain-get.ps1 -ExportToCSVSpecifies a custom location for the CSV export file.
.\asd-remotedomain-get.ps1 -ExportToCSV -CSVPath "C:\Reports\compliance.csv"Specifies a custom baseline JSON file (local path or URL).
# Local file
.\asd-remotedomain-get.ps1 -BaselinePath "C:\Baselines\custom.json"
# URL
.\asd-remotedomain-get.ps1 -BaselinePath "https://example.com/baseline.json"Enables comprehensive logging of all operations to file.
.\asd-remotedomain-get.ps1 -DetailedLoggingSpecifies a custom location for the log file.
.\asd-remotedomain-get.ps1 -DetailedLogging -LogPath "C:\Logs\audit.log".\asd-remotedomain-get.ps1Connects to Exchange Online, downloads latest baseline from GitHub, runs compliance check, and generates HTML report.
.\asd-remotedomain-get.ps1 -ExportToCSVRuns the check and exports results to both HTML and CSV formats.
.\asd-remotedomain-get.ps1 -ExportToCSV -CSVPath "C:\Reports\compliance-report.csv"Exports CSV to a specific location.
.\asd-remotedomain-get.ps1 -BaselinePath "C:\Baselines\prod-remote-domains.json"Uses a local custom baseline file instead of downloading from GitHub.
.\asd-remotedomain-get.ps1 -BaselinePath ".\baselines\dev-environment.json" -ExportToCSVUses a development environment baseline and exports results to CSV.
.\asd-remotedomain-get.ps1 -DetailedLoggingEnables comprehensive logging to file for audit trail purposes.
.\asd-remotedomain-get.ps1 -DetailedLogging -LogPath "C:\Logs\audit-$(Get-Date -Format 'yyyyMMdd').log"Logs detailed operations to a custom file location with date in filename.
.\asd-remotedomain-get.ps1 -ExportToCSV -DetailedLoggingRuns with all features enabled: HTML report, CSV export, and detailed logging.
┌─────────────────────────────────────┐
│ 1. Initialization │
│ Validate parameters and setup │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 2. Baseline Loading │
│ Download from GitHub or load local │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 3. Module Check │
│ Verify ExchangeOnlineManagement │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 4. Exchange Connection │
│ Connect to Exchange Online │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 5. Permission Validation │
│ Check user has required roles │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 6. Configuration Retrieval │
│ Get Default Remote Domain settings │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 7. Compliance Checking │
│ Compare 10 settings vs baseline │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 8. Report Generation │
│ Create HTML report │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 9. Optional Exports │
│ CSV and/or log file │
└────────────┬────────────────────────┘
↓
┌─────────────────────────────────────┐
│ 10. Completion │
│ Open report and display summary │
└─────────────────────────────────────┘
-
Initialization (0%)
- Validates command-line parameters
- Sets up file paths for outputs
- Initializes script-scope variables
- Starts logging if enabled
-
Baseline Loading (0-30%)
- Detects if baseline is URL or local file
- Downloads from GitHub (default) or reads local file
- Validates JSON schema
- Falls back to built-in defaults if needed
-
Module Check
- Checks if ExchangeOnlineManagement is installed
- Loads module if available
- Displays installation instructions if missing
-
Exchange Connection (10%)
- Tests existing connection
- Initiates authentication if needed
- Handles MFA prompts
- Confirms successful connection
-
Permission Validation
- Attempts to read organization config
- Tests access to remote domain settings
- Displays helpful error message if insufficient permissions
- Lists required roles
-
Configuration Retrieval (10-20%)
- Queries Exchange Online for Default remote domain
- Validates domain exists
- Retrieves all configuration properties
-
Compliance Checking (20-60%)
- Iterates through 10 security settings
- Compares current values vs baseline requirements
- Records PASS/FAIL for each check
- Updates progress indicator for each setting
-
Report Generation (80%)
- Calculates compliance percentage
- Generates professional HTML report
- Includes summary dashboard
- Creates detailed results table
-
Optional Exports (70-80%)
- Exports to CSV if requested
- Writes detailed log file if enabled
- Saves all files with timestamps
-
Completion (90-100%)
- Opens HTML report in default browser
- Displays console summary
- Shows file locations
- Completes progress indicator
Location: {parent-directory}\asd-remotedomain-get-{timestamp}.html
Contents:
- Compliance summary dashboard
- Total checks
- Passed checks
- Failed checks
- Compliance percentage
- Domain information section
- Detailed results table with:
- Status badge (PASS/FAIL)
- Setting name
- Description
- Current value
- Required value
- Overall compliance status
- Baseline source information
- Reference links
Features:
- Professional gradient design
- Color-coded results
- Responsive layout
- Print-friendly
- Auto-opens in browser
Location: {parent-directory}\asd-remotedomain-get-{timestamp}.csv
Format:
Setting,Description,CurrentValue,RequiredValue,Status
DomainName,Remote Domain (should be *),*,*,PASS
AllowedOOFType,Out of Office automatic reply types,External,External,PASS
AutoReplyEnabled,Allow automatic replies,False,False,PASS
Use Cases:
- Import into Excel for analysis
- Load into Power BI dashboards
- Integrate with compliance tracking systems
- Historical trend analysis
Location: {parent-directory}\asd-remotedomain-get-{timestamp}.log
Format:
[2025-04-11 14:30:45] [INFO] === ASD Remote Domain Configuration Check Started ===
[2025-04-11 14:30:45] [INFO] Script Version: 1.0
[2025-04-11 14:30:45] [INFO] PowerShell Version: 7.4.0
[2025-04-11 14:30:45] [INFO] Detailed Logging: Enabled
[2025-04-11 14:30:46] [INFO] Starting baseline settings load from: https://...
[2025-04-11 14:30:47] [INFO] Baseline loaded successfully from GitHub
[2025-04-11 14:30:48] [INFO] Check: DomainName - Current: *, Required: *, Status: PASS
[2025-04-11 14:30:48] [WARN] Check: AutoForwardEnabled - Current: True, Required: False, Status: FAIL
[2025-04-11 14:30:50] [INFO] Script completed successfully
Log Levels:
-
[INFO]- Normal operations and successful actions -
[WARN]- Non-critical issues and failed compliance checks -
[ERROR]- Critical errors and failures
The script uses the following precedence for baseline settings:
-
Custom Path - If
-BaselinePathparameter is specified - GitHub (Default) - Downloads from official repository
- Built-in Defaults - Hard-coded ASD Blueprint values
https://raw.githubusercontent.com/directorcia/bp/main/ASD/Exchange-Online/Mail-flow/remote-domains.json
{
"RemoteDomain": {
"Name": "Default",
"DomainName": "*",
"EmailReplyTypes": {
"AllowedOOFType": "External",
"AutoReplyEnabled": false,
"AutoForwardEnabled": false
},
"MessageReporting": {
"DeliveryReportEnabled": false,
"NDREnabled": false,
"MeetingForwardNotificationEnabled": false
},
"TextAndCharacterSet": {
"TNEFEnabled": null,
"CharacterSet": null,
"NonMimeCharacterSet": null
}
}
}The script validates that the baseline JSON contains all required fields:
| Field Path | Type | Description |
|---|---|---|
RemoteDomain |
Object | Root RemoteDomain object |
RemoteDomain.Name |
String | Remote domain name |
RemoteDomain.DomainName |
String | Domain name pattern |
RemoteDomain.EmailReplyTypes |
Object | Email reply types configuration |
RemoteDomain.MessageReporting |
Object | Message reporting configuration |
RemoteDomain.TextAndCharacterSet |
Object | Text and character set configuration |
If validation fails, the script falls back to built-in defaults with a warning message.
- Copy the schema above to a new JSON file
- Modify values according to your requirements:
{ "RemoteDomain": { "Name": "Default", "DomainName": "*", "EmailReplyTypes": { "AllowedOOFType": "External", "AutoReplyEnabled": false, "AutoForwardEnabled": true // Custom: Allow auto-forward }, "MessageReporting": { "DeliveryReportEnabled": false, "NDREnabled": false, "MeetingForwardNotificationEnabled": false }, "TextAndCharacterSet": { "TNEFEnabled": null, "CharacterSet": null, "NonMimeCharacterSet": null } } } - Save with a descriptive name (e.g.,
production-baseline.json) - Run script with custom baseline:
.\asd-remotedomain-get.ps1 -BaselinePath ".\production-baseline.json"
| # | Setting | Category | ASD Default | Security Impact |
|---|---|---|---|---|
| 1 | DomainName | General | * |
Applies settings to all external domains |
| 2 | AllowedOOFType | Email Reply | External |
Controls Out of Office reply types |
| 3 | AutoReplyEnabled | Email Reply | False |
Prevents information leakage via auto-replies |
| 4 | AutoForwardEnabled | Email Reply | False |
Critical: Blocks automatic email forwarding (data exfiltration risk) |
| 5 | DeliveryReportEnabled | Message Reporting | False |
Prevents delivery confirmation to external senders |
| 6 | NDREnabled | Message Reporting | False |
Blocks non-delivery reports to external senders |
| 7 | MeetingForwardNotificationEnabled | Message Reporting | False |
Prevents meeting forward notifications |
| 8 | TNEFEnabled | Text & Character | Null |
Rich-text format control (follow user settings) |
| 9 | CharacterSet | Text & Character | Null |
MIME character encoding (system default) |
| 10 | NonMimeCharacterSet | Text & Character | Null |
Non-MIME character encoding (system default) |
Risk if Enabled:
- Malicious actors can automatically forward emails to external addresses
- Data exfiltration through compromised accounts
- Bypasses DLP and compliance controls
ASD Recommendation: Must be disabled for external domains
Risk if Enabled:
- Automatic replies can leak information about:
- User availability
- Email address validity
- Internal processes
- Can be used for reconnaissance
Risk if Enabled:
- External actors can validate email addresses
- Information disclosure about mail system
- Can be used for phishing campaigns
Compliance % = (Passed Checks / Total Checks) × 100
Status:
- 100% = COMPLIANT ✓ - All checks passed
- <100% = NON-COMPLIANT ✗ - One or more checks failed
The script displays real-time progress throughout execution:
| Progress | Stage | Description |
|---|---|---|
| 0% | Initialization | Script startup and parameter validation |
| 10% | Connection | Retrieving Default remote domain configuration |
| 20% | Preparation | Starting compliance checks |
| 20-60% | Checking | Running 10 individual compliance checks (4% per check) |
| 60% | Analysis | Analyzing results and calculating compliance |
| 70% | CSV Export | Exporting to CSV (if requested) |
| 80% | Report | Generating HTML report |
| 90% | Browser | Opening report in browser |
| 100% | Complete | All operations finished |
Activity: ASD Remote Domain Check
Status: Checking AutoForwardEnabled (4 of 10)
Progress: [████████░░░░░░░░░░░░] 36%
# Basic logging (default location)
.\asd-remotedomain-get.ps1 -DetailedLogging
# Custom log location
.\asd-remotedomain-get.ps1 -DetailedLogging -LogPath "C:\Logs\compliance.log"
# With date in filename
.\asd-remotedomain-get.ps1 -DetailedLogging -LogPath "C:\Logs\audit-$(Get-Date -Format 'yyyyMMdd').log"[YYYY-MM-DD HH:MM:SS] [LEVEL] Message
-
Script Initialization
- Script version
- PowerShell version
- Parameter values
- File paths
-
Baseline Loading
- Source type (URL/Local)
- Download/read status
- Schema validation results
- Success/failure messages
-
Module and Connection
- Module availability
- Connection attempts
- Authentication events
- Permission checks
-
Compliance Checks
- Each setting checked
- Current value
- Required value
- Pass/fail status
-
Report Generation
- HTML generation status
- CSV export status
- File locations
-
Errors and Exceptions
- Error messages
- Stack traces
- Line numbers
- Command details
# View entire log
Get-Content .\asd-remotedomain-get-20250411-143045.log
# View only errors
Get-Content .\asd-remotedomain-get-20250411-143045.log | Select-String -Pattern "\[ERROR\]"
# View failed checks
Get-Content .\asd-remotedomain-get-20250411-143045.log | Select-String -Pattern "Status: FAIL"
# Count log entries by level
Get-Content .\asd-remotedomain-get-20250411-143045.log |
ForEach-Object { ($_ -split '\[')[2] -split '\]' | Select-Object -First 1 } |
Group-Object |
Select-Object Name, CountError Message:
ExchangeOnlineManagement module not found!
Install it with: Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser
Solution:
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -ForceVerification:
Get-Module -ListAvailable -Name ExchangeOnlineManagementError Message:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ INSUFFICIENT PERMISSIONS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
This script requires Exchange Online read permissions.
Required Roles (one of the following):
• Exchange Administrator
• Global Administrator
• Global Reader
• View-Only Organization Management
• Compliance Administrator
Solution:
- Contact your Exchange Online administrator
- Request one of the required roles
- Wait for role assignment to propagate (5-30 minutes)
- Re-run the script
Check Current Roles:
Get-ManagementRoleAssignment -RoleAssignee "user@domain.com" |
Select-Object Role, RoleAssigneeType |
Sort-Object RoleError Message:
Failed to download or parse baseline from URL: ...
⚠️ Using built-in ASD Blueprint defaults instead
Causes:
- No internet connectivity
- Firewall/proxy blocking GitHub
- GitHub service outage
- Invalid URL
Solutions:
Option 1: Check Connectivity
Test-NetConnection -ComputerName raw.githubusercontent.com -Port 443Option 2: Download Manually
$url = "https://raw.githubusercontent.com/directorcia/bp/main/ASD/Exchange-Online/Mail-flow/remote-domains.json"
Invoke-WebRequest -Uri $url -OutFile "baseline.json"
.\asd-remotedomain-get.ps1 -BaselinePath ".\baseline.json"Option 3: Use Built-in Defaults
- Script automatically falls back to built-in ASD Blueprint defaults
- No action required, script continues normally
Error Message:
Failed to connect to Exchange Online: The operation has timed out
Solutions:
Check Network:
Test-NetConnection -ComputerName outlook.office365.com -Port 443Check Service Health:
- Visit https://status.office.com/
- Check Microsoft 365 admin center service health
Retry with Proxy:
$ProxyOptions = New-PSSessionOption -ProxyAccessType IEConfig
Connect-ExchangeOnline -PSSessionOption $ProxyOptionsError Message:
Could not automatically open browser: ...
Please open the report manually: C:\path\to\report.html
Solution:
- Report is successfully generated
- Manually open the HTML file from the displayed path
- Use Windows Explorer or:
Start-Process "C:\path\to\asd-remotedomain-get-20250411-143045.html"Symptoms:
- Script asks for credentials multiple times
- "Not connected" message after authentication
Solutions:
Clear Cached Credentials:
Disconnect-ExchangeOnline -Confirm:$false
Connect-ExchangeOnlineCheck MFA:
- Ensure MFA app is working
- Approve any pending authentication requests
- Check conditional access policies
Error Message:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ BASELINE JSON SCHEMA VALIDATION FAILED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Missing required fields:
• RemoteDomain.EmailReplyTypes
└─ Email reply types configuration
Solution:
- Verify JSON file format
- Check for missing fields
- Validate JSON syntax:
$json = Get-Content "baseline.json" -Raw | ConvertFrom-Json
$json | ConvertTo-Json -Depth 5- Use default baseline or fix custom baseline
.\asd-remotedomain-get.ps1 -DetailedLogging -LogPath "C:\Temp\debug.log"$PSVersionTableGet-Module -ListAvailable -Name ExchangeOnlineManagement | Select-Object VersionConnect-ExchangeOnline
Get-RemoteDomain -Identity "Default"
Disconnect-ExchangeOnline -Confirm:$falseGet-ExecutionPolicy -List
# If needed:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- ASD Blueprint - Remote Domains
- GitHub Repository
- Wiki Documentation
- Baseline Repository
- Security Controls Explanation
| Property | Value |
|---|---|
| Script Name | asd-remotedomain-get.ps1 |
| Author | CIAOPS |
| Version | 1.0 |
| Date | 11-04-2025 |
| PowerShell | 5.1+ / 7+ |
| License | Open Source |
| Repository | https://github.com/directorcia/office365 |
Report Issues:
- GitHub Issues: https://github.com/directorcia/office365/issues
Documentation:
Contributions:
- Fork the repository
- Create a feature branch
- Submit a pull request
| Version | Date | Changes |
|---|---|---|
| 1.0 | 11-04-2025 | Initial release with all features |
-
asd-mailflow-get.ps1- Mail flow rule compliance check -
asd-atp-get.ps1- Advanced Threat Protection check -
o365-exo-fwd-chk.ps1- Email forwarding audit
# Basic run
.\asd-remotedomain-get.ps1
# Full audit
.\asd-remotedomain-get.ps1 -ExportToCSV -DetailedLogging
# Custom baseline
.\asd-remotedomain-get.ps1 -BaselinePath ".\custom-baseline.json"
# Custom outputs
.\asd-remotedomain-get.ps1 -ExportToCSV -CSVPath "C:\Reports\audit.csv" -DetailedLogging -LogPath "C:\Logs\audit.log"| File | Default Location |
|---|---|
| HTML Report | {parent-dir}\asd-remotedomain-get-{timestamp}.html |
| CSV Export | {parent-dir}\asd-remotedomain-get-{timestamp}.csv |
| Log File | {parent-dir}\asd-remotedomain-get-{timestamp}.log |
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (module, connection, permissions, or execution) |
Document Version: 1.0
Last Updated: 11-04-2025
Maintained By: CIAOPS