Skip to content

Commit

Permalink
241031(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioxx committed Nov 19, 2024
1 parent 42695b6 commit 9fbc2ed
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 197 deletions.
23 changes: 14 additions & 9 deletions Gioxx.ToyBox/Calendar/GTB.Calendar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,31 @@ function Export-CalendarPermission {
param(
[Parameter(Mandatory=$False, ValueFromPipeline=$True, HelpMessage="Mailbox to analyze (e.g. [email protected])")]
[string[]] $SourceMailbox,
[Parameter(Mandatory=$False, ValueFromPipeline=$True, HelpMessage="Domain to analyze (e.g. contoso.com)")]
[string] $SourceDomain,
[Parameter(Mandatory=$False, HelpMessage="Folder where export CSV file (e.g. C:\Temp)")]
[string] $folderCSV,
[Parameter(Mandatory=$False, ValueFromPipeline=$True, HelpMessage="Export all mailboxes calendar permissions")]
[switch] $All
)

begin {
$previousProgressPreference = $ProgressPreference
Set-Variable ProgressPreference Continue

priv_SetPreferences -Verbose
$eolConnectedCheck = priv_CheckEOLConnection
$mboxCounter = 0
$arr_CalPerm = @()
$eolConnectedCheck = priv_CheckEOLConnection

if ( $eolConnectedCheck -eq $true ) {
if ([string]::IsNullOrEmpty($SourceMailbox)) {
Write-Warning "WARNING: no mailbox(es) specified, I scan all the mailboxes, please be patient."
if ( $eolConnectedCheck -eq $true ) {
if ([string]::IsNullOrEmpty($SourceMailbox) -And [string]::IsNullOrEmpty($SourceDomain)) {
Write-Warning "WARNING: no mailbox(es) or domain(s) specified, I scan all the mailboxes, please be patient."
$All = $True
}

if (-not([string]::IsNullOrEmpty($SourceDomain))) {
Write-InformationColored "Analyzing mailboxes in $($SourceDomain) ..." -ForegroundColor Cyan
$SourceMailbox = Get-Mailbox -ResultSize Unlimited -WarningAction SilentlyContinue | Where { $_.RecipientTypeDetails -ne "GuestMailUser" -And $_.EmailAddresses -like "*@" + $SourceDomain }
}

if ($All) {
$SourceMailbox = Get-Mailbox -ResultSize Unlimited -WarningAction SilentlyContinue
}
Expand Down Expand Up @@ -86,7 +91,7 @@ function Export-CalendarPermission {
$arr_CalPerm | Out-Host
}

Set-Variable ProgressPreference $previousProgressPreference
priv_RestorePreferences
}
}

Expand Down Expand Up @@ -140,7 +145,7 @@ function Set-OoO {
$previousMessage = Get-MailboxAutoReplyConfiguration -Identity $SourceMailbox | Select -ExpandProperty ExternalMessage
if ( [string]::IsNullOrEmpty($previousMessage) ) {
$proposedText = "I'm out of office and will have limited access to my mailbox.<br />
I will reply to your email as soon as possible.
I will reply to your e-mail as soon as possible.
<br /><br />
Have a nice day."
} else { $proposedText = $previousMessage }
Expand Down
3 changes: 2 additions & 1 deletion Gioxx.ToyBox/Gioxx.ToyBox.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"Add-MboxPermission",
"Change-MboxLanguage",
"Change-MFAStatus",
"Check-SharedMailboxCompliance",
"Clone-OoOMessage",
"Connect-EOL",
"Connect-MSOnline",
Expand Down Expand Up @@ -86,7 +87,7 @@
# ReleaseNotes of this module
# ReleaseNotes = ''

Prerelease = '20240924(3)'
Prerelease = '241031(1)'
RequireLicenseAcceptance = $False

}
Expand Down
25 changes: 16 additions & 9 deletions Gioxx.ToyBox/Groups/GTB.Groups.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function Export-DG {
[switch] $GridView
)

Set-Variable ProgressPreference Continue
priv_SetPreferences -Verbose
$eolConnectedCheck = priv_CheckEOLConnection
$DGsCounter = 0
$arr_ExportedDG = @()
$eolConnectedCheck = priv_CheckEOLConnection

if ( $eolConnectedCheck -eq $true ) {
if ( [string]::IsNullOrEmpty($DG) ) { $All = $True } else { $DGs = Get-DistributionGroup $DG }
Expand Down Expand Up @@ -78,6 +78,8 @@ function Export-DG {
} else {
Write-Error "`nCan't connect or use Microsoft Exchange Online Management module. `nPlease check logs."
}

priv_RestorePreferences
}

function Export-DDG {
Expand All @@ -94,10 +96,10 @@ function Export-DDG {
[switch] $GridView
)

Set-Variable ProgressPreference Continue
priv_SetPreferences -Verbose
$eolConnectedCheck = priv_CheckEOLConnection
$DDGsCounter = 0
$arr_ExportedDDG = @()
$eolConnectedCheck = priv_CheckEOLConnection

if ( $eolConnectedCheck -eq $true ) {
if ( [string]::IsNullOrEmpty($DDG) ) { $All = $True } else { $DDGs = Get-DynamicDistributionGroup $DDG }
Expand Down Expand Up @@ -158,6 +160,8 @@ function Export-DDG {
} else {
Write-Error "`nCan't connect or use Microsoft Exchange Online Management module. `nPlease check logs."
}

priv_RestorePreferences
}

function Export-M365Group {
Expand All @@ -174,10 +178,10 @@ function Export-M365Group {
[switch] $GridView
)

Set-Variable ProgressPreference Continue
priv_SetPreferences -Verbose
$eolConnectedCheck = priv_CheckEOLConnection
$M365GsCounter = 0
$arr_ExportedM365Groups = @()
$eolConnectedCheck = priv_CheckEOLConnection

if ( $eolConnectedCheck -eq $true ) {
if ( [string]::IsNullOrEmpty($M365G) ) { $All = $True } else { $M365Gs = Get-UnifiedGroup $M365G }
Expand Down Expand Up @@ -238,10 +242,13 @@ function Export-M365Group {
} else {
Write-Error "`nCan't connect or use Microsoft Exchange Online Management module. `nPlease check logs."
}

priv_RestorePreferences
}

function Get-RoleGroupsMembers {
Set-Variable ProgressPreference Continue
priv_SetPreferences

$eolConnectedCheck = priv_CheckEOLConnection

if ( $eolConnectedCheck -eq $true ) {
Expand Down Expand Up @@ -288,14 +295,14 @@ function Get-UserGroups {
Write-Host "Recipient not available or not found ($($UserPrincipalName))." -f "Red"
break
} elseif ($emailAddresses.Count -gt 1) {
Write-Host "Complete e-mail address not specified, multiple email addresses found:" -f "Cyan"
Write-Host "Complete e-mail address not specified, multiple e-mail addresses found:" -f "Cyan"
$emailAddresses | ForEach-Object { Write-Host $_.Replace('SMTP:', ' ') }
Write-Host "Run the command again but specify the full address to perform a more accurate search." -f "Cyan"
$UserPrincipalName = (Get-Recipient $UserPrincipalName).PrimarySmtpAddress | Select-Object -First 1
Write-Host "First user selected: $($UserPrincipalName)" -f "Cyan"
} else {
$UserPrincipalName = (Get-Recipient $UserPrincipalName).PrimarySmtpAddress
Write-Host "Complete e-mail address not specified, user found: $($UserPrincipalName)" -f "Cyan"
Write-Host "Complete e-mail address not specified, first match found: $($UserPrincipalName)" -f "Cyan"
}
} catch {
Write-Error $_.Exception.Message
Expand Down
Loading

0 comments on commit 9fbc2ed

Please sign in to comment.