共用方式為


New-CMCollection

建立裝置或使用者集合。

語法

New-CMCollection
   -CollectionType <CollectionType>
   [-Comment <String>]
   -LimitingCollectionName <String>
   -Name <String>
   [-RefreshSchedule <IResultObject>]
   [-RefreshType <CollectionRefreshType>]
   [-VariablePriority <Int32>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-CMCollection
   -CollectionType <CollectionType>
   [-Comment <String>]
   -InputObject <IResultObject>
   -Name <String>
   [-RefreshSchedule <IResultObject>]
   [-RefreshType <CollectionRefreshType>]
   [-VariablePriority <Int32>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-CMCollection
   -CollectionType <CollectionType>
   [-Comment <String>]
   -LimitingCollectionId <String>
   -Name <String>
   [-RefreshSchedule <IResultObject>]
   [-RefreshType <CollectionRefreshType>]
   [-VariablePriority <Int32>]
   [-DisableWildcardHandling]
   [-ForceWildcardHandling]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

使用此 Cmdlet 建立裝置或使用者集合。

限制集合會決定哪些資源可以是您所建立之集合的成員。 例如,當您使用 All Systems 集合做為限制集合時,由於它是裝置集合,所以新的裝置集合可以在 Configuration Manager 階層中包含任何裝置。

若要界定您建立的集合類型,您也可以使用 New-CMDeviceCollectionNew-CMUserCollection Cmdlet。

建立集合之後,請使用成員資格規則將資源新增至集合。 若要將成員新增至集合,請使用其中一個 Cmdlet 來新增成員資格規則,例如:

如需詳細資訊,請 參閱如何在 Configuration Manager 中建立集合

注意事項

從 Configuration Manager 月臺磁碟驅動器執行 Configuration Manager Cmdlet,例如 PS XYZ:\>。 如需詳細資訊,請 參閱開始使用

範例

範例 1:建立使用者集合

此命令會建立名為 testUser 的 使用者集合,將 All Users 集合設定為限制集合。

New-CMCollection -CollectionType User -LimitingCollectionName "All Users" -Name "testUser"

範例 2:透過管線設定限制集合

此命令會先使用 Get-CMCollection 來取得 All Users 集合物件。 然後,它會使用管線運算符將對象傳遞至 New-CMCollection Cmdlet,以建立名為 testUser 的集合。 新 testUser 集合的限制集合是 All Users 集合。

Get-CMCollection -Name "All Users" | New-CMCollection -Name "testUser" -CollectionType "User"

參數

-CollectionType

指定要建立的集合類型。 此參數的功能與使用 New-CMDeviceCollectionNew-CMUserCollection Cmdlet 相同。

類型:CollectionType
接受的值:User, Device
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Comment

指定選擇性批注來描述及識別此集合。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Confirm

執行 Cmdlet 之前提示您確認。

類型:SwitchParameter
別名:cf
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

-DisableWildcardHandling

此參數會將通配符視為常值字元值。 您無法將其與 ForceWildcardHandling 結合。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-ForceWildcardHandling

此參數會處理通配符,並可能導致非預期的行為 (不建議) 。 您無法將其與 DisableWildcardHandling 結合。

類型:SwitchParameter
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-InputObject

指定限制集合的物件。 若要取得此物件,請使用 Get-CMCollectionGet-CMDeviceCollectionGet-CMUserCollection Cmdlet。

類型:IResultObject
別名:LimitingCollection
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-LimitingCollectionId

指定限制集合的識別碼。 這個值是 CollectionID 屬性,例如 或 XYZ00012SMS00001

類型:String
別名:LimitToCollectionId
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-LimitingCollectionName

指定限制集合的名稱。

類型:String
別名:LimitToCollectionName
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Name

指定新集合的名稱。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-RefreshSchedule

如果您將 RefreshType 參數設定為 PeriodicBoth,請使用此參數來設定排程。 指定當網站執行集合成員資格的完整更新時的排程物件。 若要取得此物件,請使用 New-CMSchedule Cmdlet。

類型:IResultObject
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-RefreshType

指定集合成員資格的更新方式:

  • Manual (1) :系統管理員在 Configuration Manager 控制台或 使用 Invoke-CMCollectionUpdate Cmdlet 手動觸發成員資格更新。
  • Periodic (2) :網站會依排程執行完整更新。 它不會使用累加式更新。 如果您未指定類型,則此值為預設值。
  • Continuous (4) :網站會定期評估新的資源,然後新增成員。 此類型也稱為 累加式更新。 它不會依排程執行完整更新。
  • Both (6) :和 的PeriodicContinuous組合,同時包含累加式更新和排程上的完整更新。

如果您指定 PeriodicBoth,請使用 RefreshSchedule 參數來設定排程。

注意事項

None (0) 的值在功能上與 Manual相同。

類型:CollectionRefreshType
接受的值:None, Manual, Periodic, Continuous, Both
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-VariablePriority

針對裝置集合變數的優先順序,指定從 1 到 9 的整數值。 1 是最低優先順序,且 9 是最高的。

若要在裝置集合上建立變數,請使用 New-CMDeviceCollectionVariable Cmdlet。

類型:Int32
別名:DeviceCollectionVariablePrecedence
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-WhatIf

顯示執行 Cmdlet 時會發生什麼情況。 Cmdlet 不會執行。

類型:SwitchParameter
別名:wi
Position:Named
預設值:False
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

Microsoft.ConfigurationManagement.ManagementProvider.IResultObject

輸出

IResultObject

備註

如需此傳回物件及其屬性的詳細資訊,請 參閱SMS_Collection伺服器 WMI 類別