Configuration Managerで Windows ドライバーのドライバー パッケージを作成する方法

オペレーティング システム展開ドライバーのパッケージをConfiguration Managerで作成するには、SMS_DriverPackage サーバー WMI クラス オブジェクトを作成します。 パッケージにドライバーを追加するには、 クラス SMS_DriverPackageで AddDriverContent メソッドを呼び出します。

ドライバー パッケージは、ドライバーに関連付けられているコンテンツを格納するために使用されます。 ドライバー パッケージを作成する場合、ソースの場所は、SMS プロバイダーが読み取りおよび書き込みアクセス権を持つ空の共有である必要があります。 を使用して AddDriverContentドライバーがドライバー パッケージに追加されると、SMS プロバイダーは、ドライバー ソースの場所からドライバー パッケージ共有のサブディレクトリにコンテンツをコピーします。

ドライバーに関連付けられているコンテンツをドライバー パッケージに追加し、クライアントが使用する前に配布ポイントに割り当てる必要があります。 プロパティがドライバー識別子と一致 するSMS_CIToContent サーバー WMI クラス オブジェクト CI_ID からドライバーコンテンツを取得します。

注:

複数のドライバーが同じコンテンツを共有できます。 これは通常、同じディレクトリに複数の .inf ファイルがある場合に発生します。

AddDriverContent を使用して、複数のドライバーをパッケージに同時に追加できます。 これを行うには、複数のコンテンツ ID を追加します。 別の bRefreshDPs 呼び出しが行われる場合は、 パラメーターを に false 設定する必要があります。 これにより、パッケージは配布ポイントで 1 回だけ更新されます。

を呼び出 AddDriverContentすときは、パッケージ ソースの場所のセットを指定します。 通常、これは SMS_Driver サーバー WMI クラス オブジェクト ContentSourcePath プロパティですが、プロバイダーが元のソースの場所にアクセスできない場合はオーバーライドできます。

ドライバー パッケージを作成し、ドライバー コンテンツを追加するには

  1. SMS プロバイダーへの接続を設定します。 詳細については、「 SMS プロバイダーの基礎」を参照してください。

  2. SMS_DriverPackage オブジェクトを作成します。

  3. オブジェクトの プロパティを PkgSourceFlag ( SMS_DriverPackage Storage Direct) に 2 設定します。

  4. オブジェクトをコミットします SMS_DriverPackage

  5. オブジェクトを SMS_DriverPackage 取得します。

  6. パッケージに追加するドライバーの一覧を パラメーターの AddDriverContent メソッド ContentIDs に配置します。

  7. ドライバー コンテンツ ソース パスの一覧を AddDriverContent パラメーターの メソッド ContentSourcePath に配置します。

  8. メソッドを AddDriverContent 呼び出します。

  9. クラス SMS_DriverPackage で RefreshPkgSource メソッドを呼び出して、操作を完了します。

  10. ドライバー パッケージを配布ポイントに割り当てます。 詳細については、「 配布ポイントにパッケージを割り当てる方法」を参照してください。

次のメソッドの例では、SMS_Driver サーバー WMI クラス オブジェクトの プロパティでCI_ID表される、指定されたドライバー識別子のパッケージを作成します。 メソッドは、新しいパッケージ名、説明、およびパッケージ ソース パスもパラメーターとして受け取ります。

注:

パラメーターは packageSourcePath 、汎用名前付け規則 (UNC) ネットワーク パス (\\localhost\Drivers\ATIVideo\ など) として指定する必要があります。

サンプル コードの呼び出しについては、「Configuration Manager コード スニペットの呼び出し」を参照してください。

