2013年6月27日 星期四

wmi event monitoring

"select * from __InstanceOperationEvent within 1 where TargetInstance ISA 'Win32_PnPEntity' and TargetInstance.Description='USB Mass Storage Device'"


__InstanceOperationEvent
-->__InstanceCreationEvent
-->__InstanceDeletionEvent
-->__InstanceModificationEvent

2013年6月19日 星期三

ADSI query string

  Set conn = CreateObject("ADODB.Connection")
  conn.Provider = "ADSDSOObject"
  conn.Open "ADs Provider"

DomainFQDN= kido.idv.tw
DomainContainer="DC=kido,DC=idv,DC=tw"
  query_str="(&(objectCategory=person)(objectClass=user)(&(sAMAccountName=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2))))"
  ldapStr = ";" & query_str & ";adspath;subtree"
 Set rs = conn.Execute(ldapStr)

 Set objConn = CreateObject("ADODB.Connection")
 Set objRs = CreateObject("ADODB.Recordset")
 objConn.Provider = "ADsDSOObject"
 strConn = "Active Directory Provider"
 objConn.Open strConn
 strSql = "select mail from '" & DomainFQDN & "' where sAMAccountName='" & "kido" & "'"
 objRs.Open strSql, objConn, 1, 1

2013年6月17日 星期一

configure option for static binary

CFLAGS=-m32 LDFLAGS=-static

2013年6月12日 星期三

list trusted domain info

Dim objConnection, objRootDSE, objRecordSet
Dim strFilter
strFilter = "(NETBIOSName=*)"
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objRootDSE = GetObject("LDAP://RootDSE")
Wscript.Echo objRootDSE.Get("configurationNamingContext")
Set objRecordSet = objConnection.Execute( _ 
";" & _ 
strFilter & ";" & "NETBIOSName,dnsroot,ncname;subtree")
Set objRootDSE = Nothing
While Not objRecordSet.EOF 
WScript.Echo "NETBIOSName:" & objRecordSet.Fields("netbiosname").Value & vbTab _
             & "DNSRoot:" & join(objRecordSet.Fields("dnsroot").Value) & vbTab _
             & "CName:" & objRecordSet.Fields("ncname").Value
objRecordSet.MoveNext
WEnd

2013年6月11日 星期二

freebsd partition size expansion

1:vmdk resize --> either through command line or GUI
command line: vmkfstool -X finalsize vmdk_file

2:download lastest freebsd boot only iso file and then boot the system up from CD-ROM

3: start space expansion, if you'd like to specify space to partition, -s option is required, otherwise all free space will be assigned to target partition.
gpart show <-- info="" p="" partition="" show="">gpart resize -i 1 /dev/da0 <-- assign="" br="" free="" partition="" primary="" space="" to="">gpart resize -i 6 /dev/da0s1 <-- br="" da0s1f="" dev="" give="" space="" to="">growfs /dev/da0s1f <-- level="" os="" p="">

2013年6月7日 星期五

script to update local gpo

c:\Windows\System32\GroupPolicy\gpt.ini
c:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini

1: add 1 to version parameter in c:\Windows\System32\GroupPolicy\gpt.ini
2: append [{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}] to gPCMachineExtensionNames in c:\Windows\System32\GroupPolicy\gpt.ini

3:add following to c:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini
[Startup]
0CmdLine=1233kido.vbs
0Parameters=
[Shutdown]
0CmdLine=C:\Windows\System32\GroupPolicy\Machine\Scripts\Startup\1233kido.vbs
0Parameters=

2013年6月3日 星期一

enable remoteRegistry

sc config remoteregistry start= auto