title: Powershell to add reg key
body: <p>I have a Powershell script that "builds" a PC from the basic Windows operating system on up (Windows 7 Pro - will be converted to 10 next year).  I have a number of reg keys that get added when running this script and they all work fine, no problems.  </p>
  
  <p>I am having to add a new reg key which turns off Remote Desktop Services.  I can do it at the cmd line with </p>
  
  <p><code>reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f</code></p>
  
  <p>which works fine and dandy.  So now I need to add this same key via a Powershell script and I can't get it to work.  What I have is </p>
  
  <p><code>New-Item -Path 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 1 | Out-File $log -append</code></p>
  
  <p>and when I run that, something pops up that reads</p>
  
  <p><code>Type:</code></p>
  
  <p>So I assumed it is asking for a type.  But if I add PropertyType as below </p>
  
  <p><code>New-Item -Path 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -PropertyType DWORD -Value 1 | Out-File $log -append</code></p>
  
  <p>it gives an error.  I've researched at several forums online and nothing seems to work.  Any ideas?</p>