[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$egurkhaPath=(Get-Item Env:EGURKHA_INSTALL_DIR).value.ToString()
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$egEncryPath=$scriptPath+"\EGFileEncryption.psm1"
$egDatnKy=$scriptPath+"\GetDatnKeyFiles.psm1"
Import-Module $egEncryPath,$egDatnKy

$testargs=$args
$userName=$testargs[0]
$Password=Eg-O365Dcr -EncStr $testargs[1]
$proxyUsr=$testargs[2]
$proxyPass=Eg-O365Dcr -EncStr $testargs[3]
$rName=$testargs[4]
if($proxyUsr.toString().toLower().Trim() -eq 'none') { $proxyUsr=$proxyUsr.toString().toLower().Trim() }
if($proxyPass.toString().toLower().Trim() -eq 'none') { $proxyPass=$proxyPass.toString().toLower().Trim() }

$RprtNameAndmTime=$rName.split("#")
$reportingname=$RprtNameAndmTime[0]
$mTime=$RprtNameAndmTime[1]

#-----------------------------
$domainSpecific=$false
if($reportingname -match '_exd'){
    $domainSpecific=$true
    $alldomainnames=@()
    $dhash=Eg-O635Domains -username $userName -password $Password -rptNam $reportingname -proxyserverip 'none' -proxyUsr $proxyUsr -proxyPass $proxyPass
    $reportingname=$dhash['SupersetName']
    foreach($h in $dhash.Keys){
        if($h -ne 'SupersetName'){
            $alldomainnames+=$h
        }
    }
    $DS_mxbx_Key='';$DS_mxbx_fpth='';$DS_mxbx_nam='';
    $DS_csmx_Key='';$DS_csmx_fpth='';$DS_csmx_nam='';
    $DS_rcpm_Key='';$DS_rcpm_fpth='';$DS_rcpm_nam='';
    $DS_rptmx_Key='';$DS_rptmx_fpth='';$DS_rptmx_nam='';
    $DS_stsmx_Key='';$DS_stsmx_fpth='';$DS_stsmx_nam='';
}
$rptPath='EXO/'+$reportingname
$chkwritPath=$egurkhaPath+'/agent/'+$rptPath
if($domainSpecific){ 
    $isWrite=Check-WriteFile -rptPath $chkwritPath -srchWrd 'EXOMailnDevices' -mTimInMin $mTime
}
$isProceed=$false
if($isWrite){
    $isProceed=$true
}elseif($domainSpecific -eq $false){
    $isProceed=$true
}else{
    $isProceed=$false
}
#--------------------------------
$servicSpecific=$false
if($reportingname -match '_exs'){
    $servicSpecific=$true
}
#--------------------------------

if($isProceed){
    $azureVal=Eg-GetAzureEnv -UserName $userName
    $azureEnvArr=$azureVal.Split(',')

    $ManualThrottle=0
    [double]$ActiveThrottle=.25
    $ResetSeconds=900

    $WriteLog=$true
    $LogFile = $egurkhaPath+'/agent/EXO/'+$reportingname+"\mail.log"
    $LogFile1 = $egurkhaPath+'/agent/EXO/'+$reportingname+"\mail1.log"
    $isFrstTimLog=$true

    # Writes output to a log file with a time date stamp
    Function Write-Log {
	    Param ([string]$string)
	    [string]$date = Get-Date -Format G
        if ($WriteLog) {
           ( "[" + $date + "] - [" + $reportingname+"] mTime -  " + $mTime + " - " + $string ) | Out-File -FilePath $LogFile -Append } 
        if($isFrstTimLog){     
            if ($WriteLog -eq $true){ #if flag is true 
                if ([System.IO.File]::Exists($LogFile) -and (Get-Item $LogFile).length -gt 2mb) {  #if the size of file is greater than 1MB 
                    if([System.IO.File]::Exists($LogFile1)){  #if logfile1 already exists, delete logfile1 
                        Remove-Item $LogFile1 
                    } 
                    Rename-Item $LogFile $LogFile1 
                }
            }
            $isFrstTimLog=$false
        }
    }

    Function Start-SleepWithProgress {
	    Param([int]$sleeptime)
	    For ($i=0;$i -le $sleeptime;$i++){
		    $timeleft = ($sleeptime - $i);
		    Write-Progress -Activity "Sleeping" -CurrentOperation "$Timeleft More Seconds" -PercentComplete (($i/$sleeptime)*100);
		    start-sleep 1
	    }
	    Write-Progress -Completed -Activity "Sleeping"
    }

    Function New-CleanO365Session {
        $Credential = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(convertto-securestring $Password -asplaintext -force)
        $i = 0
	    while (($Credential -eq $Null) -and ($i -lt 5)){
		    $script:Credential = Get-Credential -Message "Please provide your Exchange Online Credentials"
		    $i++
	    }
	    if ($Credential -eq $null){
		    Write-log ("[ "+$(Get-CurrentLineNumber) +" ] "+"[Error] - Failed to get credentials")
		    Write-Error -Message "Failed to get credentials" -ErrorAction Stop
	    }
	    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+"Removing all PS Sessions")
	    Get-PSSession | Remove-PSSession -Confirm:$false
	    [System.GC]::Collect()
	    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "Sleeping 15 seconds for Session Tear Down")
	    Start-SleepWithProgress -SleepTime 15
	    $Error.Clear()
	
	    # Create the session
	    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "Creating new PS Session")
	    $sessionOption = New-PSSessionOption -SkipRevocationCheck
	    if($proxyUsr -ne 'none' -and $proxyPass -ne 'none'){
	        $proxyCred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $proxyUsr, $(convertto-securestring $proxyPass -asplaintext -force)
	        $sessionOption = New-PSSessionOption -SkipRevocationCheck -ProxyAccessType WinHttpConfig -ProxyAuthentication basic -ProxyCredential $proxyCred
	    }
	    $global:session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $azureEnvArr[1] -Credential $Credential -Authentication Basic -AllowRedirection -SessionOption $sessionOption -WarningAction SilentlyContinue

	    # Check for an error while creating the session
	    if ($Error.Count -gt 0){
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "[ERROR] - Error while setting up session")
		    $ErrorCount++
		    if ($ErrorCount -gt 3){
			    $deleky=0
			    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "[ERROR] - Failed to setup session after multiple tries")
			    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "[ERROR] - Aborting Script")
                try{
                    if(Test-Path -path $global:writeTmpCsv){
                        Write-Log "Converting tmpmailboxstats to dat file due to unavailability of session"
                        $null=Protect-File  $global:writeTmpCsv -Algorithm AES -KeyAsPlainText $global:WriteTmpKey -RemoveSource
                    }
                }catch{
                    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "File stats cannot be converted to dat while aborting the script")
                }
			    exit
		    }
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "Sleeping 60s so that issue can potentially be resolved")
		    Start-SleepWithProgress -sleeptime 60
		    New-CleanO365Session
	    }
	    else {
		    $ErrorCount = 0
	    }	
	    # Import the PS session
	    $null = Import-PSSession $session -AllowClobber -WarningAction SilentlyContinue -DisableNameChecking
	
	    # Set the Start time for the current session
	    Set-Variable -Scope script -Name SessionStartTime -Value (Get-Date)
    }

    Function Test-O365Session {
	    $ObjectTime = Get-Date
	    $SessionInfo = $null
	    $SessionInfo = Get-PSSession
	    if ($SessionInfo -eq $null) { 
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "[ERROR] - No Session Found")
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "Recreating Session")
		    New-CleanO365Session
	    }	
	    elseif ($SessionInfo.State -ne "Opened"){
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "[ERROR] - Session not in Open State")
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ $SessionInfo | fl | Out-String )
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "Recreating Session")
		    New-CleanO365Session
	    }
	    elseif (($ObjectTime - $SessionStartTime).totalseconds -gt $ResetSeconds){
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "Session Has been active for greater than " + $ResetSeconds + " seconds" )
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+  "Rebuilding Connection")
		    [int]$DelayinSeconds = ((($ResetSeconds * $ActiveThrottle) / 2) - 15)
		    if ($DelayinSeconds -gt 0){
			    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "Sleeping " + $DelayinSeconds + " addtional seconds to allow throttle recovery")
			    Start-SleepWithProgress -SleepTime $DelayinSeconds
		    }
		    else{
			    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "Active Delay calculated to be " + ($DelayinSeconds + 15) + " seconds no addtional delay needed")
		    }
		    New-CleanO365Session
	    }
	    else{
		    #Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "the session "+ $SessionInfo +" state is "+$SessionInfo.State)
	    }
	    if ($ManualThrottle -gt 0){
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "Sleeping " + $ManualThrottle + " milliseconds")
		    Start-Sleep -Milliseconds $ManualThrottle
	    }
    }

    Function Get-EstimatedTimeToCompletion {
	    param([int]$ProcessedCount)
	    $ProcessedCount++
	    if (($ProcessedCount % 100) -eq 0){
		    $CurrentDate = Get-Date
		    $AveragePerObject = (((($CurrentDate) - $ScriptStartTime).totalseconds) / $ProcessedCount)
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[STATS] - Total Number of Objects:     " + $ObjectCount)
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[STATS] - Number of Objects processed: " + $ProcessedCount)
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[STATS] - Average seconds per object:  " + $AveragePerObject)
		    Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[STATS] - Estimated completion time:   " + $CurrentDate.addseconds((($ObjectCount - $ProcessedCount) * $AveragePerObject)))
	    }
	    return $ProcessedCount
    }

    function Get-CurrentLineNumber {
        $MyInvocation.ScriptLineNumber
    }


    $rptPath='EXO/'+$reportingname
    $MyDir=$egurkhaPath+'/agent/EXO/'+$reportingname
    if(!(Test-Path -Path $MyDir )){
        New-Item -ItemType directory -Path $MyDir
    }
    $isErrorOccur= $false
    Set-StrictMode -Version 2
    $ErrorCount = 0
    $TotMailbxcnt=""

    if(!$servicSpecific){
        $Error.Clear()
        try{
            New-CleanO365Session
            $Mailboxes = Eg-WriteFile -ComntRptPath $rptPath -FileName "mailbox" -keyFileName "kmailbox" -EgPath $egurkhaPath
            $results=invoke-command -scriptblock {Get-mailbox -resultsize unlimited |
                select-object -property Displayname, PrimarySMTPAddress, Identity, WasInactiveMailbox, SKUAssigned,
                RecipientTypeDetails, LitigationHoldEnabled, DeliverToMailboxAndForward, InPlaceHolds, UserPrincipalName,ArchiveStatus,Name,ArchiveName,ArchiveState,ArchiveQuota,ArchiveWarningQuota,
                ForwardingSmtpAddress, ServerName, Database, Location, Datacenter, AuditAdmin,GrantSendOnBehalfTo,IssueWarningQuota,ProhibitSendQuota,ProhibitSendReceiveQuota,IsInactiveMailbox, WhenChanged, WhenCreated, WhenSoftDeleted
            } -session (get-pssession) # | export-csv $Mailboxes[1]
            $results | ?{$_.SKUAssigned -eq $true} | export-csv $Mailboxes[1]
        }
        Catch{
            $ErrorMessage = $_.Exception.Message 
            $isErrorOccur=$true      
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ " ErrorMessage while running Mailbox : "+$ErrorMessage)  
            Write-Log $Error
            $TotMailbxcnt=""
        } 
        if($isErrorOccur -eq $true -or  (Get-Item $Mailboxes[1]).length -le 2kb){ 
            Remove-Item $Mailboxes[1] 
        }
        else{
            $DS_mxbx_Key=$Mailboxes[0];$DS_mxbx_fpth=$Mailboxes[1];$DS_mxbx_nam=$Mailboxes[2];  
            $TotMailbxcnt = import-csv  $Mailboxes[1]
            $null=Protect-File  $Mailboxes[1] -Algorithm AES -KeyAsPlainText $Mailboxes[0] -RemoveSource
        }

        $Error.Clear()
        try{
            Test-O365Session
            $casMailboxes = Eg-WriteFile -ComntRptPath $rptPath -FileName "casmailboxes" -keyFileName "Kcasmailboxes" -EgPath $egurkhaPath
            invoke-command -scriptblock { Get-CASMailbox -resultsize unlimited  | select-object ActiveSyncEnabled,Name ,Displayname, Guid, PrimarySMTPAddress
            } -session (get-pssession) | export-csv $casMailboxes[1]
        }Catch{
            $ErrorMessage = $_.Exception.Message
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "ErrorMessage while running CASMailbox : "+$ErrorMessage)  
            $isErrorOccur=$true
        } 

        if($isErrorOccur -eq $true -or (Get-Item $casMailboxes[1]).length -le 2kb){
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Deleted File Error in excuting the CASMailbox ")
            Remove-Item $casMailboxes[1]
        }
        else{
            $DS_csmx_Key=$casMailboxes[0];$DS_csmx_fpth=$casMailboxes[1];$DS_csmx_nam=$casMailboxes[2];
            $null=Protect-File  $casMailboxes[1] -Algorithm AES -KeyAsPlainText $casMailboxes[0] -RemoveSource
        }
    }

    if(!$servicSpecific){
        $Error.Clear()
        try{
            Test-O365Session
            $RecipntPerm = Eg-WriteFile -ComntRptPath $rptPath -FileName "RecipntPerm" -keyFileName "kRecipntPerm" -EgPath $egurkhaPath
	        if($TotMailbxcnt -ne $null -and $TotMailbxcnt -ne ''){
		        $UserMailbox=$TotMailbxcnt|?{$_.RecipientTypeDetails -eq 'UserMailbox'}
		        $UserMailbox | Get-RecipientPermission  -ResultSize Unlimited  | ? {$_.Trustee -ne "NT AUTHORITY\SELF" -and $_.Trustee -ne "NULL SID"} | Export-Csv $RecipntPerm[1]
	        }
        }
        Catch{
            $ErrorMessage = $_.Exception.Message
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "ErrorMessage while running RecipientPermission : "+$ErrorMessage)  
            $isErrorOccur=$true
        } 
        if($isErrorOccur -eq $true) { # -and (Get-Item $RecipntPerm[1]).length -le 2kb){
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Error in excuting the RecipientPermission cmdlet")
	        Write-Log $Error
            Remove-Item $RecipntPerm[1]
        }else{
            $DS_rcpm_Key=$RecipntPerm[0];$DS_rcpm_fpth=$RecipntPerm[1];$DS_rcpm_nam=$RecipntPerm[2];
            $null=Protect-File  $RecipntPerm[1] -Algorithm AES -KeyAsPlainText $RecipntPerm[0] -RemoveSource   
        }
    }

    if(!$servicSpecific){
        $Error.Clear()
        try{
            Test-O365Session
            $Recpnt = Eg-WriteFile -ComntRptPath $rptPath -FileName "recipients" -keyFileName "krecipients" -EgPath $egurkhaPath
            $results=  invoke-command -scriptblock { Get-Recipient -ResultSize Unlimited |
                                                Select-Object -property PrimarySMTPAddress,SKUAssigned,RecipientTypeDetails,Name ,Displayname, Guid
                                        } -session (get-pssession)  | export-csv $Recpnt[1]
            #$results | ?{$_.SKUAssigned -eq $true} | export-csv $Recpnt[1]
        }Catch{
            $ErrorMessage = $_.Exception.Message
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "ErrorMessage while running Recipient : "+$ErrorMessage)  
            $isErrorOccur=$true
        } 
        if($isErrorOccur -eq $true -or (Get-Item $Recpnt[1]).length -le 2kb){
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Error in excuting the Recipient ")
            Remove-Item $Recpnt[1]
        }else{
            $DS_rptmx_Key=$Recpnt[0];$DS_rptmx_fpth=$Recpnt[1];$DS_rptmx_nam=$Recpnt[2];
            $null=Protect-File  $Recpnt[1] -Algorithm AES -KeyAsPlainText $Recpnt[0] -RemoveSource       
        }
    }

    if(!$domainSpecific){
        $Error.Clear()
        $isErrorOccur=$false
        try{
        $DeviceStats = Eg-WriteFile -ComntRptPath $rptPath -FileName "devicestats" -keyFileName "kdevicestats" -EgPath $egurkhaPath
	    Test-O365Session
        Invoke-Command  -ScriptBlock { 
                    Get-MobileDevice -ResultSize Unlimited | 
                    select-Object WhenChangedUTC,DeviceType, DeviceUserAgent, DeviceOS, DeviceOSLanguage, Identity, ClientType }| Export-CSV -LiteralPath $DeviceStats[1]
        }catch{
            $isErrorOccur =$true
	    }
        if($isErrorOccur -eq $true -or (Get-Item $DeviceStats[1]).length -le 2kb){
            Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Error while fetching mobiledevices. Deleting the incomplete dat file")
            Remove-Item $DeviceStats[1]
        }else{
            $null=Protect-File  $DeviceStats[1] -Algorithm AES -KeyAsPlainText $DeviceStats[0] -RemoveSource 
        }
    }
    if(!$servicSpecific){
        try{
            $Error.Clear()
            $o365Domain=Eg-GetDomain -userName $userName -Password $Password -proxyUsr $proxyUsr -proxyPass $proxyPass -IsIntial $true -proxyserver 'none'
            $GraphDir=$egurkhaPath+'\agent\O365\MsGraph'
            $unProtPath=$GraphDir+'\GraphDetails.dat'
            $keyFileNam='\GraphDetailsKey.dat'
            $kvalue=Get-Content -Path $GraphDir$keyFileNam
            $null=Unprotect-File $unProtPath -Algorithm AES -KeyAsPlainText $kvalue -DstSuffix '.ini'
            $spoGraphDtls=$GraphDir+"\GraphDetails.ini"
            $getInputs=Get-Content -Path $spoGraphDtls
            Remove-Item $spoGraphDtls
            $flag=$false
            foreach($input in $getInputs){
                if($input.StartsWith('[') -and $input.ToLower().Contains($o365Domain.ToLower())){
                    $flag=$true
                }
                if($flag){
                    if($input.Contains("client_id")){
                        $appId=$input.ToString().Substring($input.IndexOf('~')+1)
                    }
                    if($input.Contains("client_secret")){
                        $appSecret=$input.ToString().Substring($input.IndexOf('~')+1)
                    }
                    if($input.Contains("TenantName")){
                        $tenantID=$input.ToString().Substring($input.IndexOf('~')+1)
                    }
                    if($input.Contains("Authority")){
                        $authString=$input.ToString().Substring($input.IndexOf('~')+1)
                        $authString=$authString+$o365Domain
                    }
                    if($input.Contains("Resource")){
                        $resource=$input.ToString().Substring($input.IndexOf('~')+1)
                        $flag=$false
                    }
                }         
            }
            $path=(([XML]((Get-Package -Name AzureAD  | select SwidTagText)).SwidTagText).SoftwareIdentity.Meta.InstalledLocation)+'\Microsoft.IdentityModel.Clients.ActiveDirectory.dll'
            Add-Type -Path $path
            try{
                $mailboxStats = Eg-WriteFile -ComntRptPath $rptPath -FileName "statsmailbox" -keyFileName "kstatsmailbox" -EgPath $egurkhaPath
                $creds = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential" -ArgumentList $appId, $appSecret
                $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext"-ArgumentList $authString
                $context = $authContext.AcquireTokenAsync($resource, $creds).Result
                $authCode=$context.CreateAuthorizationHeader()
                $header = @{
                    'Authorization'=$authCode
                }
                $queryRes = Invoke-RestMethod -Method 'Get' -Headers $header -Uri "https://graph.microsoft.com/v1.0/reports/getMailboxUsageDetail(period='D7')"
                $queryRes=$queryRes.Replace('ï»¿','')
                $queryRes=$queryRes.Replace('(Byte)','')
                $queryRes=$queryRes.Replace(' ','')
                $resultarray = ConvertFrom-Csv -InputObject $queryRes
                foreach($rs in $resultarray){
                    $rs | Export-Csv $mailboxStats[1] -Append -Force
                }
                #$resultarray | ForEach-Object{$_ | Export-Csv $mailboxStats[1] -Append}
            }
            catch{
                Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Error occured in graphapi - mailboxStats ")
                $isErrorOccur =$true
            }
            if($isErrorOccur -eq $true -or (Get-Item $mailboxStats[1]).length -le 2kb){
                Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "[ERROR] - Error while fetching mailboxStats. Deleting the incomplete dat file")
                Remove-Item $mailboxStats[1]
            }else{   
                $DS_stsmx_Key=$mailboxStats[0];$DS_stsmx_fpth=$mailboxStats[1];$DS_stsmx_nam=$mailboxStats[2];
                $null=Protect-File $mailboxStats[1] -Algorithm AES -KeyAsPlainText $mailboxStats[0] -RemoveSource
            }
        }Catch{ 
                $ErrorMessage = $_.Exception.Message
                Write-Log ("[ "+$(Get-CurrentLineNumber) +" ] "+ "ErrorMessage while running mailbox/device statistics : "+$ErrorMessage)       
        }
    }

    Write-Log "Script Complete Destroying PS Sessions"
    Get-PSSession | Remove-PSSession -Confirm:$false
}

