Remove/change a Requirement condition on a deployment Type

Frank Vanhoorne 46 Reputation points
2022-06-27T11:16:10.5+00:00

I want to change a requirement on a deployment type. I want to delete a certain OS requirement (Windows 7)
I want to do this in powershell. I tried many times but I can't get my changed saved

Script I use :

$CMApplication = ConvertTo-CMApplication -InputObject (Get-CMApplication -Name "MyAppName")
$DT = $CMApplication.DeploymentTypes
$Requirement = $DT.requirements[0]
$Requirement.Expression.Operands.Remove("Windows/All_x64_Windows_7_Client")
$Requirement.Expression.Operands.Remove("Windows/All_x86_Windows_7_Client")

$Application = ConvertFrom-CMApplication -Application $CMApplication

$Application.Put()

ps - I can add new requirements but I can't change an allready existing one

Microsoft Configuration Manager Application
Microsoft Configuration Manager Application
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Application: A computer program designed to carry out a specific task other than one relating to the operation of the computer itself, typically to be used by end users.
512 questions
0 comments No comments
{count} votes

Accepted answer
  1. AllenLiu-MSFT 47,886 Reputation points Microsoft Vendor
    2022-06-28T01:55:17.947+00:00

    Hi, @Frank Vanhoorne

    Thanks very much for your feedback. We're glad that the problem is solved now. Here's a short summary for the problem, we believe this will help other users to search for useful information more quickly.

    Problem/Symptom:
    Use powershell to delete a certain OS requirement (Windows 7) on a deployment type.

    Solution/Workaround:

    $CMApplication = ConvertTo-CMApplication -InputObject (Get-CMApplication -Name "MyAppName")  
    $DT = $CMApplication.DeploymentTypes[0]  
      
    $Requirement = $DT.requirements[0]  
    $Requirement.Expression.Operands.Remove("Windows/All_x64_Windows_7_Client")  
    $Requirement.Expression.Operands.Remove("Windows/All_x86_Windows_7_Client")  
      
    $Application = ConvertFrom-CMApplication -Application $CMApplication  
      
    $Application.Put()  
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Frank Vanhoorne 46 Reputation points
    2022-06-27T15:02:53.227+00:00

    This worked

    $CMApplication = ConvertTo-CMApplication -InputObject (Get-CMApplication -Name "MyAppName")
    $DT = $CMApplication.DeploymentTypes[0]

    $Requirement = $DT.requirements[0]
    $Requirement.Expression.Operands.Remove("Windows/All_x64_Windows_7_Client")
    $Requirement.Expression.Operands.Remove("Windows/All_x86_Windows_7_Client")

    $Application = ConvertFrom-CMApplication -Application $CMApplication

    $Application.Put()

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.