0

On a few systems I have GetDwordValue return duplicate values (.uvalue) The commands are

$reg=Get-WmiObject -List -Namespace root\default -ComputerName $ip.ipaddress | Where-Object {$_.Name -eq "StdRegProv"}
$reg.GetDwordValue($HKLM,"System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server","enabled").uvalue

It returns the values

1
1

If I run this without the .uvalue it gives me this output below and I know were it gets the 1 1 duplicates, just not why.

$reg.GetDwordValue($HKLM,"System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server","enabled")
__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     : 
__DYNASTY        : __PARAMETERS
__RELPATH        : 
__PROPERTY_COUNT : 2
__DERIVATION     : {}
__SERVER         : 
__NAMESPACE      : 
__PATH           : 
ReturnValue      : 0
uValue           : 1
PSComputerName   : 

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     : 
__DYNASTY        : __PARAMETERS
__RELPATH        : 
__PROPERTY_COUNT : 2
__DERIVATION     : {}
__SERVER         : 
__NAMESPACE      : 
__PATH           : 
ReturnValue      : 0
uValue           : 1
PSComputerName   : 

This happens to about 3 of our servers and cannot figure out why or how to return one value only.

Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26
CWL
  • 107
  • 2
  • 12

1 Answers1

0

There is no information where the $ip object comes from… If its type is an array (or any kind of a list, e.g. Object[]), then the code snippet contradict neither the Get-WmiObject cmdlet syntax (-ComputerName <String[]>), nor the GetDWORDValue method of the StdRegProv class.

Proof:

$HKLM = 2147483650
$ip = @( @{ ipaddress = $env:COMPUTERNAME }, 
         @{ ipaddress = $env:COMPUTERNAME } )
$ip.ipaddress.GetType().Name                   #  Object[]
$reg=Get-WmiObject -List -Namespace root\default -ComputerName $ip.ipaddress | Where-Object {$_.Name -eq "StdRegProv"}
$reg.GetDwordValue( $HKLM,"System\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\SSL 2.0\Server","enabled").uvalue

Output:

D:\PShell\SF\969516.ps1
Object[]
0
0
JosefZ
  • 1,564
  • 1
  • 10
  • 18
  • $ip comes from a DNS lookup of a computer name. $ip= Resolve-DnsName $computer1 -server $DNS_SERVER. I pull a list of Server from AD and use the ip address. On 1497 it returns 1 value, but 3 servers return 2. Strange and different OS's – CWL Jun 05 '19 at 13:40
  • @CWL `Resolve-DnsName` could return `IPv6` along with `IPv4`? – JosefZ Jun 05 '19 at 19:38
  • You are on the right track. It was not IPv6 as that is not set, but DNS has two ip addresses for the same server name. At least I can code for that now. Great help leading to the solution – CWL Jun 11 '19 at 13:55