Sub CreateDriverPackage(connection, driverId, newPackageName, newPackageDescription,  newPackageSourcePath)  

    Dim newPackage  
    Dim driver   
    Dim packageSources  
    Dim refreshDPs  
    Dim content   
    Dim path  
    Dim contentIds  
    Dim index  
    Dim item  

    ' Create the new driver package object.  
    Set newPackage = connection.Get("SMS_DriverPackage").SpawnInstance_  

    ' Populate the new package properties.  
    newPackage.Name = newPackageName  
    newPackage.Description = newPackageDescription  
    newPackage.PkgSourceFlag = 2 ' Storage direct  
    newPackage.PkgSourcePath = newPackageSourcePath  

    ' Save the package.  
    path=newPackage.Put_  

    ' Get the newly created package (Do this to call AddDriverContent).  
    Set newPackage=connection.Get(path)  

    ' Get the driver  
    Set driver = connection.Get("SMS_Driver.CI_ID=" & driverId )  

    ' Get the driver content.  
    Set content = connection.ExecQuery("Select * from SMS_CIToContent where CI_ID=" & driverId)  

    If content.Count = 0 Then  
        Wscript.Echo "No content found"  
        Exit Sub  
    End If  

    ' Create Array to hold driver content identifiers.  
    contentIds = Array()  
    ReDim contentIds(content.Count-1)  
    index = 0  

    For Each item In content           
        contentIds(index) = item.ContentID   
        index = index+1         
    Next  

    ' Create sources path Array.  
    packageSources = Array(driver.ContentSourcePath)  
    refreshDPs = False  

    ' Add the driver content.  
    Call newPackage.AddDriverContent(contentIds,packageSources,refreshDPs)  
    wscript.echo "Done"  

End Sub  
public void CreateDriverPackage(  
    WqlConnectionManager connection,   
    int driverId,   
    string newPackageName,   
    string newPackageDescription,   
    string newPackageSourcePath)  
{  
    try  
    {  
        if (Directory.Exists(newPackageSourcePath) == false)  
        {  
            throw new DirectoryNotFoundException("Package source path does not exist");  
        }  

        // Create new package object.  
        IResultObject newPackage = connection.CreateInstance("SMS_DriverPackage");  

        IResultObject driver = connection.GetInstance("SMS_Driver.CI_ID=" + driverId);  

        newPackage["Name"].StringValue = newPackageName;  
        newPackage["Description"].StringValue = newPackageDescription;  
        newPackage["PkgSourceFlag"].IntegerValue = (int)PackageSourceFlag.StorageDirect;  
        newPackage["PkgSourcePath"].StringValue = newPackageSourcePath;  

        // Save new package and new package properties.  
        newPackage.Put();  

        newPackage.Get();  

        // Get the content identifier.  
        List<int> contentIDs = new List<int>();  
        IResultObject content = connection.QueryProcessor.ExecuteQuery("Select * from SMS_CIToContent where CI_ID=" + driverId);  

        foreach (IResultObject ro in content)  
        {  
            contentIDs.Add(ro["ContentID"].IntegerValue);  
        }  

        // Get the package source.  
        List<string> packageSources = new List<string>();  
        packageSources.Add(driver["ContentSourcePath"].StringValue);  

        Dictionary<string, Object> inParams = new Dictionary<string, object>();  

        inParams.Add("bRefreshDPs", true);  
        inParams.Add("ContentIDs", contentIDs.ToArray());  
        inParams.Add("ContentSourcePath", packageSources.ToArray());  

        newPackage.ExecuteMethod("AddDriverContent", inParams);  
    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed to create package. Error: " + ex.Message);  
        throw;  
    }  
}  

このメソッドの例には、次のパラメーターがあります。

パラメーター 説明
connection -管理: WqlConnectionManager
- VBScript: SWbemServices
SMS プロバイダーへの有効な接続。
driverId -管理: Integer
-Vbscript: Integer
ドライバー識別子 (SMS_Driver.CI_ID)。
newPackageName -管理: String
-Vbscript: String
パッケージの名前。
newPackageDescription -管理: String
-Vbscript: String
新しいパッケージの説明。
newPackageSourcePath -管理: String
-Vbscript: String
ドライバーへの有効な UNC ネットワーク パス。

コードのコンパイル

この C# の例では、次のものが必要です。

名前空間

System

System.Collections.Generic

System.text

System.io

Microsoft。ConfigurationManagement.ManagementProvider

Microsoft。ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

堅牢なプログラミング

エラー処理の詳細については、「Configuration Manager エラーについて」を参照してください。

.NET Framework のセキュリティ

Configuration Manager アプリケーションのセキュリティ保護の詳細については、「ロールベースの管理Configuration Manager」を参照してください。

関連項目

SMS_Driver サーバー WMI クラス
クラス SMS_DriverPackageの AddDriverContent メソッド