A while back we're able to edit the registry file and now it seems like we're not able to edit the reg file. We have a bunch of server's we need to change the DynamicDaylightTimeDisable from 1 oto 0.
If I'm on the remote server and run
Get-ItemProperty -Path HKLM:\system\CurrentControlSet\Control\TimeZoneInformation -Name DynamicDaylightTimeDisable
I see
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\system\CurrentControlSet\Control\
imeZoneInformation
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\system\CurrentControlSet\Control
PSChildName : TimeZoneInformation
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Bias : 360
DaylightBias : -60
DaylightName : @tzres.dll,-161
DaylightStart : {0, 0, 3, 0...}
StandardBias : 0
StandardName : @tzres.dll,-162
StandardStart : {0, 0, 11, 0...}
TimeZoneKeyName : Central Standard Time
DynamicDaylightTimeDisabled : 1
ActiveTimeBias : 300
So if I run
Set-ItemProperty -Path HKLM:\system\CurrentControlSet\Control\TimeZoneInformation -Name DynamicDaylightTimeDisabled -Value 0 -Type DWord
It will edit DynamicDaylightTimeDisabled from 1 to 0.
Any ideals why we're not able to edit the registry file remotely?
############ New script ###############
$Svrs = "apsed1516"
foreach ($computername in $Svrs){
$GetRegValue = Get-ItemProperty -Path HKLM:\system\CurrentControlSet\Control\TimeZoneInformation -Name DynamicDaylightTimeDisable
$GetRegValue
If($RegistryKeyValue -eq 1)
{
Write-Output "DynamicDaylightTimeDisable value" $GetRegValue
Set-ItemProperty -Path HKLM:\system\CurrentControlSet\Control\TimeZoneInformation -Name DynamicDaylightTimeDisabled -Value 0 -Type DWord}
Else {
Write-Output "DynamicDaylightTimeDisable value is already" $GetRegValue
}
}
############ New script ###############
############## Old script that use to work but not doesn't ###############
$Svrs = "apsed1516"
foreach ($computername in $Svrs){
$PingStatus = Gwmi Win32_PingStatus -Filter "Address = '$computername'" | Select-Object StatusCode
If ($PingStatus.StatusCode -eq 0){
$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computername )
$regKey = $reg.OpenSubKey("HKLM:\\system\\CurrentControlSet\\Control\\TimeZoneInformation\\DynamicDaylightTimeDisable,$true")
$regKey.SetValue("0",[Microsoft.Win32.RegistryValueKind]::String)
}
else {
Write-Host "$computername unreachable"
}
}
############## Old script that use to work but not doesn't ###############