-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from BNWEIN/Dev
Added some example scripts
- Loading branch information
Showing
7 changed files
with
240 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
# Set-CIPPMailboxForwarding | ||
## SYNOPSIS | ||
|
||
Set-CIPPMailboxForwarding [-CustomerTenantID] <string> [-UserID] <string> [[-DisableForwarding] <bool>] [[-ForwardExternalEmailAddress] <string>] [[-ForwardInternalEmailAddress] <string>] [[-KeepCopy] <bool>] [<CommonParameters>] | ||
|
||
Sets mailbox forwarding for a user. | ||
## DESCRIPTION | ||
|
||
The Set-CIPPMailboxForwarding function sets mailbox forwarding for a user. It allows you to specify the customer tenant ID, user ID, and various forwarding options such as external and internal email addresses, disabling forwarding, and keeping a copy of forwarded emails. | ||
# PARAMETERS | ||
|
||
## **-CustomerTenantID** | ||
>   \ | ||
>   \ | ||
The ID of the customer tenant. | ||
|
||
## **-UserID** | ||
>   \ | ||
The ID of the user whose mailbox forwarding needs to be set. | ||
|
||
## **-DisableForwarding** | ||
>   \ | ||
>   \ | ||
Specifies whether to disable mailbox forwarding. By default, it is set to $false. | ||
|
||
## **-ForwardExternalEmailAddress** | ||
>   \ | ||
>   \ | ||
The external email address to forward emails to. | ||
|
||
## **-ForwardInternalEmailAddress** | ||
>   \ | ||
>   \ | ||
The internal email address to forward emails to. This parameter accepts an array of email addresses. | ||
|
||
## **-KeepCopy** | ||
>   \ | ||
|
||
## **-UserID** | ||
>   \ | ||
>   \ | ||
Specifies whether to keep a copy of forwarded emails. By default, it is set to $false. | ||
|
||
#### EXAMPLE 1 | ||
```powershell | ||
PS > Set-CIPPMailboxForwarding -CustomerTenantID "contoso.onmicrosoft.com" -UserID "john.doe@contoso.onmicrosoft.com" -ForwardExternalEmailAddress "john.doe@example.com" -KeepCopy $true | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<# | ||
.SYNOPSIS | ||
This script retrieves a list of tenants and their licenses using the CIPP API. | ||
.DESCRIPTION | ||
The script prompts the user to enter the CIPP API URL, client ID, client secret, and tenant ID. | ||
It then imports the CIPPAPIModule and sets the CIPP API details using the provided inputs. | ||
The script retrieves a list of tenants using the Get-CIPPTenants function. | ||
For each tenant, it retrieves the licenses using the Get-CIPPLicenses function. | ||
The script creates a custom object for each license and outputs the results. | ||
Finally, it exports the results to a CSV file and opens it using the default application. | ||
.PARAMETER CIPPAPIUrl | ||
The URL of the CIPP API. | ||
.PARAMETER CIPPClientID | ||
The client ID for accessing the CIPP API. | ||
.PARAMETER CIPPClientSecret | ||
The client secret for accessing the CIPP API. | ||
.PARAMETER TenantId | ||
The ID of the tenant. | ||
.EXAMPLE | ||
.\Get-AllTenants-Licenses.ps1 | ||
.NOTES | ||
This script requires the CIPPAPIModule to be installed. | ||
#> | ||
|
||
$CIPPAPIUrl = Read-Host "Enter the CIPP API URL" | ||
$CIPPClientID = Read-Host "Enter the CIPP API Client ID" | ||
$CIPPClientSecret = Read-Host "Enter the CIPP API Client Secret" | ||
$TenantId = Read-Host "Enter the Tenant ID" | ||
|
||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -CIPPClientID $CIPPClientID -CIPPClientSecret $CIPPClientSecret -CIPPAPIUrl $CIPPAPIUrl -TenantId $TenantId | ||
|
||
Write-Output "Getting List of tenants" | ||
$tenantsList = Get-CIPPTenants | ||
Write-Output "Getting all customer licenses - This can take a few minutes..." | ||
$CustomerLicenses = $tenantsList.defaultDomainName | ForEach-Object -Parallel { | ||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -TenantID $using:TenantId -CIPPClientID $using:CIPPClientID -CIPPClientSecret $using:CIPPClientSecret -CIPPAPIUrl $using:CIPPAPIUrl | ||
$tenant = $_ | ||
$Licenses = Get-CIPPLicenses -CustomerTenantID $tenant | ||
foreach ($License in $Licenses) { | ||
[PSCustomObject]@{ | ||
Tenant = $tenant | ||
License = $License.License | ||
CountUsed = $License.CountUsed | ||
CountAvailable = $License.CountAvailable | ||
TotalLicenses = $License.TotalLicenses | ||
skuid = $License.skuid | ||
skuPartNumber = $License.skuPartNumber | ||
} | ||
} | ||
} -ThrottleLimit 5 | ||
|
||
if ($null -eq $CustomerLicenses) { | ||
exit | ||
} | ||
|
||
$filename = "CustomerLicenses" + (Get-Date -Format "yyyy-MM-dd") + ".csv" | ||
$filepath = "$env:TEMP\$($filename)" | ||
|
||
$CustomerLicenses | Export-CSV -Path $filepath | ||
|
||
Start-Process -FilePath $filepath |
69 changes: 69 additions & 0 deletions
69
Example Scripts/Get-AllTenants-SharedMailboxesEnabledAccount.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<# | ||
.SYNOPSIS | ||
This script retrieves a list of tenants and their shared mailboxes with account enabled using the CIPP API. | ||
.DESCRIPTION | ||
The script prompts the user to enter the CIPP API URL, client ID, client secret, and tenant ID. It then imports the CIPPAPIModule and sets the CIPP API details using the provided inputs. | ||
The script retrieves a list of tenants using the Get-CIPPTenants function from the CIPPAPIModule. It then iterates through each tenant in parallel and retrieves the shared mailboxes with account enabled using the Get-CIPPEnabledSharedMailboxe function from the CIPPAPIModule. For each shared mailbox, it creates a custom object with properties such as Tenant, UserPrincipalName, DisplayName, GivenName, Surname, AccountEnabled, and onPremisesSyncEnabled. | ||
If no shared mailboxes with account enabled are found, the script exits. Otherwise, it exports the data to a CSV file with a filename based on the current date and saves it to the user's temporary folder. Finally, it opens the CSV file using the default application associated with CSV files. | ||
.PARAMETER CIPPAPIUrl | ||
The URL of the CIPP API. | ||
.PARAMETER CIPPClientID | ||
The client ID for accessing the CIPP API. | ||
.PARAMETER CIPPClientSecret | ||
The client secret for accessing the CIPP API. | ||
.PARAMETER TenantId | ||
The ID of the tenant. | ||
.EXAMPLE | ||
PS C:\> .\Get-AllTenants-SharedMailboxesEnabledAccount.ps1 | ||
.NOTES | ||
This script requires the CIPPAPIModule to be installed. | ||
#> | ||
|
||
$CIPPAPIUrl = Read-Host "Enter the CIPP API URL" | ||
$CIPPClientID = Read-Host "Enter the CIPP API Client ID" | ||
$CIPPClientSecret = Read-Host "Enter the CIPP API Client Secret" | ||
$TenantId = Read-Host "Enter the Tenant ID" | ||
|
||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -CIPPClientID $CIPPClientID -CIPPClientSecret $CIPPClientSecret -CIPPAPIUrl $CIPPAPIUrl -TenantId $TenantId | ||
|
||
Write-Output "Getting List of tenants" | ||
$tenantsList = Get-CIPPTenants | ||
Write-Output "Getting all shared mailboxes with account enabled - This can take a few minutes..." | ||
$SharedMailboxesEnabled = $tenantsList.defaultDomainName | ForEach-Object -Parallel { | ||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -TenantID $using:TenantId -CIPPClientID $using:CIPPClientID -CIPPClientSecret $using:CIPPClientSecret -CIPPAPIUrl $using:CIPPAPIUrl | ||
$tenant = $_ | ||
$SharedMailboxes = Get-CIPPEnabledSharedMailboxe -CustomerTenantID $tenant | ||
foreach ($mailbox in $SharedMailboxes) { | ||
[PSCustomObject]@{ | ||
Tenant = $tenant | ||
UserPrincipalName = $mailbox.UserPrincipalName | ||
DisplayName = $mailbox.DisplayName | ||
GivenName = $mailbox.GivenName | ||
Surname = $mailbox.Surname | ||
AccountEnabled = $mailbox.AccountEnabled | ||
onPremisesSyncEnabled = $mailbox.onPremisesSyncEnabled | ||
} | ||
} | ||
} -ThrottleLimit 5 | ||
|
||
if ($null -eq $SharedMailboxesEnabled) { | ||
exit | ||
} | ||
|
||
$filename = "SharedMailboxesAccountEnabled" + (Get-Date -Format "yyyy-MM-dd") + ".csv" | ||
$filepath = "$env:TEMP\$($filename)" | ||
|
||
$SharedMailboxesEnabled | Export-CSV -Path $filepath | ||
|
||
Start-Process -FilePath $filepath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<# | ||
.SYNOPSIS | ||
This script retrieves a list of soft deleted mailboxes for all tenants using the CIPP API. | ||
.DESCRIPTION | ||
The script prompts the user to enter the CIPP API URL, client ID, client secret, and tenant ID. It then imports the CIPPAPIModule and sets the CIPP API details using the provided inputs. | ||
The script retrieves a list of tenants using the Get-CIPPTenants function and then retrieves the soft deleted mailboxes for each tenant in parallel using the Get-CIPPMailboxes function. The retrieved mailbox information is stored in a custom object and exported to a CSV file. | ||
.PARAMETER CIPPAPIUrl | ||
The URL of the CIPP API. | ||
.PARAMETER CIPPClientID | ||
The client ID for accessing the CIPP API. | ||
.PARAMETER CIPPClientSecret | ||
The client secret for accessing the CIPP API. | ||
.PARAMETER TenantId | ||
The ID of the tenant. | ||
.OUTPUTS | ||
SoftDeletedMailboxes.csv - A CSV file containing the soft deleted mailbox information for all tenants. | ||
.EXAMPLE | ||
PS C:\> .\Get-AllTenants-SoftDeletedMailboxes.ps1 | ||
.NOTES | ||
This script requires the CIPPAPIModule to be installed. | ||
#> | ||
|
||
$CIPPAPIUrl = Read-Host "Enter the CIPP API URL" | ||
$CIPPClientID = Read-Host "Enter the CIPP API Client ID" | ||
$CIPPClientSecret = Read-Host "Enter the CIPP API Client Secret" | ||
$TenantId = Read-Host "Enter the Tenant ID" | ||
|
||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -CIPPClientID $CIPPClientID -CIPPClientSecret $CIPPClientSecret -CIPPAPIUrl $CIPPAPIUrl -TenantId $TenantId | ||
|
||
Write-Output "Getting List of tenants" | ||
$tenantsList = Get-CIPPTenants | ||
Write-Output "Getting all customers soft deleted mailboxes - This can take a few minutes..." | ||
$DeletedMailboxes = $tenantsList.defaultDomainName | ForEach-Object -Parallel { | ||
Import-Module CIPPAPIModule | ||
Set-CIPPAPIDetails -TenantID $using:TenantId -CIPPClientID $using:CIPPClientID -CIPPClientSecret $using:CIPPClientSecret -CIPPAPIUrl $using:CIPPAPIUrl | ||
$tenant = $_ | ||
$Deleted = Get-CIPPMailboxes -CustomerTenantID $tenant -SoftDeletedMailboxes | ||
foreach ($mailbox in $Deleted) { | ||
[PSCustomObject]@{ | ||
Tenant = $tenant | ||
MailBoxDeletedDate = $mailbox.WhenSoftDeleted | ||
DisplayName = $mailbox.DisplayName | ||
UserPrincipalName = $mailbox.UPN | ||
PrimarySmtpAddress = $mailbox.PrimarySmtpAddress | ||
MailboxType = $mailbox.RecipientType | ||
MailboxStatus = $mailbox.RecipientTypeDetails | ||
} | ||
} | ||
} -ThrottleLimit 5 | ||
|
||
if ($null -eq $DeletedMailboxes) { | ||
exit | ||
} | ||
|
||
$filename = "SoftDeletedMailboxes" + (Get-Date -Format "yyyy-MM-dd") + ".csv" | ||
$filepath = "$env:TEMP\$($filename)" | ||
|
||
$DeletedMailboxes | Export-CSV -Path $filepath | ||
|
||
Start-Process -FilePath $filepath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters