Created
November 28, 2017 06:01
-
-
Save sean-m/0dcbcc68502d18d77f40af06a395a7be to your computer and use it in GitHub Desktop.
PowerShell function for retreiving a FIM/MIM Sync Management Agent object.
This file contains hidden or 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
function Get-Ma { | |
param ( | |
[string]$Name, | |
[string]$Guid | |
) | |
$search_string = "" | |
if ([String]::IsNullOrEmpty($Name) -and [String]::IsNullOrEmpty($Guid)) { | |
throw "Must pass management agent Name or Guid" | |
} | |
elseif ($Name) { | |
$search_string = "Name='$Name'" | |
} | |
elseif ($Guid) { | |
$search_string = "GUID='$Guid'" | |
} | |
$opt = new-object System.Management.ConnectionOptions | |
$opt.Authentication = [System.Management.AuthenticationLevel]::PacketPrivacy; | |
$mPath = New-Object System.Management.ManagementPath "root\MicrosoftIdentityIntegrationServer" | |
$myScope = new-object System.Management.ManagementScope( $mPath, $opt ); | |
$myQuery = new-object System.Management.SelectQuery( "MIIS_ManagementAgent", $search_string ); | |
$searcher = new-object System.Management.ManagementObjectSearcher( $myScope, $myQuery ); | |
return $searcher.Get() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment