#180527 - 2007-09-13 02:05 PM
Reporting Group Policy applied
|
gdstiers
Fresh Scripter
Registered: 1999-08-11
Posts: 14
Loc: Chattanooga, TN, USA
|
Q: How does the logon script report Group Policies applied ? A: The following code lists GPO names, but does not interpret the date/time field (REG_DWORD, variable $poltime) - Suggestions ??
; ; Registry locations for GPO applied to WinXP
; Current User ; enumerate gpextensions to capture SID. store GPO SID in log table. all variables global. ; *** 9/12/7 1231 gds need to convert Reg_Dword to KiXtart date format. ; hkcu\software\microsoft\windows nt\currentversion\winlogon\gpextensions\[sid]\LastpolicyTime (Reg_Dword) $usersid="hkcu\software\microsoft\windows nt\currentversion\winlogon\gpextensions"
; enumerate SID - may bypass DisplayName='Local Group Policy' ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\0\DisplayName (String) ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\1\DisplayName (String) ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\2\DisplayName (String) $userdname="hkcu\software\microsoft\windows\currentversion\group policy\history"
:loop1 $keyname=enumkey("$usersid",$index1) if @error=0 $poltime=readvalue("$usersid\$keyname","LastPolicyTime") $msg="User sid ($keyname)" ? "@DATE,@TIME,$msg" :loop2 $sidname=enumkey("$userdname\$keyname",$index2) if @ERROR=0 $dname=readvalue("$userdname\$keyname\$sidname","DisplayName") $msg="User policy ($dname) was applied ($poltime)" ? "@DATE,@TIME,$msg" goto loop2 endif goto loop1 endif
; Local Machine ; enumerate gpextensions to capture SID ; hklm\software\microsoft\windows nt\currentversion\winlogon\gpextensions\[sid]\LastpolicyTime (Reg_Dword) $computersid="hklm\software\microsoft\windows nt\currentversion\winlogon\gpextensions"
; enumerate SID - may bypass DisplayName='Local Group Policy' ; hklm\software\microsoft\windows\currentversion\group policy\history\[sid]\0\DisplayName (String) ; hklm\software\microsoft\windows\currentversion\group policy\history\[sid]\1\DisplayName (String) ; hklm\software\microsoft\windows\currentversion\group policy\history\[sid]\2\DisplayName (String) $computerdname="hklm\software\microsoft\windows\currentversion\group policy\history"
[code repeats Current User]
|
|
Top
|
|
|
|
#180558 - 2007-09-13 08:07 PM
Re: Reporting Group Policy applied
[Re: NTDOC]
|
gdstiers
Fresh Scripter
Registered: 1999-08-11
Posts: 14
Loc: Chattanooga, TN, USA
|
What is a [code tag] ? The sample text was Notepad-formated until previewed and submitted to the forum. The question to the forum is how to convert a Registry REG_DWORD value to a KiXtart date.
|
|
Top
|
|
|
|
#180561 - 2007-09-13 08:12 PM
Re: Reporting Group Policy applied
[Re: gdstiers]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Please read this thread and it will help you become a better user of the board not only here but on every other board out there as well.
Thanks
The Post/Reply Formatting Box and How to use it
|
|
Top
|
|
|
|
#180566 - 2007-09-13 08:54 PM
Re: Reporting Group Policy applied
[Re: NTDOC]
|
gdstiers
Fresh Scripter
Registered: 1999-08-11
Posts: 14
Loc: Chattanooga, TN, USA
|
The [code tags] create a window in the post to view the code. Text outside the window can be formatted.
Q: How does the logon script report Group Policies applied ? A: The following code lists GPO names (REG_SZ), but does not interpret the date/time field (REG_DWORD, variable $poltime) - Suggestions ?? ; ; Registry locations for GPO applied to WinXP (Current User) ; Loop1 ; Enumerate gpextensions to capture [sid] ; hkcu\software\microsoft\windows nt\currentversion\winlogon\gpextensions\[sid]\LastpolicyTime (Reg_Dword) ; Loop2 ; Enumerate SID to capture display name ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\0\DisplayName (String) ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\1\DisplayName (String) ; hkcu\software\microsoft\windows\currentversion\group policy\history\[sid]\2\DisplayName (String)
dim $usersid, $userdname, $keyname, $index1, $index2, $msg, $err
dim $poltime, $sidname, $dname
$usersid="hkcu\software\microsoft\windows nt\currentversion\winlogon\gpextensions"
$userdname="hkcu\software\microsoft\windows\currentversion\group policy\history"
:loop1
$keyname=enumkey("$usersid",$index1)
if @error=0
$poltime=readvalue("$usersid\$keyname","LastPolicyTime")
$msg="User sid ($keyname)"
? "@DATE,@TIME,$msg"
:loop2
$sidname=enumkey("$userdname\$keyname",$index2)
if @ERROR=0
$dname=readvalue("$userdname\$keyname\$sidname","DisplayName")
$msg="User policy ($dname) was applied ($poltime)"
? "@DATE,@TIME,$msg"
goto loop2
endif
goto loop1
endif
|
|
Top
|
|
|
|
#180581 - 2007-09-13 09:53 PM
Re: Reporting Group Policy applied
[Re: Mart]
|
gdstiers
Fresh Scripter
Registered: 1999-08-11
Posts: 14
Loc: Chattanooga, TN, USA
|
Please accept my apology. I did not intend to offend anyone. The board members provide valuable assistance in the forums and UDF library that have helped me more than once. I did not understand the board formatting until practicing your suggestions and referenced link. I did not realize that the hex value, read from the Registry, that was converted to decimal, by the function in Mart's link, would still need to be converted, by some other calculations, to a date. I tried a UDF from the library, but I knew a 1904 date was missing something.
|
|
Top
|
|
|
|
#180589 - 2007-09-13 10:54 PM
Re: Reporting Group Policy applied
[Re: Mart]
|
gdstiers
Fresh Scripter
Registered: 1999-08-11
Posts: 14
Loc: Chattanooga, TN, USA
|
Mission accomplished.
Thanks everyone !!
|
|
Top
|
|
|
|
#180590 - 2007-09-13 10:57 PM
Re: Reporting Group Policy applied
[Re: gdstiers]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|