How to Use PowerShell to Disable Provisioning
FIM ScriptBox Item
Summary
This script disables provisioning on your FIM server.
Note
To use this script, you need to add the FIM service account to the FIMSyncAdmins group!
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 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 |
#---------------------------------------------------------------------------------------------------------- set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant #---------------------------------------------------------------------------------------------------------- if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation} clear-host $exportObject = export-fimconfig -uri $URI ` –onlyBaseResources ` -customconfig ("/mv-data") ` -ErrorVariable Err ` -ErrorAction SilentlyContinue if($Err){throw $Err} if($exportObject -eq $null) {throw "There is no metaverse data configured on your system!"} $provisioningState = ($exportObject.ResourceManagementObject.ResourceManagementAttributes | ` Where-Object {$_.AttributeName -eq "SyncConfig-provisioning-type"}).Value if(0 -eq [String]::Compare($provisioningState,"none", $true)) {throw "L:Provisioning is already disabled"} $importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange $importChange.Operation = 1 $importChange.AttributeName = "SyncConfig-provisioning-type" $importChange.AttributeValue = "none" $importChange.FullyResolved = 1 $importChange.Locale = "Invariant" $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject $importObject.ObjectType = $exportObject.ResourceManagementObject.ObjectType $importObject.TargetObjectIdentifier = $exportObject.ResourceManagementObject.ObjectIdentifier $importObject.SourceObjectIdentifier = $exportObject.ResourceManagementObject.ObjectIdentifier $importObject.State = 1 $importObject.Changes = (,$importChange) $importObject | Import-FIMConfig -uri $URI -ErrorVariable Err -ErrorAction SilentlyContinue if($Err){throw $Err} write-host "`nProvisioning disabled successfully`n" #---------------------------------------------------------------------------------------------------------- trap { $exMessage = $_.Exception.Message if($exMessage.StartsWith("L:")) {write-host "`n" $exMessage.substring(2) "`n" -foregroundcolor white -backgroundcolor darkblue} else {write-host "`nError: " $exMessage "`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.