This may be something so easy but I cannot figure out why its not working. See below:
$regPath = "HKLM:\SOFTWARE\Microsoft\Enrollments\" + $idString
$regPath
Invoke-Command -ComputerName $ComputerName {Remove-Item -Path $regPath -Force -Verbose}
I am essentially trying to remove a registry entry under a particular path. When I output $regPath
and copy & paste it manually into the path parameter, it accepts it and runs as normal. Despite this, when I want to provide the variable with the same path, it produces the error in the title - appears to be null. I have checked the documentation and it says -path
is a String...which the information I am providing is. I'm really not sure why it is not accepting it.