-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from Tools4everBV/feature-first-release
Feature: first release
- Loading branch information
Showing
14 changed files
with
1,700 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). | ||
|
||
## [v1.0.0] - 02-12-2024 | ||
|
||
This is the first official release of _HelloID-Conn-SA-Full-Exchange-Online-SharedMailboxUpdate_. | ||
|
||
### Added | ||
|
||
### Changed | ||
|
||
### Deprecated | ||
|
||
### Removed |
10 changes: 10 additions & 0 deletions
10
Manual resources/[powershell-datasource]_Shared-mailbox-generate-table-update.inputs.json
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,10 @@ | ||
[ | ||
{ | ||
"description": null, | ||
"translateDescription": false, | ||
"inputFieldType": 1, | ||
"key": "searchValue", | ||
"type": 0, | ||
"options": 1 | ||
} | ||
] |
22 changes: 22 additions & 0 deletions
22
Manual resources/[powershell-datasource]_Shared-mailbox-generate-table-update.model.json
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,22 @@ | ||
[ | ||
{ | ||
"key": "primarySmtpAddress", | ||
"type": 0 | ||
}, | ||
{ | ||
"key": "alias", | ||
"type": 0 | ||
}, | ||
{ | ||
"key": "id", | ||
"type": 0 | ||
}, | ||
{ | ||
"key": "userPrincipalName", | ||
"type": 0 | ||
}, | ||
{ | ||
"key": "name", | ||
"type": 0 | ||
} | ||
] |
136 changes: 136 additions & 0 deletions
136
Manual resources/[powershell-datasource]_Shared-mailbox-generate-table-update.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,136 @@ | ||
####################################################################### | ||
# Template: HelloID SA Powershell data source | ||
# Name: Shared-mailbox-generate-table-update | ||
# Date: 02-12-2024 | ||
####################################################################### | ||
|
||
# For basic information about powershell data sources see: | ||
# https://docs.helloid.com/en/service-automation/dynamic-forms/data-sources/powershell-data-sources.html | ||
|
||
# Service automation variables: | ||
# https://docs.helloid.com/en/service-automation/service-automation-variables.html | ||
|
||
#region init | ||
# Enable TLS1.2 | ||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12 | ||
|
||
$VerbosePreference = "SilentlyContinue" | ||
$InformationPreference = "Continue" | ||
$WarningPreference = "Continue" | ||
|
||
# global variables (Automation --> Variable libary): | ||
$TenantId = $EntraTenantId | ||
$AppID = $EntraAppID | ||
$Secret = $EntraSecret | ||
$Organization = $EntraOrganization | ||
|
||
# variables configured in form: | ||
$searchValue = $datasource.searchValue | ||
$searchQuery = "*$searchValue*" | ||
|
||
# PowerShell commands to import | ||
$commands = @("Get-User", "Get-Mailbox") | ||
#endregion init | ||
|
||
try { | ||
#region import module | ||
$actionMessage = "importing $moduleName module" | ||
|
||
$importModuleParams = @{ | ||
Name = "ExchangeOnlineManagement" | ||
Cmdlet = $commands | ||
ErrorAction = 'Stop' | ||
} | ||
|
||
Import-Module @importModuleParams | ||
#endregion import module | ||
|
||
#region create access token | ||
Write-Verbose "Creating Access Token" | ||
$actionMessage = "creating access token" | ||
|
||
$body = @{ | ||
grant_type = "client_credentials" | ||
client_id = "$AppID" | ||
client_secret = "$Secret" | ||
resource = "https://outlook.office365.com" | ||
} | ||
|
||
$exchangeAccessTokenParams = @{ | ||
Method = 'POST' | ||
Uri = "https://login.microsoftonline.com/$TenantId/oauth2/token" | ||
Body = $body | ||
ContentType = 'application/x-www-form-urlencoded' | ||
UseBasicParsing = $true | ||
} | ||
|
||
$accessToken = (Invoke-RestMethod @exchangeAccessTokenParams).access_token | ||
#endregion create access token | ||
|
||
#region connect to Exchange Online | ||
Write-Verbose "Connecting to Exchange Online" | ||
$actionMessage = "connecting to Exchange Online" | ||
|
||
$exchangeSessionParams = @{ | ||
Organization = $Organization | ||
AppID = $AppID | ||
AccessToken = $accessToken | ||
CommandName = $commands | ||
ShowBanner = $false | ||
ShowProgress = $false | ||
TrackPerformance = $false | ||
ErrorAction = 'Stop' | ||
} | ||
Connect-ExchangeOnline @exchangeSessionParams | ||
|
||
Write-Information "Successfully connected to Exchange Online" | ||
#endregion connect to Exchange Online | ||
|
||
#region check shared mailbox | ||
$actionMessage = "getting shared mailbox" | ||
|
||
if (-not [String]::IsNullOrEmpty($searchValue)) { | ||
Write-information "searchQuery: $searchQuery" | ||
|
||
$SharedMailboxParams = @{ | ||
Filter = "{Alias -like '$searchQuery' -or Name -like '$searchQuery'}" | ||
RecipientTypeDetails = "SharedMailbox" | ||
ResultSize = "Unlimited" | ||
Verbose = $false | ||
ErrorAction = "Stop" | ||
} | ||
|
||
$mailboxes = Get-Mailbox @SharedMailboxParams | ||
|
||
$resultCount = @($mailboxes).Count | ||
|
||
Write-Information "Result count: $resultCount" | ||
|
||
if ($resultCount -gt 0) { | ||
foreach ($mailbox in $mailboxes) { | ||
$returnObject = @{ | ||
name = "$($mailbox.displayName)" | ||
alias = "$($mailbox.Alias)" | ||
id = "$($mailbox.ExchangeGuid)" | ||
primarySmtpAddress = "$($mailbox.PrimarySmtpAddress)" | ||
} | ||
|
||
Write-Output $returnObject | ||
} | ||
} | ||
} | ||
#endregion check shared mailbox | ||
} | ||
catch { | ||
$ex = $PSItem | ||
if ($($ex.Exception.GetType().FullName -eq 'Microsoft.PowerShell.Commands.HttpResponseException') -or | ||
$($ex.Exception.GetType().FullName -eq 'System.Net.WebException')) { | ||
$errorMessage = ($ex.ErrorDetails.Message | Convertfrom-json).error_description | ||
} | ||
else { | ||
$errorMessage = $($ex.Exception.message) | ||
} | ||
|
||
Write-Error "Error $actionMessage for Exchange Online shared mailbox with the query [$searchQuery]. Error: $errorMessage" | ||
} | ||
#endregion lookup |
34 changes: 34 additions & 0 deletions
34
... resources/[powershell-datasource]_shared-mailbox-update-check-mailbox-exists.inputs.json
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,34 @@ | ||
[ | ||
{ | ||
"description": null, | ||
"translateDescription": false, | ||
"inputFieldType": 1, | ||
"key": "Name", | ||
"type": 0, | ||
"options": 1 | ||
}, | ||
{ | ||
"description": null, | ||
"translateDescription": false, | ||
"inputFieldType": 1, | ||
"key": "PrimarySmtpAddress", | ||
"type": 0, | ||
"options": 1 | ||
}, | ||
{ | ||
"description": null, | ||
"translateDescription": false, | ||
"inputFieldType": 1, | ||
"key": "Alias", | ||
"type": 0, | ||
"options": 1 | ||
}, | ||
{ | ||
"description": null, | ||
"translateDescription": false, | ||
"inputFieldType": 1, | ||
"key": "SelectedSM", | ||
"type": 0, | ||
"options": 1 | ||
} | ||
] |
6 changes: 6 additions & 0 deletions
6
...l resources/[powershell-datasource]_shared-mailbox-update-check-mailbox-exists.model.json
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,6 @@ | ||
[ | ||
{ | ||
"key": "text", | ||
"type": 0 | ||
} | ||
] |
Oops, something went wrong.