简体   繁体   English

PowerShell将集合移动到SCCM中的另一个文件夹?

[英]PowerShell Move collection to another folder in SCCM?

I have a script that creates collections in SCCM but I need to have it created in one of the sub folders under "Device Collections". 我有一个在SCCM中创建集合的脚本,但是我需要在“设备集合”下的一个子文件夹中创建它。 I cant see to figure out how to move the collection using the WMI class. 我看不出如何使用WMI类移动集合。 Since this script does not run on the SCCM server itself I cant use configmanager module for Move-CMobject . 由于此脚本未在SCCM服务器本身上运行,因此我无法将configmanager模块用于Move-CMobject Is there a way to implement a collection move using the PowerShell code style below? 有没有一种使用下面的PowerShell代码样式来实现集合移动的方法?

$CMCollection = ([WMIClass]”\root\sms\site_:SMS_Collection”).CreateInstance()
$CMCollection.name = $CollectionName
$CMCollection.LimitToCollectionID = “12345678”
$CMCollection.RefreshType = 2
$CMCollection.Put()

You need the method MoveMembers of the class SMS_ObjectContainerItem . 你需要的方法MoveMembers类的SMS_ObjectContainerItem After you created the collection (It is not possible to create in the correct path afaik). 创建集合后(无法在正确的路径中创建afaik)。

The powershell code would be something like this: powershell代码将如下所示:

[Array]$DeviceCollectionID = <CollID>
$TargetFolderID = <ContainerNodeID>
$CurrentFolderID = 0
$ObjectTypeID = 5000

Invoke-WmiMethod -Namespace 'Root\SMS\Site_<SiteCode>' -Class 'SMS_objectContainerItem' -Name 'MoveMembers' -ArgumentList $CurrentFolderID,$DeviceCollectionID,$ObjectTypeID,$TargetFolderID

To get the ContainerNodeID of your Target folder you can use a query like this: 要获取目标文件夹的ContainerNodeID,可以使用如下查询:

select * from sms_objectcontainernode where objecttypeName = 'sms_collection_device' where Name =<your target folder name>

I found no valid ms source for the ObjectIDTypes but from my own programs and several samples I know 5000 is for collection folders. 我没有找到ObjectIDTypes的有效ms来源,但是从我自己的程序和几个我知道有5000个样本用于收集文件夹的样本中。 The CurrentFolderID is always 0 if you just created something programatically because it will be in root. 如果您刚刚以编程方式创建了某些内容,则CurrentFolderID始终为0,因为它将位于根目录中。 For an existing folder you can figure it out the same way as your target. 对于现有文件夹,您可以用与目标文件夹相同的方法来计算。

There is also this list from some code sample I found which has no source but is probably correct. 我发现的一些代码示例中也有此列表,该列表没有源,但可能是正确的。

Object type 2 - Package Folder
Object type 7 - Query Folder
Object type 9 - Software Metering Folder
Object type 14 - Operating System Installers Folder
Object type 17 - State Migration GFolder
Object type 18 - Image Package Folder
Object type 19 - Boot Image Folder
Object type 20 - Task Sequence Folder
Object type 23 - Driver Package Folder
Object type 25 - Driver Folder
Object type 2011 - Configuration Baseline Folder
Object type 5000 - Device Collection Folder
Object type 5001 - User Collection Folder
Object type 6000 - Application Folder
Object type 6001 - Configuration Item Folder

If you need some type that is missing you can also look at the sms_objectcontainernode instances and just check what your given folders have as type 如果您需要某种缺少的类型,还可以查看sms_objectcontainernode实例,然后仅检查给定文件夹的类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Powershell创建另一个文件夹并在Outlook中移动电子邮件 - Powershell to create another folder and move emails in Outlook Powershell 将所有下载移动到另一个文件夹 function - Powershell move all download to another folder function 使用Powershell将计算机移至SCCM 2012任务序列中的新OU - Move Computer to new OU in SCCM 2012 Task Sequence with Powershell SCCM Powershell SCRIPT从文件夹层次结构中获取对象位置 - SCCM Powershell SCRIPT to get object location from folder hierarchy 使用Powershell将带有特殊附件的电子邮件移动到另一个文件夹Outlook 2010 - Move Email with special attachments to another folder Outlook 2010 with powershell Powershell将文本文件从一个文件夹移动到另一个文件夹 - Powershell to move text files from one folder to another powershell,如何管理目录并将文件移动到另一个文件夹 - powershell, how to mointor a directory and move files over to another folder Powershell 解压缩扩展名为 .zip 的文件并将其移动到另一个文件夹 - Powershell unzip file with .zip extension and move it to another folder 在Powershell中将X文件从一个文件夹移动到另一个文件夹 - Move X files from one folder to another in Powershell Powershell SCCM 客户端模块 - Powershell module for SCCM Client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM