New-ItemProperty creates string instead of DWord when run via GPO


the code below works expected when run via elevated cli, creating appropriate dword entry if necessary, or changing value 1.

the same code works when run via login or startup gpo, except creates string value instead of dword value.

i stumped. in advance can provide here.

 

  $revision = 3 #working  ## initialize event logging  $eventlog = new-object system.diagnostics.eventlog('application')  $eventlog.machinename = "."  $eventlog.source = "script"    ## send start message event log  $eventlog.writeentry("[enablelinkedconnections][1]" + "registry editing has begun!")    # create new 32-bit dword key\value if don't exist  if ($(test-path hklm:\software\microsoft\windows\currentversion\policies\system\enablelinkedconnections) -eq "false")  	{  	  new-itemproperty "hklm:\software\microsoft\windows\currentversion\policies\system" -name "enablelinkedconnections" -value 1 -propertytype "dword"  	  $eventlog.writeentry("[enablelinkedconnections][2]" + "enablelinkedconnections not found , created.")    }  else    {      # set value if exist      set-itemproperty "hklm:\software\microsoft\windows\currentversion\policies\system" -name "enablelinkedconnections" -value 1    }  $eventlog.writeentry("[enablelinkedconnections][3]" + "registry editing has finished. bam!")  

replace:

 

if ($(test-path hklm:\software\microsoft\windows\currentversion\policies\system\enablelinkedconnections) -eq "false")   if (!(test-path hklm:\software\microsoft\windows\currentversion\policies\system\enablelinkedconnections))  or change "false" $false,because condition of comparison false , run set-itemproperty

 





Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2