0

I'm trying to remove and add a reg key through PS and I end up getting an error. See below. I don't know why it's causing this error.

$path1 = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'   
Remove-item -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
$path1 = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
New-item -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
New-ItemProperty -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name 'NoAutoUpdate' -Value 0 -PropertyType DWord

Error:

New-ItemProperty : Cannot use interface. The IDynamicPropertyCmdletProvider interface is not implemented by this
provider.
At line:1 char:1
+ New-ItemProperty -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\Wind ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [New-ItemProperty], PSNotSupportedException
    + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.NewItemPropertyCommand
$path1 = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'   
Remove-item -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
$path1 = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
New-item -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU
New-ItemProperty -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name 'NoAutoUpdate' -Value 0 -PropertyType DWord

Error:

New-ItemProperty : Cannot use interface. The IDynamicPropertyCmdletProvider interface is not implemented by this
provider.
At line:1 char:1
+ New-ItemProperty -Path $HKLM\SOFTWARE\Policies\Microsoft\Windows\Wind ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotImplemented: (:) [New-ItemProperty], PSNotSupportedException
    + FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.NewItemPropertyCommand
2
  • 2
    Welcome to Stack Overflow. Could you please format your code properly? Thanks in advance. Commented Jul 26, 2023 at 21:42
  • 2
    Errors are probably caused by your use of $HKLM. Why aren't you using the variable you define? New-ItemProperty -Path $path1 ... Commented Jul 26, 2023 at 21:48

1 Answer 1

1
#requires -RunAsAdministrator

$path1 = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU'
Remove-Item -Path $path1 # might want to use -Force and or -Recurse
New-Item -Path $path1
New-ItemProperty -Path $path1 -Name 'NoAutoUpdate' -Value 0

What is $HKLM in your example? The path seems constant, why not use and reuse a variable and use HKLM:

Sign up to request clarification or add additional context in comments.

2 Comments

That worked! I'm still kind of a newbie with PowerShell so I appreciate the correction. Much appreciated 👍
Ok. StackOverflow etiquette is to now mark my answer as the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.