how to temporarily un-protect certain objects??

This topic contains 2 replies, has 2 voices, and was last updated by  tommls 3 years, 6 months ago.

  • Author
    Posts
  • #16253

    tommls
    Participant

    I have this PS script for protecting AD objects that I got from a website, it works very well:

    cls
    import-module activedirectory
    Get-ADObject -filter {ObjectClass -eq "user" -or ObjectClass -eq "group"} | Set-ADObject -ProtectedFromAccidentalDeletion:$true
    Get-ADOrganizationalUnit -filter * | Set-ADObject -ProtectedFromAccidentalDeletion:$true

    My question: How do I rewrite line two so it only affects the members of the "Computers" group??
    I need to temporarily set this value to 'false' so I can move 150+ computers to a group that's enabled for WSUS updates but I'm not sure how to apply it only the "Computers" group...
    I can comment out line four...
    Thank you, Tom

  • #16254

    Adam Bertram
    Moderator

    This will take off accidental deletion for only members of the Computers Active Directory group. Just change it to $true again when you want to enable it again.

    Get-ADGroupMember 'Computers' | Set-ADObject -ProtectedFromAccidentalDeletion:$false

  • #16257

    tommls
    Participant

    I ended up using

    Get-ADComputer -Filter {OperatingSystem -like "*Windows 7*"} | Set-ADObject -ProtectedFromAccidentalDeletion:$false

    The other line threw errors.
    Then I moved computers manually to the WSUS updates group and will monitor them.
    Then I re-protected everything.
    Thank you, Tom

You must be logged in to reply to this topic.