add outputs to script (#2834)

Some quick QoL
This commit is contained in:
Keepers 2023-03-16 23:07:01 -06:00 committed by GitHub
parent 8dfb00f308
commit 968f51616f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -31,7 +31,7 @@ function Get-AccessToken {
Param()
if ([String]::IsNullOrEmpty($TenantId) -or [String]::IsNullOrEmpty($ClientId) -or [String]::IsNullOrEmpty($ClientSecret)) {
Write-Host "Need to specify TenantId, ClientId, and ClientSecret as parameters or ENVs"
Write-Host "`nNeed to specify TenantId, ClientId, and ClientSecret as parameters or ENVs"
}
$body=@{
@ -130,7 +130,7 @@ function Remove-Folder {
</FindFolder>
"@
Write-Host "Looking for folders under well-known folder: $WellKnownRoot & matching folder: $FolderNamePurge$FolderNamePrefixPurge & for user: $User"
Write-Host "`nLooking for folders under well-known folder: $WellKnownRoot & matching folder: $FolderNamePurge$FolderNamePrefixPurge & for user: $User"
$getFolderIdMsg = Initialize-SOAPMessage -User $User -Body $body
$response = Invoke-SOAPRequest -Token $Token -Message $getFolderIdMsg
@ -160,10 +160,10 @@ function Remove-Folder {
}
if (![String]::IsNullOrEmpty($FolderNamePurge)) {
Write-Host "Found desired folder to purge: $FolderNamePurge"
Write-Host "`nFound desired folder to purge: $FolderNamePurge"
}
Write-Verbose "Folder Id and ChangeKey for ""$folderName"": $folderId, $changeKey"
Write-Verbose "`nFolder Id and ChangeKey for ""$folderName"": $folderId, $changeKey"
# Empty and delete the folder if found
if (![String]::IsNullOrEmpty($folderId) -and ![String]::IsNullOrEmpty($changeKey)) {

View File

@ -15,12 +15,21 @@ if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) {
Install-Module -Name ExchangeOnlineManagement -MinimumVersion 3.0.0 -Force
}
Write-Host "Connecting to Exchange..."
Write-Host "`nConnecting to Exchange..."
$password = convertto-securestring -String "$AdminPwd" -AsPlainText -Force
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminUser, $password
Connect-ExchangeOnline -Credential $cred
Write-Host "Resetting retention..."
Write-Host "`nResetting retention..."
# Set retention values for all mailboxes
Get-Mailbox | ForEach-Object { Set-Mailbox -Identity $_.Alias -RetentionHoldEnabled $false -LitigationHoldEnabled $false -SingleItemRecoveryEnabled $false -RetainDeletedItemsFor 0 -AuditLogAgeLimit 0 -Force }
Get-Mailbox | ForEach-Object { Start-ManagedFolderAssistant -Identity $_.Alias }
Get-Mailbox | ForEach-Object {
Write-Host "...for" $_
Set-Mailbox -Identity $_.Alias `
-RetentionHoldEnabled $false `
-LitigationHoldEnabled $false `
-SingleItemRecoveryEnabled $false `
-RetainDeletedItemsFor 0 `
-AuditLogAgeLimit 0 `
-Force
}