【发布时间】:2018-10-10 18:36:46
【问题描述】:
我们使用 SCCM 2016 来安装 Microsoft 更新并进行多个部署,但截止日期已过。我希望能够使用脚本将这些截止日期推迟到未来的日期,因为使用 GUI 手动更改每个部署非常耗时。
这个命令显示了我感兴趣的部署:
Get-CMDeployment | Select-Object -Property * | Where-Object {`
$_.SoftwareName -like '*SecurityUpdates*' -and $_.CollectionName -like '*Servers*'
}
我的研究表明我应该使用Set-CMSoftwareUpdateDeployment 来修改现有部署的截止日期。然而,这就是我卡住的地方。根据以下线程,我应该用来定义新期限的参数是DeploymentExpireDay 和DeploymentExpireTime,并确保部署设置为必需:
https://social.technet.microsoft.com/Forums/ie/en-US/11f977f4-09d1-4127-b8ce-7cdb19c88d1b/update-deployment-installation-deadlines-via-powershell?forum=configmanagersecurity
不确定如何构造一个工作命令,我查阅了 cmdlet 的 MS 文档:https://docs.microsoft.com/en-us/powershell/module/configurationmanager/set-cmsoftwareupdatedeployment?view=sccm-ps
查看文档,DeploymentExpireDay 和 DeploymentExpireTime 未在参数列表中列出。只有DeploymentExpireDateTime 在列表中。然而,为了增加混淆,这两个参数包含在示例中,而 DeploymentExpireDateTime 没有。
我这样连接到 SCCM:
#Load Configuration Manager PowerShell Module
Import-module ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5) + '\ConfigurationManager.psd1')
#Get SiteCode and set Powershell Drive
$SiteCode = (Get-PSDrive -PSProvider CMSITE).Name
Push-Location "$($SiteCode):\"
我试过了:
$DeadlineDay = Get-Date -Month 11 -Day 08 -Year 2018
$DeadlineTime = Get-Date -Hour 16 -Minute 0 -Second 0
Set-CMSoftwareUpdateDeployment `
-DeploymentName "Deployment Name" `
-DeploymentType Required `
-DeploymentExpireDay $DeadlineDay `
-DeploymentExpireTime $DeadlineTime
但我明白了:
Set-CMSoftwareUpdateDeployment : A parameter cannot be found that matches parameter name 'DeploymentExpireDay'.
At line:1 char:104
+ ... ment Name" -DeploymentType Required -DeploymentExpireDay $Deadli ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-CMSoftwareUpdateDeployment], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ConfigurationManagement.Cmdlets.Deployments.Commands.SetSoftwareUpdateDeploymentCommand
所以我尝试了这个:
$date = (Get-Date).AddDays(20)
Set-CMSoftwareUpdateDeployment `
-DeploymentName "Deployment Name" `
-DeploymentType Required `
-DeploymentExpireDateTime $date
但我明白了:
cmdlet Set-CMSoftwareUpdateDeployment at command pipeline position 1
Supply values for the following parameters:
InputObject:
PS SCM:\>
谁能告诉我我做错了什么?提前致谢!
【问题讨论】:
标签: powershell sccm