Set-ItemProperty : Cannot find path
I am running PDQ deploy. I have made a new package with 1 PowerShell step. I have the PowerShell.ps1 in question located on the network share that all of the other(working) packages are also using. The script in question is working great locally, no problems when I pull the .ps1 from the file share to the local machine and run it. The purpose of the script is to change the registry key value of the path noted to '2'.
When I attempt to deploy it to a machine I get a an error noted below, which is confusing because that registry key exists, I've checked manually on the machine I'm testing.
The script in question is only one line as you can see below. The ExecutionPolicy is being bypassed and all that good stuff.
It is very likely that I'm just incorrectly using some of the cmdlets, however, I wanted to post here to use this opportunity to learn as I've had similar problems deploying .ps1 scripts in the past. I surmise that for some reason the deploy user(domain admin) account can't see the registry of the computer I'm deploying to? Any help would be appreciated.
Set-ItemProperty -Path Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -Value 2
Set-ItemProperty : Cannot find path 'HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds' because it
does not exist.
At C:\windows\AdminArsenal\PDQDeployRunner\service-1\exec\FeedKill.ps1:2 char:1
+ Set-ItemProperty -Path Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft ...
+ CategoryInfo : ObjectNotFound: (HKEY_CURRENT_US...ntVersion\Feeds:String) [Set-ItemProperty], ItemNotFo
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand
Did you mean to have 2 :'s in your path?
Another thought...since this is HKCU, are you deploying this as the Logged on User?
Thanks for the quick reply!
The '::' was just some syntax I saw online when working with registry keys. When just one is removed it throws a different error noted below. I removed 'Registry::' and was left with the same error noted above.
I just went ahead and changed the package to use Logged on User, but I was left with the same original error. Do you think the problem is that I'm trying to make changes to HKCU when there's technically no one logged onto that machine at the time of the script being ran?(besides presumably the account set up to deploy the script)
Try using HKCU and as the logged on user.
You might also try:
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -Value 2
It's like magic! That worked for me. Seems the issue was the syntax for HKCU vs HKEY_CURRENT_USER? When ran locally both solutions work for me, however, your solution works when remotely deploying. Do you know why this is the case?
Not 100% sure whether it's an OS thing or a PS version thing.
Interesting. In any case, thanks a lot for your help! I'm not sure if there's a "select answer" type thing similar to stackoverflow but I've upvoted all your answers if that helps in someway
We're all here to help each other! Glad it worked out!
Please sign in to leave a comment.