how to temporarily un-protect certain objects??

Welcome Forums General PowerShell Q&A how to temporarily un-protect certain objects??

This topic contains 2 replies, has 2 voices, and was last updated by

4 years, 8 months ago.

  • Author
  • #16253

    Points: -19
    Rank: Member

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

    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

    Points: 22
    Rank: Member

    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

    Points: -19
    Rank: Member

    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

The topic ‘how to temporarily un-protect certain objects??’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort