2012-11-13 102 views
0

它在錫上說什麼。從本質上講,我想是這樣的(在PowerShell中,但是這在很大程度上無關):有沒有辦法從服務器獲取WMI.Service?

$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" 
} 
+0

究竟是什麼WMI.Service對象/類/什麼?你正在尋找[SMO服務類](http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.wmi.service.aspx)? – Pondlife

+0

這個問題已經標記爲SMO,所以是的,這是一個很好的猜測。我已經更新了代碼,使其更清晰一些。 –

回答

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 
相關問題