http://blogs.technet.com/b/heyscriptingguy/archive/2007/07/25/how-can-i-create-a-new-wmi-namespace-under-the-root-namespace.aspx?Redirected=true
http://blogs.technet.com/b/smsandmom/archive/2007/08/30/how-to-extend-your-hardware-inventory-using-the-sms-def-mof-file.aspx
http://blogs.msdn.com/b/rslaten/archive/2007/03/23/adding-custom-data-to-wmi-as-a-low-rights-user-and-having-sms-collect-that-data.aspx
wmi custom namespace/class creation/deletion via script/mof
2013年5月23日 星期四
wmi associator
1:使用WMI object browser點選要開啟的class
2:點選association tab,找出連結兩個class的associator
3:連結成功後即可query對應物件屬性
strComputer = "."
maxlen=0
Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdaptersConf = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objAdapterConf In colAdaptersConf
set ASSOobjItem = objAdapterConf.Associators_("win32_networkAdapterSetting")
For each objASSOobjItem in ASSOobjItem
Wscript.Echo objASSOobjItem.NetConnectionID & " : " & objAdapterConf.IPAddress(0)
Next
Next
2:點選association tab,找出連結兩個class的associator
3:連結成功後即可query對應物件屬性
strComputer = "."
maxlen=0
Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdaptersConf = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objAdapterConf In colAdaptersConf
set ASSOobjItem = objAdapterConf.Associators_("win32_networkAdapterSetting")
For each objASSOobjItem in ASSOobjItem
Wscript.Echo objASSOobjItem.NetConnectionID & " : " & objAdapterConf.IPAddress(0)
Next
Next
wmi event registration management
wmi registered event removal
host="."
WQL="select * from __eventfilter where Name like '%NTC%'"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\subscription")
Set colItems = objWMIService.ExecQuery(WQL)
For Each objItem in colItems
set ASSOobjItem = objItem.Associators_("__FilterToConsumerBinding")
For each objASSOobjItem in ASSOobjItem
objASSOobjItem.Delete_
Next
Wscript.Echo objItem.Delete_
Next
Event Registration
#PRAGMA AUTORECOVER
#pragma namespace("\\\\.\\root\\subscription")
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "NTC20130523001 Process Monitor";
ScriptingEngine = "VBScript";
ScriptFileName = "D:\\Q.vbs";
};
instance of __EventFilter as $EventFilter
{
EventNamespace = "Root\\Cimv2";
Name = "NTC20130523001 Process Monitor";
Query = "Select * From __InstanceCreationEvent Within 2"
"Where TargetInstance Isa \"Win32_Process\" "
"And Targetinstance.Name = \"calc.exe\" ";
QueryLanguage = "WQL";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
%windir%\system32\wbem\mofcomp.exe customize.mof
manaully do wmi event registration
1: create filter
2: create consumer
3: right click on the created filter/consumer from the right pane and pick desired object to register
REF:http://www.codeproject.com/Articles/28226/Creating-WMI-Permanent-Event-Subscriptions-Using-M
REF:http://support.microsoft.com/kb/2545227
host="."
WQL="select * from __eventfilter where Name like '%NTC%'"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\subscription")
Set colItems = objWMIService.ExecQuery(WQL)
For Each objItem in colItems
set ASSOobjItem = objItem.Associators_("__FilterToConsumerBinding")
For each objASSOobjItem in ASSOobjItem
objASSOobjItem.Delete_
Next
Wscript.Echo objItem.Delete_
Next
Event Registration
#PRAGMA AUTORECOVER
#pragma namespace("\\\\.\\root\\subscription")
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "NTC20130523001 Process Monitor";
ScriptingEngine = "VBScript";
ScriptFileName = "D:\\Q.vbs";
};
instance of __EventFilter as $EventFilter
{
EventNamespace = "Root\\Cimv2";
Name = "NTC20130523001 Process Monitor";
Query = "Select * From __InstanceCreationEvent Within 2"
"Where TargetInstance Isa \"Win32_Process\" "
"And Targetinstance.Name = \"calc.exe\" ";
QueryLanguage = "WQL";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
%windir%\system32\wbem\mofcomp.exe customize.mof
manaully do wmi event registration
1: create filter
2: create consumer
3: right click on the created filter/consumer from the right pane and pick desired object to register
REF:http://www.codeproject.com/Articles/28226/Creating-WMI-Permanent-Event-Subscriptions-Using-M
REF:http://support.microsoft.com/kb/2545227
2013年4月19日 星期五
dot net tips
C:\Windows\Microsoft.NET\Framework\\
web.config segment encryption
aspnet_regiis -pef ConfigurationStrings webPath -prov "RsaProtectedConfigurationProvider|DataProtectionConfigurationProvider "
hide your source code with aspnet_compiler.exe
web.config segment encryption
aspnet_regiis -pef ConfigurationStrings webPath -prov "RsaProtectedConfigurationProvider|DataProtectionConfigurationProvider "
hide your source code with aspnet_compiler.exe
2013年4月11日 星期四
wmi win32: rpc unavailable
1: make sure the machine is turned on
2: make sure you can successfully establish the IPC connection with the target machine
3: check firewall setup. RemoteAdmin need to be enabled.
by command
netsh firewall set service RemoteAdmin
netsh firewall add portopening protocol=tcp port=135 name=DCOM_TCP135
by GPO
Windows Firewall: Allow remote administration exception
4: verify firewall setup
netsh firewall show state
2: make sure you can successfully establish the IPC connection with the target machine
3: check firewall setup. RemoteAdmin need to be enabled.
by command
netsh firewall set service RemoteAdmin
netsh firewall add portopening protocol=tcp port=135 name=DCOM_TCP135
by GPO
Windows Firewall: Allow remote administration exception
4: verify firewall setup
netsh firewall show state
2013年4月9日 星期二
2013年2月22日 星期五
netbios alias
1:
2: reboot server
netbios debug tips: nbtstat -RR / -c
netbios diag tool: browstat
Please note, the target netbios name should match the dns a record or should not exist in dns zone. otherwise, system will always prompt authentication error with error code 1396 when issuing net use command.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
Add a new Multi-String value called OptionalNames.
Enter one or more aliases, one per line.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
Add a new DWORD value called DisableStrictNameChecking
and set to 1.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
Add a new DWORD value called DisableLoopBackCheck and set to 1.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Add a new Multi-String Value BackConnectionHostNames.
Enter one or more aliases, one per line.
2: reboot server
netbios debug tips: nbtstat -RR / -c
netbios diag tool: browstat
Please note, the target netbios name should match the dns a record or should not exist in dns zone. otherwise, system will always prompt authentication error with error code 1396 when issuing net use command.
訂閱:
文章 (Atom)