Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ChatOps for Microsoft Identity Manager - Slack Configuration and Start Script. Associate blogpost https://blog.darrenjrobinson.com/chatops-for-microsoft-identity-manager/
# Install Poshbot PowerShell Module if it doesn't already exist
if (-not (Get-Module -Name "Poshbot")) {
install-module Poshbot
}
# Install LithnetRMA PowerShell Module if it doesn't already exist
if (-not (Get-Module -Name "LithnetRMA")) {
install-module LithnetRMA
}
# Install LithnetMIISAutomation PowerShell Module if it doesn't already exist
# The following module is required on your MIM Sync Server. Execute the following there and enable Remote PowerShell.
# See https://blog.darrenjrobinson.com/remotely-managing-your-fimmim-synchronisation-server-using-powershell-and-the-lithnet-miis-automation-powershell-module/
#if (-not (Get-Module -Name "LithnetMIISAutomation")) {
# install-module LithnetMIISAutomation
#}
# Check to see if the Lithnet PostBot RMA Module has been installed
if (-not (Get-Module -Name "PoshBot.LithnetRMA")) {
install-module "PoshBot.LithnetRMA"
}
# Check to see if the Lithnet PostBot MIIS Automation Module has been installed
if (-not (Get-Module -Name "Poshbot.LithnetMiisAutomation")) {
install-module "Poshbot.LithnetMiisAutomation"
}
import-module Poshbot
# Define Bot Configuration
$Token = 'xoxb-700205364516-1234567890-ViAQcRQsETv3XMBg24U6kyJQ' # Your Slack Bot Token
$BotName = 'identitybot' # The name of your bot
$BotAdmin = 'MIMGuy' # Your Slack account name
$PoshbotPath = 'C:\poshbot'
$PoshbotConfig = Join-Path $PoshbotPath config.psd1
$PoshbotPlugins = Join-Path $PoshbotPath plugins
$PoshbotLogs = Join-Path $PoshbotPath logs
$BotParams = @{
Name = $BotName
BotAdmins = $BotAdmin
CommandPrefix = '!'
LogLevel = 'Info'
BackendConfiguration = @{
Name = 'SlackBackend'
Token = $Token
}
AlternateCommandPrefixes = 'lithnet'
ConfigurationDirectory = $PoshbotPath
LogDirectory = $PoshbotLogs
PluginDirectory = $PoshbotPlugins
PluginConfiguration = @{
'PoshBot.LithnetRMA' = @{
MIMServiceCreds = import-clixml C:\poshbot\MIMAdminSyncCred.xml
MIMServiceAddress = 'http://mimserviceserver:5725'
}
'PoshBot.LithnetMIISAutomation' = @{
MIMSyncCreds = import-clixml C:\poshbot\MIMAdminSyncCred.xml
MIMSyncAddress = 'mimsyncserver.yourdomain.com' # Must be FQDN
}
}
}
# Set up folders for logging and plugins, save the config
$null = mkdir $PoshbotPath, $PoshbotPlugins, $PoshbotLogs -Force
$pbc = New-PoshBotConfiguration @BotParams
Save-PoshBotConfiguration -InputObject $pbc -Path $PoshbotConfig
Start-PoshBot -Configuration $pbc -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.