locked
What is the proper powershell to disable a connector? RRS feed

  • Question

  • I've got an open ticket with Microsoft and I might need to disable all of my Exchange Connectors in a hurry (I have 46 of them)?

    I've tried these.  They executed without an error but the connector remained enabled.

    Get-SCSMConnector -DisplayName "ConnectorName" | %{ $_.Enabled = 0 } | Update-SCSMConnector 
    
    Get-SCSMConnector -DisplayName "ConnectorName" | %{ $_.Enabled = 1 } | Update-SCSMConnector 
    
    Get-SCSMConnector -DisplayName "ConnectorName" | %{ $_.Enabled = "False" } | Update-SCSMConnector 

    Wednesday, December 3, 2014 5:55 PM

Answers

  • Well, the first problem is that you have 46 exchange connectors. that seems excessive. 

    I've never had any luck with the SCSMConnector commandlets, and the documentation suggests it won't work on custom connector types

    the following SMLets script will set the property, but not update the connector configuration, and the connector will still run: 

    Import-module SMLets
    
    $EXConnectorClass = Get-SCSMClass ExchangeConnector
    $EXConnectors = Get-SCSMObject -Class $EXConnectorClass 
    Foreach ($EXConnector in $EXConnectors) {
    	Set-scsmObject $EXconnector -Property Enabled -value $False
    }
    Unfortunately, i can't find any documentation on triggering a connector configuration update. you might try this trick, i.e. setting the enable on the ex connector, disabling an AD connector twice to trigger a connector config update, and then re-enabling the AD connector again to restore regular operation. 


    • Edited by Thomas Bianco Wednesday, December 3, 2014 8:28 PM
    • Marked as answer by Foothill1 Monday, December 8, 2014 10:38 PM
    Wednesday, December 3, 2014 8:28 PM

