Hello,
I am trying to write some code to remove a registry value from a machine if the value exists, and I am testing with a machine that I am 100% positive contains the value. However, I keep getting the error “Property does not exist at path” - I pasted the error at the bottom of this post. I know it exists - is it possible that it is hidden or protected or something to that effect? Thanks for any assistance, here is my code, and the error below:
"OU=TPOS,OU=DEV,OU=POS,DC=Company,DC=net","OU=TPOS,OU=QA,OU=POS,DC=Company,DC=net" | ForEach-Object {Get-ADComputer -Filter "Name –like 'P0*'" -SearchBase $_ | Select-Object –ExpandProperty Name | Add-Content C:\Temp\TPOSLower.txt} Get-Content C:\Temp\TPOSLower.txt | ForEach-Object {If(Test-Connection -ComputerName $_ -Quiet) {Remove-ItemProperty -Name Transaction_Count -Path HKLM:\Software\Company\ImageInfo}}
Remove-ItemProperty : Property Transaction_Count does not exist at path
HKEY_LOCAL_MACHINE\Software\Company\ImageInfo.
At line:1 char:99
- … $_ -Quiet) {Remove-ItemProperty -Name Transaction_Count -Path HKLM:\S …
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (Transaction_Count:String) [Remove-ItemProperty], PSArgumentException
- FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.RemoveIte
mPropertyCommand