make changes for unchecked boxes

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. }
 

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

[quote quote=207705]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

[/quote]
my bad.