gpt4 book ai didi

powershell - SCCM-使用PowerShell更改现有部署截止日期

转载 作者:行者123 更新时间:2023-12-02 23:53:20 29 4
gpt4 key购买 nike

我们使用SCCM 2016来安装Microsoft更新,并具有多个截止日期为过去日期的部署。我希望能够使用脚本将这些截止日期推迟到将来的日期,因为使用GUI手动更改每个部署非常耗时。

enter image description here

该命令向我展示了感兴趣的部署:

Get-CMDeployment | Select-Object -Property * | Where-Object {`
$_.SoftwareName -like '*SecurityUpdates*' -and $_.CollectionName -like '*Servers*'
}

我的研究表明,我应该使用 Set-CMSoftwareUpdateDeployment修改现有部署的截止日期。但是,这就是我遇到的问题。根据以下线程,我用于定义新截止日期的参数是 DeploymentExpireDayDeploymentExpireTime,并确保将部署设置为必需:
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,参数列表中未列出 DeploymentExpireDayDeploymentExpireTime。列表中仅 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:\>

谁能指导我我做错了什么?提前致谢!

最佳答案

为了使这一点可识别,您可能不仅需要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)

关于powershell - SCCM-使用PowerShell更改现有部署截止日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52731119/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com