0

We have an application that integrates with SCCM 2012 and saves custom SCCM applications to SCCM.

The problem I am having is that attempting to save one of our custom applications when the SCCM administrator has set the application to be in the retired state causes our application to fail the saving process.

I'd like to be able to query the SCCM application state in order to determine before we attempt the save operation whether the given application is Active or Retired.

I can find no reference to "retired" status in the SMS_Application Server WMI help or any of the other pages: http://msdn.microsoft.com/en-us/library/hh949251.aspx

I have noticed that there is a Restore() method which looks like it will change the status of a Retired package back to Active, however that's not quite what I want to do.

Can anyone help me determine how to find an applications current status?

Thanks.

4

1 回答 1

1

There's a method in the SCCM 2012 PowerShell cmdlets that appears to be retrieving the expired status. Here's the c# code (decompiled from the dll AppUI.PS.AppMan.dll on the SCCM server)

    private bool IsApplicationRetired(IResultObject applicaction)
    {
        IResultObject[] resultObjectArray = null;
        int integerValue = applicaction["CI_ID"].IntegerValue;
        object[] objArray = new object[] { integerValue };
        resultObjectArray = base.ExecuteQuery(string.Format(CultureInfo.InvariantCulture, "SELECT * FROM SMS_Application WHERE CI_ID = {0}", objArray));
        IResultObject[] resultObjectArray1 = resultObjectArray;
        int num = 0;
        if (num < (int)resultObjectArray1.Length)
        {
            IResultObject resultObject = resultObjectArray1[num];
            this.isApplicationRetired = resultObject["IsExpired"].BooleanValue;
        }
        if (this.isApplicationRetired)
        {
            object[] objArray1 = new object[] { integerValue };
            IResultObject instance = base.ConnectionManager.GetInstance(string.Format(CultureInfo.InvariantCulture, "SMS_Application.CI_ID={0}", objArray1));
            if (instance != null)
            {
                string stringValue = instance["ModelName"].StringValue;
                instance.Dispose();
                object[] objArray2 = new object[] { base.ConnectionManager.EscapeQueryString(stringValue, ConnectionManagerBase.EscapeQuoteType.SingleQuote) };
                resultObjectArray = base.ExecuteQuery(string.Format(CultureInfo.InvariantCulture, "SELECT CI_ID FROM SMS_Application WHERE ModelName = '{0}' AND IsLatest = 1 AND IsExpired = 0", objArray2));
                IResultObject[] resultObjectArray2 = resultObjectArray;
                int num1 = 0;
                if (num1 < (int)resultObjectArray2.Length)
                {
                    IResultObject resultObject1 = resultObjectArray2[num1];
                    if (resultObject1["CI_ID"].IntegerValue != integerValue)
                    {
                        this.isApplicationRetired = false;
                    }
                }
            }
        }
        return this.isApplicationRetired;
    }
于 2013-06-04T18:43:48.947 回答