Skip to content

Commit

Permalink
Fix small changes after implementation (#3)
Browse files Browse the repository at this point in the history
* Fix: small changes after implementation

* Updated readme to the new template

* Added changelog.md

* Fix: readme logo
  • Loading branch information
rhouthuijzen authored Dec 16, 2024
1 parent e7686c1 commit a7509a5
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 112 deletions.
12 changes: 6 additions & 6 deletions All-in-one setup/createform.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ Invoke-HelloIDDatasource -DatasourceName $dataSourceGuid_0_Name -DatasourceType
<# Begin: DataSource "function-check-online-mailbox-exists" #>
$tmpPsScript = @'
#######################################################################
# Template: RHo HelloID SA Powershell data source
# Template: HelloID SA Powershell data source
# Name: function-check-online-mailbox-exists
# Date: 05-02-2024
# Date: 28-11-2024
#######################################################################
# For basic information about powershell data sources see:
Expand All @@ -372,8 +372,8 @@ $tmpPsScript = @'
# https://docs.helloid.com/en/service-automation/service-automation-variables.html
#region init
# Set TLS to accept TLS, TLS 1.1 and TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
# Enable TLS1.2
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
$VerbosePreference = "SilentlyContinue"
$InformationPreference = "Continue"
Expand Down Expand Up @@ -514,7 +514,7 @@ Invoke-HelloIDDatasource -DatasourceName $dataSourceGuid_1_Name -DatasourceType

<# Begin: Dynamic Form "Exchange Online Shared Mailbox - Create" #>
$tmpSchema = @"
[{"templateOptions":{"title":"Retrieving this information from Exchange Online takes an average of +/- 10 seconds.","titleField":"","bannerType":"Info","useBody":true},"type":"textbanner","summaryVisibility":"Show","body":"Please wait so we can validate the input.","requiresTemplateOptions":false,"requiresKey":false,"requiresDataSource":false},{"key":"organization","templateOptions":{"label":"Organization","required":true,"useObjects":false,"useDataSource":true,"useFilter":true,"options":[],"valueField":"Naam","textField":"Naam","dataSourceConfig":{"dataSourceGuid":"$dataSourceGuid_0","input":{"propertyInputs":[]}},"useDefault":true,"defaultSelectorProperty":"Naam"},"type":"dropdown","summaryVisibility":"Show","textOrLabel":"text","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"name","templateOptions":{"label":"name","placeholder":"IT department","required":true,"minLength":2},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"alias","templateOptions":{"label":"Alias","placeholder":"it-department"},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"Validation","templateOptions":{"label":"Validate","readonly":true,"useDataSource":true,"pattern":"^Valid.*","dataSourceConfig":{"dataSourceGuid":"$dataSourceGuid_1","input":{"propertyInputs":[{"propertyName":"Name","otherFieldValue":{"otherFieldKey":"name"}},{"propertyName":"Alias","otherFieldValue":{"otherFieldKey":"alias"}},{"propertyName":"Organization","otherFieldValue":{"otherFieldKey":"organization"}}]}},"displayField":"text","required":true},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false}]
[{"templateOptions":{"title":"Retrieving this information from Exchange Online takes an average of +/- 10 seconds.","titleField":"","bannerType":"Info","useBody":true},"type":"textbanner","summaryVisibility":"Show","body":"Please wait so we can validate the input.","requiresTemplateOptions":false,"requiresKey":false,"requiresDataSource":false},{"key":"organization","templateOptions":{"label":"Organization","required":true,"useObjects":false,"useDataSource":true,"useFilter":true,"options":[],"valueField":"Naam","textField":"Naam","dataSourceConfig":{"dataSourceGuid":"$dataSourceGuid_0","input":{"propertyInputs":[]}},"useDefault":true,"defaultSelectorProperty":"Naam"},"type":"dropdown","summaryVisibility":"Show","textOrLabel":"text","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"name","templateOptions":{"label":"name","placeholder":"IT department","required":true,"minLength":2},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"alias","templateOptions":{"label":"Alias","placeholder":"it-department","required":true},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false},{"key":"Validation","templateOptions":{"label":"Validate","readonly":true,"useDataSource":true,"pattern":"^Valid.*","dataSourceConfig":{"dataSourceGuid":"$dataSourceGuid_1","input":{"propertyInputs":[{"propertyName":"Name","otherFieldValue":{"otherFieldKey":"name"}},{"propertyName":"Alias","otherFieldValue":{"otherFieldKey":"alias"}},{"propertyName":"Organization","otherFieldValue":{"otherFieldKey":"organization"}}]}},"displayField":"text","required":true},"type":"input","summaryVisibility":"Show","requiresTemplateOptions":true,"requiresKey":true,"requiresDataSource":false}]
"@

$dynamicFormGuid = [PSCustomObject]@{}
Expand Down Expand Up @@ -579,7 +579,7 @@ $delegatedFormName = @'
Exchange Online - Shared Mailbox - Create
'@
$tmpTask = @'
{"name":"Exchange Online - Shared Mailbox - Create","script":"#######################################################################\n# Template: RHo HelloID SA Delegated form task\n# Name: Exchange Online Shared Mailbox - Create\n# Date: 02-05-2024\n#######################################################################\n\n# For basic information about delegated form tasks see:\n# https://docs.helloid.com/en/service-automation/delegated-forms/delegated-form-powershell-scripts.html\n\n# Service automation variables:\n# https://docs.helloid.com/en/service-automation/service-automation-variables.html\n\n#region init\n\n# Set TLS to accept TLS, TLS 1.1 and TLS 1.2\n[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12\n\n$VerbosePreference = \"SilentlyContinue\"\n$InformationPreference = \"Continue\"\n$WarningPreference = \"Continue\"\n\n# global variables (Automation --> Variable libary):\n$TenantId = $EntraTenantId\n$AppID = $EntraAppID\n$Secret = $EntraSecret\n$Organization = $EntraOrganization\n\n# variables configured in form:\n$Maildomain = $form.organization.Maildomain\n$Name = $form.name\n$Alias = $form.alias\n\n# PowerShell commands to import\n$commands = @(\"Get-User\", \"New-Mailbox\", \"Set-Mailbox\")\n#endregion init\n\n#region functions\n\n#endregion functions\n\ntry {\n #region import module\n $actionMessage = \"importing $moduleName module\"\n\n $importModuleParams = @{\n Name = \"ExchangeOnlineManagement\"\n Cmdlet = $commands\n ErrorAction = 'Stop'\n }\n\n Import-Module @importModuleParams\n #endregion import module\n\n #region create access token\n Write-Verbose \"Creating Access Token\"\n $actionMessage = \"creating access token\"\n \n $body = @{\n grant_type = \"client_credentials\"\n client_id = \"$AppID\"\n client_secret = \"$Secret\"\n resource = \"https://outlook.office365.com\"\n }\n\n $exchangeAccessTokenParams = @{\n Method = 'POST'\n Uri = \"https://login.microsoftonline.com/$TenantId/oauth2/token\"\n Body = $body\n ContentType = 'application/x-www-form-urlencoded'\n UseBasicParsing = $true\n }\n \n $accessToken = (Invoke-RestMethod @exchangeAccessTokenParams).access_token\n #endregion create access token\n\n #region connect to Exchange Online\n Write-Verbose \"Connecting to Exchange Online\"\n $actionMessage = \"connecting to Exchange Online\"\n\n $exchangeSessionParams = @{\n Organization = $Organization\n AppID = $AppID\n AccessToken = $accessToken\n CommandName = $commands\n ShowBanner = $false\n ShowProgress = $false\n TrackPerformance = $false\n ErrorAction = 'Stop'\n }\n Connect-ExchangeOnline @exchangeSessionParams\n \n Write-Information \"Successfully connected to Exchange Online\"\n #endregion connect to Exchange Online\n\n #region create shared mailbox\n $actionMessage = \"creating shared mailbox\"\n $CreateMailboxParams = @{\n Shared = $true\n Name = $Name\n DisplayName = $Name\n PrimarySmtpAddress = $Alias.Replace(\" \", \"\") + \"@$Maildomain\"\n Alias = $Alias.Replace(\" \", \"\")\n ErrorAction = 'Stop'\n }\n\n New-Mailbox @CreateMailboxParams\n\n Write-Information \"Shared Mailbox [$Name] created successfully\" \n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Shared Mailbox [$Name] created successfully\" # required (free format text) \n IsError = $false # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n #endregion create shared mailbox\n\n #region update shared mailbox\n $actionMessage = \"updating shared mailbox\"\n Start-Sleep -Seconds 10\n\n $UpdateMailboxParams = @{\n Identity = \"$($CreateMailboxParams.PrimarySmtpAddress)\"\n MessageCopyForSendOnBehalfEnabled = $true\n MessageCopyForSentAsEnabled = $true\n ErrorAction = 'Stop'\n }\n\n Set-Mailbox @UpdateMailboxParams\n \n Write-Information \"Shared Mailbox [$Name] updated successfully\" \n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Shared Mailbox [$Name] updated successfully\" # required (free format text) \n IsError = $false # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n #endregion update shared mailbox\n}\ncatch {\n $ex = $PSItem\n if ($($ex.Exception.GetType().FullName -eq 'Microsoft.PowerShell.Commands.HttpResponseException') -or\n $($ex.Exception.GetType().FullName -eq 'System.Net.WebException')) {\n $errorMessage = ($ex.ErrorDetails.Message | Convertfrom-json).error_description\n }\n else {\n $errorMessage = $($ex.Exception.message)\n }\n\n Write-Error \"Error $actionMessage for Exchange Online shared mailbox [$Name]. Error: $errorMessage\"\n\n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Error $actionMessage for Exchange Online shared mailbox [$Name]\" # required (free format text) \n IsError = $true # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n}","runInCloud":false}
{"name":"Exchange Online - Shared Mailbox - Create","script":"#######################################################################\n# Template: HelloID SA Delegated form task\n# Name: Exchange Online Shared Mailbox - Create\n# Date: 28-11-2024\n#######################################################################\n\n# For basic information about delegated form tasks see:\n# https://docs.helloid.com/en/service-automation/delegated-forms/delegated-form-powershell-scripts.html\n\n# Service automation variables:\n# https://docs.helloid.com/en/service-automation/service-automation-variables.html\n\n#region init\n\n# Enable TLS1.2\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12\n\n$VerbosePreference = \"SilentlyContinue\"\n$InformationPreference = \"Continue\"\n$WarningPreference = \"Continue\"\n\n# global variables (Automation --> Variable libary):\n$TenantId = $EntraTenantId\n$AppID = $EntraAppID\n$Secret = $EntraSecret\n$Organization = $EntraOrganization\n\n# variables configured in form:\n$Maildomain = $form.organization.Maildomain\n$Name = $form.name\n$Alias = $form.alias\n\n# PowerShell commands to import\n$commands = @(\"Get-User\", \"New-Mailbox\", \"Set-Mailbox\")\n#endregion init\n\n#region functions\n\n#endregion functions\n\ntry {\n #region import module\n $actionMessage = \"importing $moduleName module\"\n\n $importModuleParams = @{\n Name = \"ExchangeOnlineManagement\"\n Cmdlet = $commands\n ErrorAction = 'Stop'\n }\n\n Import-Module @importModuleParams\n #endregion import module\n\n #region create access token\n Write-Verbose \"Creating Access Token\"\n $actionMessage = \"creating access token\"\n \n $body = @{\n grant_type = \"client_credentials\"\n client_id = \"$AppID\"\n client_secret = \"$Secret\"\n resource = \"https://outlook.office365.com\"\n }\n\n $exchangeAccessTokenParams = @{\n Method = 'POST'\n Uri = \"https://login.microsoftonline.com/$TenantId/oauth2/token\"\n Body = $body\n ContentType = 'application/x-www-form-urlencoded'\n UseBasicParsing = $true\n }\n \n $accessToken = (Invoke-RestMethod @exchangeAccessTokenParams).access_token\n #endregion create access token\n\n #region connect to Exchange Online\n Write-Verbose \"Connecting to Exchange Online\"\n $actionMessage = \"connecting to Exchange Online\"\n\n $exchangeSessionParams = @{\n Organization = $Organization\n AppID = $AppID\n AccessToken = $accessToken\n CommandName = $commands\n ShowBanner = $false\n ShowProgress = $false\n TrackPerformance = $false\n ErrorAction = 'Stop'\n }\n Connect-ExchangeOnline @exchangeSessionParams\n \n Write-Information \"Successfully connected to Exchange Online\"\n #endregion connect to Exchange Online\n\n #region create shared mailbox\n $actionMessage = \"creating shared mailbox\"\n $CreateMailboxParams = @{\n Shared = $true\n Name = $Name\n DisplayName = $Name\n PrimarySmtpAddress = $Alias.Replace(\" \", \"\") + \"@$Maildomain\"\n Alias = $Alias.Replace(\" \", \"\")\n ErrorAction = 'Stop'\n }\n\n New-Mailbox @CreateMailboxParams\n\n Write-Information \"Shared Mailbox [$Name] created successfully\" \n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Shared Mailbox [$Name] created successfully\" # required (free format text) \n IsError = $false # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n #endregion create shared mailbox\n\n #region update shared mailbox\n $actionMessage = \"updating shared mailbox\"\n Start-Sleep -Seconds 10\n\n $UpdateMailboxParams = @{\n Identity = \"$($CreateMailboxParams.PrimarySmtpAddress)\"\n MessageCopyForSendOnBehalfEnabled = $true\n MessageCopyForSentAsEnabled = $true\n ErrorAction = 'Stop'\n }\n\n Set-Mailbox @UpdateMailboxParams\n \n Write-Information \"Shared Mailbox [$Name] updated successfully\" \n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Shared Mailbox [$Name] updated successfully\" # required (free format text) \n IsError = $false # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n #endregion update shared mailbox\n}\ncatch {\n $ex = $PSItem\n if ($($ex.Exception.GetType().FullName -eq 'Microsoft.PowerShell.Commands.HttpResponseException') -or\n $($ex.Exception.GetType().FullName -eq 'System.Net.WebException')) {\n $errorMessage = ($ex.ErrorDetails.Message | Convertfrom-json).error_description\n }\n else {\n $errorMessage = $($ex.Exception.message)\n }\n\n Write-Error \"Error $actionMessage for Exchange Online shared mailbox [$Name]. Error: $errorMessage\"\n\n $Log = @{\n Action = \"CreateResource\" # optional. ENUM (undefined = default) \n System = \"Exchange Online\" # optional (free format text) \n Message = \"Error $actionMessage for Exchange Online shared mailbox [$Name]\" # required (free format text) \n IsError = $true # optional. Elastic reporting purposes only. (default = $false. $true = Executed action returned an error) \n TargetDisplayName = $Name # optional (free format text) \n TargetIdentifier = $([string]$Alias) # optional (free format text) \n }\n #send result back \n Write-Information -Tags \"Audit\" -MessageData $log\n}","runInCloud":false}
'@

Invoke-HelloIDDelegatedForm -DelegatedFormName $delegatedFormName -DynamicFormGuid $dynamicFormGuid -AccessGroups $delegatedFormAccessGroupGuids -Categories $delegatedFormCategoryGuids -UseFaIcon "True" -FaIcon "fa fa-inbox" -task $tmpTask -returnObject ([Ref]$delegatedFormRef)
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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).

## [v2.0.1] - 02-12-2024

- Small changes after implementation and readme updated to new template.

## [v2.0.0] - 03-06-2024

- Rework to new logging and use exchange online module V3.

## [v1.0.1] - 16-11-2021

- Added version number and updated all-in-one script.

## [v1.0.0] - 29-04-2021

This is the first official release of _HelloID-Conn-SA-Full-Exchange-Online-SharedMailboxCreate_.

### Added

### Changed

### Deprecated

### Removed
Loading

0 comments on commit a7509a5

Please sign in to comment.