EasyEntra.Format.ps1xml

<?xml version="1.0" encoding="utf-8"?>
<!-- *******************************************************************
Copyright(c) Agema A/S, 2026
******************************************************************** -->
<Configuration>
  <ViewDefinitions>
    <!--############################ Get-Mailbox ################################-->
    <View>
      <Name>Microsoft.Exchange.Data.Directory.Management.Mailbox</Name>
      <ViewSelectedBy>
        <TypeName>Microsoft.Exchange.Data.Directory.Management.Mailbox</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>25</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Alias</Label>
            <Width>20</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>RecipientTypeDetails</Label>
            <Width>20</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>PrimarySmtpAddress</Label>
            <Width>30</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>ExternalDirectoryObjectId</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>Name</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Alias</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>RecipientTypeDetails</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>PrimarySmtpAddress</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>ExternalDirectoryObjectId</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <!--############################ Get-Mailbox ################################-->
 
    <!--########### CreateUserFromTemplate Result (Hybrid & Entra) ##############-->
    <View>
      <Name>EasyEntra.CreateUserFromTemplate.Result</Name>
      <ViewSelectedBy>
        <TypeName>EasyEntra.CreateUserFromTemplate.Result</TypeName>
      </ViewSelectedBy>
      <CustomControl>
        <CustomEntries>
          <CustomEntry>
            <CustomItem>
              <ExpressionBinding>
                <ScriptBlock>
                  try {
                    $sb = [System.Text.StringBuilder]::new()
                    [void]$sb.AppendLine()
                    [void]$sb.AppendLine("Identity : $($_.Identity)")
                    [void]$sb.AppendLine("DisplayName : $($_.DisplayName)")
                    [void]$sb.AppendLine("Template : $($_.Template)")
                     
                    # Domain only exists for Hybrid user creation
                    if ($null -ne $_.Domain) {
                      [void]$sb.AppendLine("Domain : $($_.Domain)")
                    }
 
                    [void]$sb.AppendLine("Tenant : $($_.Tenant)")
                    [void]$sb.AppendLine("Type : $($_.Type)")
                    [void]$sb.AppendLine("Status : $($_.Status)")
                    if ($null -ne $_.Timestamp) {
                      [void]$sb.AppendLine("Timestamp : $($_.Timestamp.ToString('yyyy-MM-dd HH:mm:ss'))")
                    }
                    if ($null -ne $_.TaskLog -and $_.TaskLog.Count -gt 0) {
                      [void]$sb.AppendLine("TaskLog : $($_.TaskLog.Count) entries")
                      [void]$sb.AppendLine()
                      Format-EETaskLogEntries -StringBuilder $sb -TaskLog $_.TaskLog
                    } else {
                      [void]$sb.AppendLine("TaskLog : (empty)")
                    }
                    $sb.ToString()
                  }
                  catch {
                    "Error formatting output: $($_.Exception.Message)"
                  }
                </ScriptBlock>
              </ExpressionBinding>
            </CustomItem>
          </CustomEntry>
        </CustomEntries>
      </CustomControl>
    </View>
    <!--########### CreateUserFromTemplate Result (Hybrid & Entra) ##############-->
 
    <!--############### Decommission Result (Hybrid & Entra) ####################-->
    <View>
      <Name>EasyEntra.Decommission.Result</Name>
      <ViewSelectedBy>
        <TypeName>EasyEntra.Decommission.Result</TypeName>
      </ViewSelectedBy>
      <CustomControl>
        <CustomEntries>
          <CustomEntry>
            <CustomItem>
              <ExpressionBinding>
                <ScriptBlock>
                  try {
                    $sb = [System.Text.StringBuilder]::new()
                    [void]$sb.AppendLine()
                    [void]$sb.AppendLine("Identity : $($_.Identity)")
                     
                    # Domain only exists for Hybrid decommissions
                    if ($null -ne $_.Domain) {
                      [void]$sb.AppendLine("Domain : $($_.Domain)")
                    }
                     
                    [void]$sb.AppendLine("Tenant : $($_.Tenant)")
                    [void]$sb.AppendLine("Type : $($_.Type)")
                    [void]$sb.AppendLine("Status : $($_.Status)")
                     
                    if ($null -ne $_.Timestamp) {
                      [void]$sb.AppendLine("Timestamp : $($_.Timestamp.ToString('yyyy-MM-dd HH:mm:ss'))")
                    }
                     
                    # Show count of enabled decommission settings
                    if ($null -ne $_.DecommissionSettings) {
                      $settings = @($_.DecommissionSettings)
                      $enabledCount = ($settings | Where-Object { $_.Enabled }).Count
                       
                      [void]$sb.AppendLine("DecommissionSettings : $enabledCount of $($settings.Count) enabled")
                    } else {
                      [void]$sb.AppendLine("DecommissionSettings : (not specified)")
                    }
                     
                    if ($null -ne $_.TaskLog -and $_.TaskLog.Count -gt 0) {
                      [void]$sb.AppendLine("TaskLog : $($_.TaskLog.Count) entries")
                      [void]$sb.AppendLine()
                      Format-EETaskLogEntries -StringBuilder $sb -TaskLog $_.TaskLog
                    } else {
                      [void]$sb.AppendLine("TaskLog : (empty)")
                    }
                     
                    $sb.ToString()
                  }
                  catch {
                    "Error formatting output: $($_.Exception.Message)"
                  }
                </ScriptBlock>
              </ExpressionBinding>
            </CustomItem>
          </CustomEntry>
        </CustomEntries>
      </CustomControl>
    </View>
    <!--############### Decommission Result (Hybrid & Entra) ####################-->
 
    <!--##################### PST Export Result ##########################-->
    <View>
      <Name>EasyEntra.PstExport.Result</Name>
      <ViewSelectedBy>
        <TypeName>EasyEntra.PstExport.Result</TypeName>
      </ViewSelectedBy>
      <CustomControl>
        <CustomEntries>
          <CustomEntry>
            <CustomItem>
              <ExpressionBinding>
                <ScriptBlock>
                  try {
                    $sb = [System.Text.StringBuilder]::new()
                    # One label width per object: the ArchiveTotalMessages width when the
                    # archive lines show, otherwise the TotalMessages width (mailbox-only
                    # output unchanged).
                    $showArchive = -not [string]::IsNullOrEmpty($_.ArchiveOutputPath)
                    $w = if ($showArchive) { 'ArchiveTotalMessages'.Length } else { 'TotalMessages'.Length }
                    [void]$sb.AppendLine()
                    [void]$sb.AppendLine("$('Identity'.PadRight($w)) : $($_.Identity)")
                    [void]$sb.AppendLine("$('Tenant'.PadRight($w)) : $($_.Tenant)")
                    [void]$sb.AppendLine("$('Type'.PadRight($w)) : $($_.Type)")
                    [void]$sb.AppendLine("$('Status'.PadRight($w)) : $($_.Status)")
                    if ($null -ne $_.Timestamp) {
                      [void]$sb.AppendLine("$('Timestamp'.PadRight($w)) : $($_.Timestamp.ToString('yyyy-MM-dd HH:mm:ss'))")
                    }
                    [void]$sb.AppendLine("$('OutputPath'.PadRight($w)) : $($_.OutputPath)")
                    [void]$sb.AppendLine("$('TotalFolders'.PadRight($w)) : $($_.TotalFolders)")
                    [void]$sb.AppendLine("$('TotalMessages'.PadRight($w)) : $($_.TotalMessages)")
                    [void]$sb.AppendLine("$('FileSizeMB'.PadRight($w)) : $($_.FileSizeMB) MB")
                    if ($null -ne $_.PartPaths -and $_.PartPaths.Count -gt 1) {
                      [void]$sb.AppendLine("$('Parts'.PadRight($w)) : $($_.PartPaths.Count)")
                    }
                    if (-not [string]::IsNullOrEmpty($_.Scope)) {
                      [void]$sb.AppendLine("$('Scope'.PadRight($w)) : $($_.Scope)")
                    }
                    if ($showArchive) {
                      [void]$sb.AppendLine("$('ArchiveOutputPath'.PadRight($w)) : $($_.ArchiveOutputPath)")
                      [void]$sb.AppendLine("$('ArchiveTotalFolders'.PadRight($w)) : $($_.ArchiveTotalFolders)")
                      [void]$sb.AppendLine("$('ArchiveTotalMessages'.PadRight($w)) : $($_.ArchiveTotalMessages)")
                      [void]$sb.AppendLine("$('ArchiveFileSizeMB'.PadRight($w)) : $($_.ArchiveFileSizeMB) MB")
                      if ($null -ne $_.ArchivePartPaths -and $_.ArchivePartPaths.Count -gt 1) {
                        [void]$sb.AppendLine("$('ArchiveParts'.PadRight($w)) : $($_.ArchivePartPaths.Count)")
                      }
                    }
                    [void]$sb.AppendLine("$('Duration'.PadRight($w)) : $($_.Duration)")
                    if ($null -ne $_.StartDate) {
                      [void]$sb.AppendLine("$('StartDate'.PadRight($w)) : $($_.StartDate.ToString('yyyy-MM-dd'))")
                    }
                    if ($null -ne $_.EndDate) {
                      [void]$sb.AppendLine("$('EndDate'.PadRight($w)) : $($_.EndDate.ToString('yyyy-MM-dd'))")
                    }
                    if ($null -ne $_.SplitSizeBytes) {
                      [void]$sb.AppendLine("$('SplitSizeMB'.PadRight($w)) : $([math]::Round($_.SplitSizeBytes / 1MB, 1)) MB")
                    }
                    if ($null -ne $_.TaskLog -and $_.TaskLog.Count -gt 0) {
                      [void]$sb.AppendLine("$('TaskLog'.PadRight($w)) : $($_.TaskLog.Count) entries")
                      [void]$sb.AppendLine()
                      Format-EETaskLogEntries -StringBuilder $sb -TaskLog $_.TaskLog
                    } else {
                      [void]$sb.AppendLine("$('TaskLog'.PadRight($w)) : (empty)")
                    }
                    $sb.ToString()
                  }
                  catch {
                    "Error formatting output: $($_.Exception.Message)"
                  }
                </ScriptBlock>
              </ExpressionBinding>
            </CustomItem>
          </CustomEntry>
        </CustomEntries>
      </CustomControl>
    </View>
    <!--##################### PST Export Result ##########################-->
 
    <!--################## OneDrive Export Result #######################-->
    <View>
      <Name>EasyEntra.OneDriveExport.Result</Name>
      <ViewSelectedBy>
        <TypeName>EasyEntra.OneDriveExport.Result</TypeName>
      </ViewSelectedBy>
      <CustomControl>
        <CustomEntries>
          <CustomEntry>
            <CustomItem>
              <ExpressionBinding>
                <ScriptBlock>
                  try {
                    $sb = [System.Text.StringBuilder]::new()
                    [void]$sb.AppendLine()
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Identity', $_.Identity))
 
                    # Domain is cloud-only-empty for OneDrive; show only when present.
                    if (-not [string]::IsNullOrEmpty($_.Domain)) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Domain', $_.Domain))
                    }
 
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Tenant', $_.Tenant))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Type', $_.Type))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Status', $_.Status))
                    if ($null -ne $_.Timestamp) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Timestamp', $_.Timestamp.ToString('yyyy-MM-dd HH:mm:ss')))
                    }
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'OutputPath', $_.OutputPath))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'TotalItems', $_.TotalItems))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'IncludedCount', $_.IncludedCount))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'SkippedCount', $_.SkippedCount))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'ErrorCount', $_.ErrorCount))
                    [void]$sb.AppendLine(("{0,-15}: {1} MB" -f 'IncludedMB', [math]::Round($_.IncludedBytes / 1MB, 1)))
                    [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Duration', $_.Duration))
 
                    # Optional fields — shown only when present, mirroring the PST view's StartDate/EndDate.
                    if ($null -ne $_.PartPaths -and $_.PartPaths.Count -gt 1) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'Parts', $_.PartPaths.Count))
                    }
                    if (-not [string]::IsNullOrEmpty($_.ManifestPath)) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'ManifestPath', $_.ManifestPath))
                    }
                    if ($null -ne $_.ModifiedAfter) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'ModifiedAfter', $_.ModifiedAfter.ToString('yyyy-MM-dd')))
                    }
                    if ($null -ne $_.ModifiedBefore) {
                      [void]$sb.AppendLine(("{0,-15}: {1}" -f 'ModifiedBefore', $_.ModifiedBefore.ToString('yyyy-MM-dd')))
                    }
                    if ($null -ne $_.MaxFileSizeBytes) {
                      [void]$sb.AppendLine(("{0,-15}: {1} MB" -f 'MaxFileSizeMB', [math]::Round($_.MaxFileSizeBytes / 1MB, 1)))
                    }
                    if ($null -ne $_.SplitSizeBytes) {
                      [void]$sb.AppendLine(("{0,-15}: {1} MB" -f 'SplitSizeMB', [math]::Round($_.SplitSizeBytes / 1MB, 1)))
                    }
 
                    if ($null -ne $_.TaskLog -and $_.TaskLog.Count -gt 0) {
                      [void]$sb.AppendLine(("{0,-15}: {1} entries" -f 'TaskLog', $_.TaskLog.Count))
                      [void]$sb.AppendLine()
                      Format-EETaskLogEntries -StringBuilder $sb -TaskLog $_.TaskLog
                    } else {
                      [void]$sb.AppendLine(("{0,-15}: (empty)" -f 'TaskLog'))
                    }
                    $sb.ToString()
                  }
                  catch {
                    "Error formatting output: $($_.Exception.Message)"
                  }
                </ScriptBlock>
              </ExpressionBinding>
            </CustomItem>
          </CustomEntry>
        </CustomEntries>
      </CustomControl>
    </View>
    <!--################## OneDrive Export Result #######################-->
 
  </ViewDefinitions>
</Configuration>