PowerShell Remove-ItemProperty

CkKrupka

Beta member
Messages
3
I am trying to create a powershell script for our helpdesk folks.

Deleting this registry fixes an issue that we see once in a while so creating this would make things so much easier.

This is what I have but I keep getting this below. Any ideas?


$Computer = Read-Host "Please Enter Computer Name"
$Username = Read-Host "Who is the user?"
Invoke-Command -ComputerName $Computer -ScriptBlock {Remove-ItemProperty -Path 'HKLM:\Software\Microsoft\MSLicensing'} -ArgumentList $Username
Write-OutPut "RegKeys have now been successfully changed on $Computer"





cmdlet Remove-ItemProperty at command pipeline position 1
Supply values for the following parameters:
Name[0]:
 
Are you trying to get rid of that entire path or a specific key inside it?
 
Last edited:
$Computer = Read-Host "Please Enter Computer Name"
$Username = Read-Host "Who is the user?"
Invoke-Command -ComputerName $Computer -ScriptBlock {Remove-ItemProperty -Path 'HKLM:\Software\Microsoft\MSLicensing' -force -recursive} -ArgumentList $Username
Write-OutPut "RegKeys have now been successfully changed on $Computer"


Try adding these two arguments (see bold)
 
Getting this error now for some reason.

A parameter cannot be found that matches parameter name 'Recursive'.
+ CategoryInfo : InvalidArgument: :)) [Remove-ItemProperty], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RemoveItemPropertyCommand
 
You're just missing the Name parameter.
Remove-ItemProperty expects two things; the path to the property you want to delete, and the name of that property.

In your case, if you want to delete everything in the "MSLicensing" folder, just add "-Name '*'" to the argument like so:

Invoke-Command -ComputerName $Computer -ScriptBlock {Remove-ItemProperty -Path 'HKLM:\Software\Microsoft\MSLicensing' -Name '*'} -ArgumentList $Username
 
Back
Top Bottom