How to Use PowerShell to Display Whether an MPR is Enabled
FIM ScriptBox Item
Summary
The objective of this script is to display whether a MPR is enabled.
Script Code
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 |
#---------------------------------------------------------------------------------------------------------- set-variable -name URI -value "http://localhost:5725/resourcemanagementservice" -option constant #---------------------------------------------------------------------------------------------------------- if($args.count -ne 1) {throw "MPR name missing!"} $mprName = $args[0] if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation} clear-host $curObject = export-fimconfig -uri $URI ` –onlyBaseResources ` -customconfig ("/ManagementPolicyRule[DisplayName='$mprName']") if($curObject -eq $null) {throw "MPR not found!"} $objectType = $curObject.ResourceManagementObject.ObjectType $objectIdentifier = $curObject.ResourceManagementObject.ObjectIdentifier $curAttribute = $curObject.ResourceManagementObject.ResourceManagementAttributes | ` Where-Object {$_.AttributeName -eq "Disabled"} write-host "Checking " """$mprName""" if($curAttribute.Value -eq "True") {write-host "`n -MPR is disabled`n"} else {write-host "`n -MPR is disabled`n"} #---------------------------------------------------------------------------------------------------------- trap { Write-Host "`nError: $($_.Exception.Message)`n" -foregroundcolor white -backgroundcolor darkred Exit 1 } #---------------------------------------------------------------------------------------------------------- |
Note
To provide feedback about this script, create a post on the FIM TechNet Forum.
For more FIM related Windows PowerShell scripts, see the FIM ScriptBox.