• Gallery
  • Hot Cold Ground Blues Band
  • Links
  • Music
  • Nurburgring 2010 Blog
  • Support
« Teams in a domain environment | Home | Daniel's Website, I presume? »

Powershell detect and delete a registry entry

Thursday 30 June 2022 at 5:25 pm

I'm sure this will be better documented elsewhere on the web, but I like to add snippets here which may help a person with the same query as me.

I wanted to use PS to see if a particular entry in HKLM\Microsoft\Windows\CurrentVersion\Run is there, and if it is, delete it so the program doesn't autorun.  So here's my code:

$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\run"
$test = (Get-ItemProperty -Path $path -Name "softwarename") #you can use wildcard * to find
if ($test -ne $null)
{
Write-Host "deleting reg entry"
Remove-ItemProperty $path -Name "softwarename"
}
Else
{
Write-Host "it's not there, bye"
}

It's probably clunky and badly-written, but works for me!

XML: RSS FeedXML: Atom FeedPowered by PivotX - 2.3.11

Site Pages

    Pages
    • Gallery
    • Links
    • Music
    • Nurburgring 2010 Blog
    • Support
    • Hot Cold Ground Blues Band

Blog Categories

  • home
  • bikes
  • funny
  • music
  • projects
  • random
  • rants

About

This is the personal website of Daniel Carway.

All characters, scenarios and events are entirely fictitious and should not be confused with real people and situations. Any similarity to your own life is completely your own fault. admin

Links

  • This site built on PivotX
  • PivotX Forum
  • PivotX Documentation
  • PivotX Extensions
  • PivotX Themes

Search

Search for words used in entries and pages on this website