Last active
April 23, 2019 23:24
-
-
Save darrenjrobinson/ac33332b3e09d778998c1f871be186ed to your computer and use it in GitHub Desktop.
Search MIM Service via the Lithnet MIM Rest API and PowerShell. Assoicated Blog https://blog.darrenjrobinson.com/getting-started-with-the-lithnet-rest-api-for-the-microsoft-identity-manager-service/
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
# Creds | |
$Username = "domain\user" | |
$Password = 'P@$$w0rd123' | |
$site_auth = "$($Username):$($Password)" | |
# Encode for Basic Authorization | |
$site_Bytes = [System.Text.Encoding]::utf8.GetBytes($site_auth) | |
$Site_EncodedAuth=[Convert]::ToBase64String($site_Bytes) | |
# Server URI | |
$uri = "https://mimdev.mydomain.com/v2/resources/" | |
# Search Query. Get all Person Objects | |
$objType = '?objectType=Person' | |
# Handle Self Sign Cert | |
add-type @" | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
public class TrustAllCertsPolicy : ICertificatePolicy { | |
public bool CheckValidationResult( | |
ServicePoint srvPoint, X509Certificate certificate, | |
WebRequest request, int certificateProblem) { | |
return true; | |
} | |
} | |
"@ | |
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy | |
# Search | |
$response = Invoke-WebRequest -Uri ($uri+$objType) -Method Get -Headers @{Authorization = "Basic $Site_EncodedAuth"} -ContentType "application/json" | |
$users = $response.Content | ConvertFrom-Json | |
$users.Results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment