有没有办法从服务器获取WMI.Service?

时间:2012-11-13 21:40:27

标签: sql-server smo

它在锡上说的是什么。从本质上讲,我想要这样的东西(在powershell中,但这在很大程度上是不相关的):

$server = new-object "Microsoft.SqlServer.Management.Smo.Server" "my\instance"
$service = $server.somePropertyOrMethod
if ($service.getType().FullName -eq 'Microsoft.SqlServer.Management.Smo.Wmi.Service') {
   write-output "you've found what I'm looking for"
}

1 个答案:

答案 0 :(得分:0)

寻找类似的东西?

XP_WMIV3_DLL is a Extended Sqlserver Procedure for Quering WMI.
This package includes versions for 32-bit and 64-bit SQL servers.

Currently tested under SQL-Server 2005 and SQL-Server 2008.

download: http://bummisoft.de/download/XP_WMI.zip


Installation:

EXEC sp_addextendedproc xp_wmiv3, '<Your Path>\XP_WMIV3_DLL.dll'

eg:  EXEC sp_addextendedproc xp_wmiv3, 'C:\DLLs\XP_WMIV3_DLL.dll'

Uninstallation

EXEC sp_dropextendedproc xp_wmiv3


Usage 

e.g. 

exec xp_wmiv3 'SELECT * FROM Win32_Volume'
exec xp_wmiv3 'SELECT * FROM CIM_Userdevice where Name like "%HID%"'
exec dbo.xp_wmiv3 'Select * from win32_perfformatteddata_perfproc_process where name=''sqlservr'''



Create table #tmp(Domain varchar(255),Name varchar(255),Sid varchar(255))
insert into #tmp Exec xp_wmiV2 'SELECT  Domain,SID,Name FROM Win32_UserAccount  where Status ="OK"'
Select * from #tmp
Drop Table #tmp



Be aware that some querys my last very long, some won't return at last.

Covered namespaces in this version depend on local  - root\CIMV2