#204021 - 2012-01-06 08:53 PM
Re: Bug in @producttype Win2K8
[Re: Allen]
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
Maybe not a bug, but a loss of functionality now exists in the @PRODUCTTYPE macro for Windows 2008 platforms.
In all prior versions of the Windows OS, the PRODUCTTYPE macro differentiated between Servers and Domain Controllers. That allowed something likeIf Instr(@PRODUCTTYPE, 'Server') Or Instr(@PRODUCTTYPE, 'Controller')
$IsServer = 1
If Instr(@PRODUCTTYPE, 'Controller')
$IsDC = 1
EndIf
EndIf to set flags for Server and DC roles.
On Windows 2008, the Domain Controller is no longer listed as a separate product type. All DCs and servers are now simply listed as "Server" (yes, there are several classes of "Windows Server 2008...", but none list "Domain Controller".
There are WMI methods to determine DC roles, but it's now extra code. It would be nice to have this functionality extended to the Windows 2008 descriptions.
Alternately, a DOMAINROLE macro that returned the same values as the WMI DomainRole values would be a nice addition: Value Hex value DomainRole 0 0x0 Standalone Workstation 1 0x1 Member Workstation 2 0c2 Standalone Server 3 0x3 Member Server 4 0x4 Backup Domain Controller 5 0x5 Primary Domain Controller
OK - I'm done whining...
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#204090 - 2012-01-19 06:43 PM
Re: Bug in @producttype Win2K8
[Re: NTDOC]
|
Lee Wilmott
Starting to like KiXtart
Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
|
I made the same comment to Ruud a year or two ago; saying that scripts could no longer identify a Domain Controller. He accepted that fact.
In light of this, I implemented the following script...
Function IsDC()
Dim $objWMIService, $colItems, $objItem
Dim $Counter
;Assume it is not a Domain Controller
$IsDC = 0
Select
Case InStr(@PRODUCTTYPE, "Windows Server 2008") <> 0
$objWMIService = GetObject( "winmgmts://./root/CIMV2" )
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_ServerFeature where ID='10'", "WQL", 48 )
$Counter = 0
For Each $objItem In $colItems
$Counter = $Counter + 1
Next
If $Counter <> 0
$IsDC = 1
EndIf
Case 1
If InStr(@PRODUCTTYPE, "Domain Controller") <> 0
$IsDC = 1
EndIf
EndSelect
EndFunction
In all honesty, I believe this script can be slimmed down a little, but it works!
It's also not too clever in that a new operating system may require this function to be updated...but you get my drift.
Lee
|
Top
|
|
|
|
#204091 - 2012-01-19 06:44 PM
Re: Bug in @producttype Win2K8
[Re: Lee Wilmott]
|
Lee Wilmott
Starting to like KiXtart
Registered: 2002-09-17
Posts: 106
Loc: Bristol, UK
|
PS...while it may seem minor, I do agree that if a trailing space exists, it ought to be removed.
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 507 anonymous users online.
|
|
|