make changes for unchecked boxes

Welcome Forums General PowerShell Q&A make changes for unchecked boxes

Viewing 2 reply threads
  • Author
    Posts
    • #207702
      Participant
      Topics: 2
      Replies: 2
      Points: 29
      Rank: Member

      Hi,

      this code makes changes to checked items, i’d like it to make changes for the unchecked items as well in the same line but i was very unsuccessful of getting it to work. can someone help me pls ?

       

      1. $objTypeCheckbox = New-Object System.Windows.Forms.CheckedListbox
      2. $objTypeCheckbox.Location = New-Object System.Drawing.Point(10,40)
      3. $objTypeCheckbox.Size = New-Object System.Drawing.Size(260,20)
      4. $objTypeCheckbox.Height = 80
      5. import-csv ‘C:\scripts\gpos.csv’ | ForEach-Object {
      6. $objTypeCheckbox.Items.Add($_.Displayname)
      7. $objTypeCheckbox.CheckOnClick=$true
      8. }
      9. $form.Controls.Add($objTypeCheckbox)
      10. $form.Topmost = $true
      11. $result = $form.ShowDialog()
      12. $us = [Microsoft.VisualBasic.Interaction]::InputBox(“Select user”, “user name”)
      13. $permissionLevel = if ($result -eq [System.Windows.Forms.DialogResult]::Yes) { ‘GpoApply’ } else {” }
      14. foreach ($checkedPolicy in $objTypeCheckbox.CheckedItems) {
      15.     Write-Host “Applying $permissionLevel to $checkedPolicy”
      16.      Set-GPPermissions -Name $checkedPolicy -PermissionLevel $permissionLevel -TargetName $us -TargetType User -Domain domain.domain
      17. }

       

    • #207705
      Participant
      Topics: 4
      Replies: 2247
      Points: 5,484
      Helping Hand
      Rank: Community MVP

      When you corosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or even more.

      https://social.technet.microsoft.com/Forums/en-US/abab94e2-cad9-47f1-ba1a-2265f99a5f27/make-changes-for-unchecked-boxes?forum=winserverpowershell

    • #207714
      Participant
      Topics: 2
      Replies: 2
      Points: 29
      Rank: Member

      When you corosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or even more.

      https://social.technet.microsoft.com/Forums/en-US/abab94e2-cad9-47f1-ba1a-2265f99a5f27/make-changes-for-unchecked-boxes?forum=winserverpowershell

      my bad.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.