All replies

  • This should work. Had some problem myself but found this page and modified the code:

    http://blog.scsmsolutions.com/2012/03/update-ad-and-sccm-connector-scheduler-with-powershell/ 

    Just change ZGC in the -eq Displayname so it will match your connectors and you can easy disable all connectors.

    $SMDIR    = (Get-ItemProperty "hklm:\SOFTWARE\Microsoft\System Center\2010\Service Manager\Setup\").InstallDirectory
    $SMSDKDIR = "${SMDIR}\SDK Binaries"
    $SMDLL    = "${SMSDKDIR}\Microsoft.EnterpriseManagement.Core.dll"
    $SMADDDLL = "${SMSDKDIR}\Microsoft.EnterpriseManagement.ServiceManager.dll"
    
    [reflection.assembly]::LoadFile($SMDLL) | out-null
    [reflection.assembly]::LoadFile($SMADDDLL) | out-null
    
    $ServiceManagementGroup = new-object Microsoft.EnterpriseManagement.ServiceManagementGroup "localhost"
    
    # Get All connectors with displayname ZGC
    $connectors = $ServiceManagementGroup.ConnectorFramework.GetConnectors() | ? {$_.DisplayName -eq "ZGC"}
    
    foreach($connector in $connectors)
    {
        write-host "Disabling connector: $connector.DisplayName"
        $connector.ConnectorObject.Item($null,"Enabled").Value = $true
        
        $connector.ConnectorObject.Commit()
        $ServiceManagementGroup.LinkingFramework.UpdateDataSource($connector.ConnectorObject.Id)
    
    }



    www.zgc.se - Sysadmin blog.

    Wednesday, December 3, 2014 6:53 PM
  • Slight problem with this.  I translated it into SDK code.  The call to GetConnectors() only returned 15 connectors and not one of them was an Exchange Connector.  It only returns the 'out-of-the-box' connectors.

    Microsoft.EnterpriseManagement.EnterpriseManagementGroup mg = null;
    
    mg = new EnterpriseManagementGroup("scsmServer");
    IList connectors = (IList) mg.ConnectorFramework.GetConnectors()

    Wednesday, December 3, 2014 8:02 PM
  • Crap, i did'nt have the exchange connector installed so i did'nt test it with that one. I tried a bunch of different ways to try to disable the connector and this was the only way i found that worked. As you sad the commands is accepted but the connector is still enabled. 



    www.zgc.se - Sysadmin blog.

    Wednesday, December 3, 2014 8:19 PM
  • An interesting tidbit is that I can bring back the object but I still need to find a way to translate it into a connector.

    EnterpriseManagementObject obj = mg.EntityObjects.GetObject<EnterpriseManagementObject>(new Guid("1F670F76-F1EF-6EB3-7308-EDE87690706C"), ObjectQueryOptions.Default); ManagementPackClass objClass = obj.GetLeastDerivedNonAbstractClass(); // == Microsoft.SystemCenter.Connector // I ran this against the SCCM connector and it returned // the exact same class. Just need to figure out where // they are referenced in the system since it is not // included in the list of Connectors.


    Wednesday, December 3, 2014 8:26 PM
  • Well, the first problem is that you have 46 exchange connectors. that seems excessive. 

    I've never had any luck with the SCSMConnector commandlets, and the documentation suggests it won't work on custom connector types

    the following SMLets script will set the property, but not update the connector configuration, and the connector will still run: 

    Import-module SMLets
    
    $EXConnectorClass = Get-SCSMClass ExchangeConnector
    $EXConnectors = Get-SCSMObject -Class $EXConnectorClass 
    Foreach ($EXConnector in $EXConnectors) {
    	Set-scsmObject $EXconnector -Property Enabled -value $False
    }
    Unfortunately, i can't find any documentation on triggering a connector configuration update. you might try this trick, i.e. setting the enable on the ex connector, disabling an AD connector twice to trigger a connector config update, and then re-enabling the AD connector again to restore regular operation. 


    • Edited by Thomas Bianco Wednesday, December 3, 2014 8:28 PM
    • Marked as answer by Foothill1 Monday, December 8, 2014 10:38 PM
    Wednesday, December 3, 2014 8:28 PM
  • Right now, I'm looking into using the SDK to alter the Management Pack directly.  Disabling the connectors in the management pack directly seems worth a try.
    Wednesday, December 3, 2014 8:58 PM
  • Quick side note, Updating the property as per my script, and then enabling and disabling a separate connector (i.e. an AD connector) DOES INDEED trigger a configuration update on the workflow server and the exchange connector no longer runs. it seems like system is at least looking at the value of this property as part of the evaluation of this connector running, i.e. it's not just a display flag, it has some effect on the function of the connector, even if it's not the full effect. 

    Thursday, December 4, 2014 4:10 PM

  • I just recently went through an automation task for SCSM and thought I would share my solution. 

    This is how I solved the AD connector enable disable issue. These are snipits from a much large script but will help you resolve any module already imported errors then the disable function. 

    #Install the SMLets Module

    if ( ! (Get-Module -Name SMLets))
        {
            Try { Import-Module SMLets -ErrorAction Stop }
            Catch 
            { 
                $PowershellError =  "      Error: SMlets Module not loaded. "
                $PowershellCheck = "Fail"
            }
        }
        else
        {
            Write-Host  "SMLets is already installed"
        }


    #This is the connector disable function
    function Disable-SCSM-Connectors {
        #Stop Exchange Connectors
        Write-Host "Disabling Exchange Connectors"

        $EXConnectorClass = Get-SCSMClass ExchangeConnector
        $EXConnectors = Get-SCSMObject -Class $EXConnectorClass 
        Foreach ($EXConnector in $EXConnectors) {
        Set-scsmObject $EXconnector -Property Enabled -value $False
        }

        Start-Sleep -s 2

        #Stop AD Connectors
        Write-Host "Disabling AD Connectors"

        $ADConnectors = Get-SCSMConnector -Name "ADConnector*"
        Foreach ($ADConnector in $ADConnectors) {
        $ADConnector.Enabled = $false
            Update-SCSMConnector -Connector $ADConnector
        }

        Start-Sleep -s 2

    }

    Cheers!


    • Edited by TJodoin Friday, August 16, 2019 12:38 PM grammatical error.
    Friday, August 16, 2019 12:37 PM