我在我的系统上运行下面的脚本来执行所有 sccm 客户端操作触发器并出现以下错误。
Run-SCCMClientAction : Connecting to remote server DD4 failed with the following error message : The WS-Management service cannot process the request. The service is
configured to not accept any remote shell requests. For more information, see the about_Remote_Troubleshooting Help topic.
At line:60 char:2
+ Run-SCCMClientAction -Computername $env:COMPUTERNAME -ClientAction A ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Run-SCCMClientAction
Function Run-SCCMClientAction {
[CmdletBinding()]
# Parameters used in this function
param
(
[Parameter(Position=0, Mandatory = $True, HelpMessage="Provide PC names", ValueFromPipeline = $true)]
[string[]]$Computername,
[ValidateSet('MachinePolicy',
'DiscoveryData',
'ComplianceEvaluation',
'AppDeployment',
'HardwareInventory',
'UpdateDeployment',
'UpdateScan',
'SoftwareInventory')]
[string[]]$ClientAction
)
$ActionResults = @()
Try {
$ActionResults = Invoke-Command -ComputerName $Computername {param($ClientAction)
Foreach ($Item in $ClientAction) {
$Object = @{} | select "Action name",Status
Try{
$ScheduleIDMappings = @{
'MachinePolicy' = '{00000000-0000-0000-0000-000000000021}';
'DiscoveryData' = '{00000000-0000-0000-0000-000000000003}';
'ComplianceEvaluation' = '{00000000-0000-0000-0000-000000000071}';
'AppDeployment' = '{00000000-0000-0000-0000-000000000121}';
'HardwareInventory' = '{00000000-0000-0000-0000-000000000001}';
'UpdateDeployment' = '{00000000-0000-0000-0000-000000000108}';
'UpdateScan' = '{00000000-0000-0000-0000-000000000113}';
'SoftwareInventory' = '{00000000-0000-0000-0000-000000000002}';
}
$ScheduleID = $ScheduleIDMappings[$item]
Write-Verbose "Processing $Item - $ScheduleID"
[void]([wmiclass] "root\ccm:SMS_Client").TriggerSchedule($ScheduleID);
$Status = "Success"
Write-Verbose "Operation status - $status"
}
Catch{
$Status = "Failed"
Write-Verbose "Operation status - $status"
}
$Object."Action name" = $item
$Object.Status = $Status
$Object
}
} -ArgumentList $ClientAction -ErrorAction Stop | Select-Object @{n='PCName';e={$_.pscomputername}},"Action name",Status
}
Catch{
Write-Error $_.Exception.Message
}
Return $ActionResults
}
Run-SCCMClientAction -Computername $env:COMPUTERNAME -ClientAction AppDeployment
答案1
要运行脚本,只需将其作为配置项的一部分并将其添加到基线即可。将基线部署到您希望脚本运行的集合。完成后,客户端将下载脚本的副本并执行它。
话虽如此,还要确保您已正确配置客户端设置,因为您实际上不需要强制执行这些操作。