我们使用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
在Doco中,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:\>
有人可以指导我关于我做错了什么吗?预先感谢!
答案 0 :(得分:1)
您可能需要除DeploymentName之外的更多信息才能使此信息可识别。尝试同时指定参数-SoftwareUpdateGroupName和-DeploymentName,所以
$date = (Get-Date).AddDays(20)
Set-CMSoftwareUpdateDeployment `
-DeploymentName "Deployment Name" `
-SoftwareUpdateGroupName "Software Update Group Name" `
-DeploymentType Required `
-DeploymentExpireDateTime $date
如果您不知道软件更新组的名称,我会走完全不同的路线。
首先使用
进行部署Get-CMSoftwareUpdateDeployment
我认为在您的情况下,您无论如何都想要它们,但如果没有,您可能必须使用“ where ”进行过滤,因为-Name参数似乎已损坏。
然后将获得的对象用作Set-CMSoftwareUpdateDeployment的InputObject,使名称变通并修改时间:
Get-CMSoftwareUpdateDeployment | where {$_.AssignmentName -eq "Deployment Name"}
| Set-CMSoftwareUpdateDeployment -DeploymentExpireDateTime (Get-Date).AddDays(20)