Saturday, September 4, 2021

Get the office 365 Compliance report

Install-Module -Name ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement

$Credential = Get-Credential #-credential  used to connect Azure AD 

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking -AllowClobber

$StartDate=(((Get-Date).AddDays(-30))).Date  # Report for last 30 days 
$EndDate=Get-Date
$Operation="UserLoggedIn" #Login details
$Results=Search-UnifiedAuditLog  -UserIds 'Abc@abc.com' -StartDate $StartDate -EndDate $EndDate -operations $Operation -ResultSize 1 |select UserIds , CreationDate 
$Results

No comments:

Post a Comment

HTML

Script:

JS