how to delete a reg key ?

Tushar Debnath 176 Reputation points
2023-04-19T12:16:00.5433333+00:00

Hi , Someone please help me to write a ps script for intune remediation to delete a reg key ? Thanks

Microsoft Security | Intune | Other
{count} votes

Accepted answer
  1. Crystal-MSFT 53,986 Reputation points Microsoft External Staff
    2023-04-20T02:16:45.2266667+00:00

    @Tushar Debnath, Thanks for posting in Q&A.

    To use Proactive Remediations to delete a registry key, here is a link with an example for your reference:

    https://andrewstaylor.com/2022/04/12/proactive-remediations-101-intunes-hidden-secret/

    Note: Non-Microsoft link, just for the reference.

    I notice you want to delete a registry key. You can change the "new-item" command to "Remove-ItemProperty" to meet your requirement.

    Here is a remediation script example for your reference:

    Start-Transcript -Path $env:TEMP\DisableFastBoot.txt if(Get-ItemProperty -LiteralPath "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "test") {Remove-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power' -Name 'test'; write-host "Value delete"}; Stop-Transcript  
    
    

    Note: You can change it according to your requirement.

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-itemproperty?view=powershell-7.3

    Hope it can help.


    If the answer is helpful, 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 additional answers

Sort by: Most helpful

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.