Last active
January 21, 2019 22:05
-
-
Save darrenjrobinson/7d65c74d22a55483c0373c18bd39ac93 to your computer and use it in GitHub Desktop.
Remote PowerShell from Azure to Microsoft Identity Manager. Associated blogpost here https://blog.darrenjrobinson.com/using-azure-functions-with-the-lithnet-miis-automation-powershell-module-to-query-your-microsoft-identity-manager-metaverse/
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
# Get the input request | |
$in = Get-Content $req -Raw | ConvertFrom-Json | |
# Username for connection to MIM Sync Server via Function Application Settings | |
$username = $env:MIMServiceCredUser | |
# Password for connection to MIM Sync Server via Function Application Settings | |
$pw = $env:MIMServiceCredPassword | |
# Credentials password (encrypted) | |
$keypath = 'D:\home\site\wwwroot\MyMIMSearchFunction\bin\Keys\MyMIMSyncPassKey.key' | |
$password = $pw | ConvertTo-SecureString -key (Get-Content $keypath) | |
# Create PS Creds | |
$credentials = New-Object System.Management.Automation.PSCredential $Username,$password | |
# skipping cert check as we're using a self signed cert | |
$options = New-PsSessionOption –SkipCACheck -SkipCNCheck | |
# Setup scriptblock | |
$scriptblock = {param($o,$a,$v) get-mvobject -ObjectType $o $a $v } | |
# Connect to MIM Sync Server and execure the query | |
$obj = Invoke-Command $scriptblock -computer mymimsyncserver.westus.cloudapp.azure.com -useSSL -credential $credentials -SessionOption $options -argumentlist $in.objecttype,$in.attribute,$in.attributevalue | |
# Output result | |
Out-File -Encoding Ascii -FilePath $res -inputObject $obj.Attributes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment