Important Notice: On February 29th, this community will be put into read-only mode. All existing posts will remain but customers will be unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Set-ItemProperty : Cannot find path

Hello All!

 

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.

Script:

Set-ItemProperty -Path Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -Value 2

Error:

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 
   undException
  + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetItemPropertyCommand
0

Comments

9 comments
Date Votes
  • Did you mean to have 2 :'s in your path?

     

    Registry::HKEY_CURRENT_USER\
    1
  • Another thought...since this is HKCU, are you deploying this as the Logged on User?

    1
  • Mike Kercher

    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.

    Set-ItemProperty : Cannot find drive. A drive with the name 'Registry' does not exist.

    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)

     

    0
  • Try using HKCU and as the logged on user.

    HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -Value 2
    1
  • You might also try:

     

    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Feeds -Name ShellFeedsTaskbarViewMode -Value 2

    1
  • 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?

    0
  • Not 100% sure whether it's an OS thing or a PS version thing.

    1
  • 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

    0
  • We're all here to help each other!  Glad it worked out!

    1

Please sign in to leave a comment.

Didn't find what you were looking for?

New post