Initial situation:
On the customer side, there is a wish to include in an existing on-boarding/off-boarding PowerShell script also the creation and deletion of SEPPmail Secure E-Mail Gateway Users.
Question:
What is necessary for including the user administration of the SEPPmail Secure E-Mail Gateway into the script?
Answer:
Preparation:
First, the required modules must be installed and loaded with the following command sequence:
Install-Module Microsoft.Powershell.Secretmanagement -Force
Install-Module Microsoft.Powershell.Secretstore -Force
Install-Module SEPPmailAPI -Force
Get-Module seppmailapi -ListAvailable
The output should look something like this:
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Script 1.0.5 SEPPmailAPI Core,Desk {Find-SMACustomer, Get-SMACustomer, New…
Import-Module SEPPmailAPI
Get-Module
The output should look something like this:
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-It…
Binary 1.1.2 Microsoft.PowerShell.SecretManagem… {Get-Secret, Get-SecretInfo, Get-SecretVault, Reg…
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script 1.4.7 PackageManagement {Find-Package, Find-PackageProvider, Get-Package,…
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Fin…
Script 2.1.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …
Script 1.0.5 SEPPmailAPI {Add-SMAcustomerAdmin, Add-SMAGroupMember, Export…
Now, the login credentials are first taken from the token created on the SEPPmail Secure E-Mail Gateway (see also Rest API) to be put into a variable:
$tokencred = Get-Credential -UserName 2hWp0UpFH2pMdc6nLYTEtnO5Pwy5NgYk -Message N4Eoim8tlbC90CFwysiGgEHRNnyAwY7H
Optionally, the content of the variable can be output for checking:
$tokencred
The SEPPmailAPI configuration is then created with the help of the previously created variable:
New-SMAConfiguration -ConfigurationName 'Config1' -SMAHost 'securemail.myseppmail.tld' -Credential $tokencred -SMASkipCertCheck $false
The newly created configurations and any existing configurations can now be listed.
Get-SMAConfiguration -List
The output should look something like this:
ConfigName UserName SMAHost SMAPort SMASkipCertCheck SMAPIVersion Active
Cfg
---------- -------- ------- ------- ---------------- ------------ ---------
demo SIag57raUsdsEa7JKUG35423KgfhBhNZ 172.16.161.99 8445 True v1 True
Config1 gg65KGzgz767ew2TF56GZgu556GgzZ7h securemail.meinefirma.tld 8445 False v1 False
Since several SEPPmailAPI configurations are possible in parallel, one configuration (in the example, the newly created Config1) is to be set as default
Set-SMAConfiguration -ConfigurationName Config1 -SetAsDefault
The functionality of the configurations and thus the connectivity to the respective SEPPmail Secure E-Mail Gateway (in the example, the newly created Config1) can now be tested
Set-SMAConfiguration -ConfigurationName Config1 -SetAsDefault
Further information can be found at <https://github.com/seppmail//SEPPmailAPI.
Administration of the SEPPmail Secure E-Mail Gateway:
The SEPPmail Secure E-Mail Gateway whose configuration is currently active can now be administered.
The following commands are available for this purpose: https://docs.seppmail.com/api and/or
help on the possible commands and their parameters can also be found directly in the PowerShell. For this purpose, the commands
help <command>
and/or
help <command> -parameter <parameter>
are available.
The following should be noted with regard to the parameters:
Boolean are followed by $True or $False and switch the option on or off accordingly.
String requires the entry of a string. If this contains spaces, it must be delimited by inverted commas, for example 'This is a string'.
Switch performs ONE action. To undo this, if necessary, the command must be executed again without the unwanted parameter.
Further information:
A HowTo video (ca. 25 minutes) can be found under https://www.youtube.com/watch?v=RHaZW7txxBg.