if($domainSpecific -and $servicSpecific -eq $false){  
    #------------- 1.For Domain Specific - mailbox ---------------------- 
    if($DS_mxbx_fpth -ne ''){
        $mxbxFilePth=$DS_mxbx_fpth -replace (".csv",".dat")   
        if((Get-Item -Path $mxbxFilePth).Length -gt 2KB){
            $null=Unprotect-File $mxbxFilePth -Algorithm AES -KeyAsPlainText $DS_mxbx_Key
            $mailbxs= import-csv $DS_mxbx_fpth
            $nam=$DS_mxbx_nam.ToString()
            foreach($domain in $alldomainnames){
                $isAddContent=$false
                $domainDir=$egurkhaPath+'/agent/EXO/'+$dhash[$domain]
                if(!(Test-Path -Path $domainDir )){
                    New-Item -ItemType directory -Path $domainDir
                }        
                $rptDpth=$domainDir+'/'+$nam
                foreach($tmpRes in $mailbxs){
                    if($tmpRes.PrimarySmtpAddress -match $domain -and $tmpRes.SKUAssigned -eq $true){
                        $isAddContent=$true
                        $tmpRes| export-csv $rptDpth -Append
                    }
                }
                if($isAddContent){
                    $knam=$nam.Replace("csv","dat")
                    $kDpth=$domainDir+'/k'+$knam
                    $DS_mxbx_Key|Add-Content $kDpth
                    $null=Protect-File $rptDpth -Algorithm AES -KeyAsPlainText $DS_mxbx_Key -RemoveSource
                }
            }
        }
    }

    #------------- 2.Domain Specific - casmailboxes ----------------------
    if($DS_csmx_fpth -ne ''){   
        $csmxFilePth=$DS_csmx_fpth -replace (".csv",".dat")
        if((Get-Item -Path $csmxFilePth).Length -gt 2KB){
            $null=Unprotect-File $csmxFilePth -Algorithm AES -KeyAsPlainText $DS_csmx_Key
            $csmailbxs= import-csv $DS_csmx_fpth
            $csnam=$DS_csmx_nam.ToString()
            foreach($domain in $alldomainnames){
                $isAddContent=$false
                $domainDir=$egurkhaPath+'/agent/EXO/'+$dhash[$domain]
                if(!(Test-Path -Path $domainDir )){
                    New-Item -ItemType directory -Path $domainDir
                }        
                $rptDpth=$domainDir+'/'+$csnam
                foreach($tmpRes in $csmailbxs){
                    if($tmpRes.PrimarySMTPAddress -match $domain){
                        $isAddContent=$true
                        $tmpRes| export-csv $rptDpth -Append
                    }
                }
                if($isAddContent){
                    $knam=$csnam.Replace("csv","dat")
                    $kDpth=$domainDir+'/k'+$knam
                    $DS_csmx_Key|Add-Content $kDpth
                    $null=Protect-File $rptDpth -Algorithm AES -KeyAsPlainText $DS_csmx_Key -RemoveSource
                }
            }
        }
    }


    #$DS_rcpm_Key=$RecipntPerm[0];$DS_rcpm_fpth=$RecipntPerm[1];$DS_rcpm_nam=$RecipntPerm[2];
     #------------- 3.Domain Specific - recipient Permissions ----------------------
    if($DS_rcpm_fpth -ne ''){  
        $rpcmTFilePth=$DS_rcpm_fpth -replace (".csv",".dat")
        if((Get-Item -Path $rpcmTFilePth).Length -gt 2KB){
            $null=Unprotect-File $rpcmTFilePth -Algorithm AES -KeyAsPlainText $DS_rcpm_Key
            $rcpts= import-csv $DS_rcpm_fpth
            $rpnam=$DS_rcpm_nam.ToString()
            foreach($domain in $alldomainnames){
                $isAddContent=$false
                $domainDir=$egurkhaPath+'/agent/EXO/'+$dhash[$domain]
                if(!(Test-Path -Path $domainDir )){
                    New-Item -ItemType directory -Path $domainDir
                }        
                $rptDpth=$domainDir+'/'+$rpnam
                foreach($tmpRes in $rcpts){
                    if($tmpRes.PrimarySMTPAddress -match $domain){
                        $isAddContent=$true
                        $tmpRes| export-csv $rptDpth -Append
                    }
                }
                if($isAddContent){
                    $knam=$rpnam.Replace("csv","dat")
                    $kDpth=$domainDir+'/k'+$knam
                    $DS_rcpm_Key|Add-Content $kDpth
                    $null=Protect-File $rptDpth -Algorithm AES -KeyAsPlainText $DS_rcpm_Key -RemoveSource
                }
            }
        }
    }
        
    #------------- 4.Domain Specific - recipients ----------------------
    if($DS_rptmx_fpth -ne ''){  
        $rptmxFilePth=$DS_rptmx_fpth -replace (".csv",".dat")
        if((Get-Item -Path $rptmxFilePth).Length -gt 2KB){
            $null=Unprotect-File $rptmxFilePth -Algorithm AES -KeyAsPlainText $DS_rptmx_Key
            $rcpts= import-csv $DS_rptmx_fpth
            $rpnam=$DS_rptmx_nam.ToString()
            foreach($domain in $alldomainnames){
                $isAddContent=$false
                $domainDir=$egurkhaPath+'/agent/EXO/'+$dhash[$domain]
                if(!(Test-Path -Path $domainDir )){
                    New-Item -ItemType directory -Path $domainDir
                }        
                $rptDpth=$domainDir+'/'+$rpnam
                foreach($tmpRes in $rcpts){
                    if($tmpRes.PrimarySMTPAddress -match $domain){
                        $isAddContent=$true
                        $tmpRes| export-csv $rptDpth -Append
                    }
                }
                if($isAddContent){
                    $knam=$rpnam.Replace("csv","dat")
                    $kDpth=$domainDir+'/k'+$knam
                    $DS_rptmx_Key|Add-Content $kDpth
                    $null=Protect-File $rptDpth -Algorithm AES -KeyAsPlainText $DS_rptmx_Key -RemoveSource
                }
            }
        }
    }

    #------------- 5.For Domain Specific - statsmailbox ----------------------
    if($DS_stsmx_fpth -ne ''){
        $stsmxFilePth=$DS_stsmx_fpth -replace (".csv",".dat")
        if((Get-Item -Path $stsmxFilePth).Length -gt 2KB){
            $null=Unprotect-File $stsmxFilePth -Algorithm AES -KeyAsPlainText $DS_stsmx_Key
            $dstat= import-csv $DS_stsmx_fpth
            $dsnam=$DS_stsmx_nam.ToString()
            foreach($domain in $alldomainnames){
                $isAddContent=$false
                $domainDir=$egurkhaPath+'/agent/EXO/'+$dhash[$domain]
                if(!(Test-Path -Path $domainDir )){
                    New-Item -ItemType directory -Path $domainDir
                }        
                $rptDpth=$domainDir+'/'+$dsnam
                foreach($tmpRes in $dstat){
                    if($tmpRes.UserPrincipalName -match $domain){
                        $isAddContent=$true
                        $tmpRes| export-csv $rptDpth -Append
                    }
                }
                if($isAddContent){
                    $knam=$dsnam.Replace("csv","dat")
                    $kDpth=$domainDir+'/k'+$knam
                    $DS_stsmx_Key|Add-Content $kDpth
                    $null=Protect-File $rptDpth -Algorithm AES -KeyAsPlainText $DS_stsmx_Key -RemoveSource
                }
            }
        }
    }
}

$csvDir=$egurkhaPath+'/agent/EXO/'+$reportingname+'/'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'mailbox'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'casmailboxes'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'RecipntPerm'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'recipients'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'statsmailbox'
Eg-DeleteCsvFiles -FilePath $csvDir -Pattern 'devicestats'
# SIG # Begin signature block
# MIIcdAYJK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