I need help to create a PowerShell script that will check for registry key only (not value) and will add registry key in case of absence of Registry key in the computer.
I've been able to add the tag using the script
reg add "HKLM\SOFTWARE\WOW6432Node\Tanium\Tanium Client\Sensor Data\Tags" /v Test
But when trying to search the key using
Test-Path 'HKLM:\SOFTWARE\WOW6432Node\Tanium\Tanium Client\Sensor Data\Tags\Test'
It is showing False. No values need to be assigned to the key 'Test'. Just need a script that will return the value if the 'Test' tag has been created or not. If not, will be able to execute the script.
The below script is not capturing existence of the key 'Test'
$x =Get-ChildItem -Path 'HKLM:\SOFTWARE\WOW6432Node\Tanium\Tanium Client\Sensor Data\Tags'
if($x -eq "Test") {
write-host("Key is There")
}
Else {
reg add "HKLM\SOFTWARE\WOW6432Node\Tanium\Tanium Client\Sensor Data\Tags" /v Test
}
Need help to get the correct checking criteria.

$xis not a string...