Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Search MIM Service via the Lithnet MIM Rest API and PowerShell. Assoicated Blog
# Creds
$Username = "domain\user"
$Password = 'P@$$w0rd123'
$site_auth = "$($Username):$($Password)"
# Encode for Basic Authorization
$site_Bytes = [System.Text.Encoding]::utf8.GetBytes($site_auth)
# Server URI
$uri = ""
# 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
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.