DataGathering/FreeBusy-EXO.txt

#DO NOT MODIFY ANY OF THE COMMANDS BELOW
[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
$RemoteAddress = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the remote user's email address in the format user@domain.com", "Remote Address")
$LocalAddress = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the local user's email address in the format user@domain.com", "Local Address")
$Folder = "$env:temp\MSDataCollection"
New-Item -Path $folder -ItemType Directory -erroraction silentlycontinue|out-null
Set-Location $folder
$FormatEnumerationLimit = -1
Get-FederationTrust -erroraction silentlycontinue |Export-CliXML "Cloud_FedTrust.xml"
Get-FederatedOrganizationIdentifier -erroraction silentlycontinue |Export-CliXML "Cloud_FedOrgID.xml"
Get-OrganizationRelationship -erroraction silentlycontinue |Export-CliXML "Cloud_OrgRel.xml"
 
#User queries
$remoteuser = get-recipient $RemoteAddress -RecipientTypeDetails Mailuser, MailContact, RemoteUserMailbox -erroraction silentlyContinue
if ($remoteUser) {$remoteAddress = $remoteuser.ExternalEmailAddress.ToString().split(":")[1]}
$Remotedomain = $RemoteAddress.Split("@")[1]
$localuser = get-mailbox $LocalAddress -erroraction SilentlyContinue
if ($localuser) {$localAddress = $localuser.PrimarySmtpAddress.ToString()}
$localdomain = $localAddress.Split("@")[1]
 
Test-OrganizationRelationship -Identity (get-organizationrelationship |Where-Object {$_.DomainNames -match $RemoteDomain}).Identity -UserIdentity $RemoteAddress -erroraction silentlycontinue | export-clixml cloudtestOrg.xml
Get-AvailabilityAddressSpace -erroraction silentlycontinue |Export-CliXML "Cloud_AvailAddrSpc.xml"
Get-IntraOrganizationConnector -erroraction silentlycontinue |Export-CliXML "Cloud_IntraOrgConn.xml"
Get-FederationInformation -Domainname $RemoteDomain -erroraction silentlycontinue |Export-CliXML "Cloud_FedInfo.xml"
Invoke-item $Folder