I'm new to powershell (and really scripting in general) and I've recently created a tool to search and delete malicious files on a remote host (I work in security ops) but I'm struggling to work out how to do the same with registry keys and registry values. I have a list of the entries I'm looking for to be used as an array and need the script to cycle through them.
Can anyone give me any steers or advice on this? This is what I have cobbled together so far from other threads. It runs through the array fine but keeps trying to search within the directory the script is in at the moment.
$computer = Read-Host -Prompt ‘Input target host’
$mallist = @("mazqnjrurg","mazqnjrurg.vbs","Angry Birds","Angry Birds.vbe")
foreach ($mal in $mallist)
{ $Reg = Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
$RegKey= $Reg.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run")
get-childitem $regkey | foreach-object {if ($_ -match "$mal"){Remove-Item -Path "Registry::$_" }}
}
Thank you