Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.