所以我有这个可爱的脚本,它将在 SCCM 2012 中创建文件夹和驱动程序包,它创建了文件夹和驱动程序包,但我不知道如何将它们放在正确的文件夹中。我认为 PkgFlags 会这样做,但这似乎什么也没做,我找不到移动包的函数。
我已经为此工作了几天,但一无所获
请帮忙
$SCCMSiteCode = Read-Host "SCCM Site Code"
$PackageNamePath = Read-Host "Driver Package Original Path"
$PackageSourcePath = Read-Host "Driver Package Source Path"
$FolderArray1 = Get-ChildItem -Path "$PackageNamePath"
foreach ($FolderList1 in $FolderArray1)
{
if (($FolderList1.name -Like "Server*") -or ($FolderList1.name -Like "Windows*"))
{
$Argument1 = @{Name = "$FolderList1"; ObjectType = 23; ParentContainerNodeId = 0}
Set-WmiInstance -Namespace "root\sms\site_$SCCMSiteCode" -Class "SMS_ObjectContainerNode" -Arguments $Argument1
$GetID1 = Get-wmiObject -Namespace root\SMS\site_$SCCMSiteCode -Query "Select name,containernodeid from SMS_ObjectContainerNode" | select name,ContainerNodeID | Where-Object {$_.Name -eq $FolderList1}
$FolderArray2 = Get-ChildItem -Path "$PackageNamePath\$FolderList1"
foreach ($FolderList2 in $FolderArray2)
{
if (($FolderList2.name -NotLike "Server*") -or ($FolderList2.name -NotLike "Windows*"))
{
$DateTime = get-date -Format yyyy.MM.dd-hh.mm.ss
$Milliseconds = (get-date).millisecond
$FullDateTime = "$DateTime.$Milliseconds"
New-Item -ItemType Directory -Path "$PackageSourcePath\$FullDateTime"
$PackageName = "$FolderList2 - $FolderList1"
$Argument2 = @{Name = "$PackageName"; PkgSourcePath = "$PackageSourcePath\$FullDateTime"; PkgSourceFlag = 2; PkgFlags = $GetID1.ContainerNodeID}
Set-WmiInstance -Namespace "root\sms\site_$SCCMSiteCode" -Class "SMS_DriverPackage" -Arguments $Argument2
}
}
}
}