을 얻는 방법 IIS 응용 프로그램을 통해 정보 WMI
문제
어떻게 얻을 실제 디렉토리 경로의 IIS 응용 프로그램(가상 폴더)을 이용하여 WMI?
해결책
사용 스 성경 V2 더 많은 샘플을 볼 수있는 도구 :
On Error Resume Nextconst wbemflagreturnimmed sevide = & h10 const wbemflagforwardonly = & h20
Arrcomputers = array ( "*")는 Arrcomputers의 각 strcomputer wscript.echo wscript.echo "====================================================================== = 일반 ================== "
set objwmiservice = getObject ( "winmgmts : "& strcomputer & " root microsoftiisv2") set colitems = objwmiservice.execquery ( "select * from iiswebvirtualdir_iiswebvirtdir", "wbemffertory"
colitems wscript.echo "groupcomponent :"& objitem.groupcomponent wscript.echo "partcomponent :"& objitem.partcomponent.echo 다음에 다음에 다음에 objitem에 대해
다른 팁
확실히,그것은 3 년 동안 오래 된,그러나 그것은 좋은 질문입니다.이 사양의 솔루션을 사용해야 합.순이 포함되어 있 PowerShell,다음이 될 것이다.누군가가 알고 싶을 수도 있습니다 일부는 일:
$server = 'ServerName'
$query = "Select Path From IIsWebVirtualDirSetting WHERE Name = 'W3SVC/1/ROOT'"
Get-WmiObject -namespace "root/microsoftiisv2" -query $query -computername $server -authentication 6
그 결과 개체 중 하나를 포함 시라,"Path".
Isalamon의 답변과 동일한 결과를 반환 해야하는 순전히 .NET 옵션이 있습니다.
샘플 사용법 (교체 strComputer
)
Macros.WmiMacros.QueryWmiAdvanced (Macros.WmiMacros.ScopeItem.Creation("\\\\strComputer\\root\\MicrosoftIISv2", true,true)) "SELECT * FROM IIsWebVirtualDir_IIsWebVirtualDir"
|> Seq.map (fun e-> e.Properties.["GroupComponent"].Value, e.Properties.["PartComponent"].Value)
훨씬 더 자세한 사용 :
let webServerSettings =
Macros.WmiMacros.QueryWmiAdvanced (Macros.WmiMacros.ScopeItem.Creation("\\\\strComputer\\root\\MicrosoftIISv2", true,true)) "SELECT Name,ServerComment FROM IIsWebServerSetting"
|> Seq.map (fun e -> e.Properties.["Name"].Value,e.Properties.["ServerComment"].Value)
let webVirtualDirs =
Macros.WmiMacros.QueryWmiAdvanced (Macros.WmiMacros.ScopeItem.Creation("\\\\strComputer\\root\\MicrosoftIISv2", true,true)) "SELECT AppRoot,Name FROM IIsWebVirtualDir"
|> Seq.map (fun e -> e.Properties.["Name"].Value,e.Properties.["AppRoot"].Value)
let webVirtualDirSettings =
Macros.WmiMacros.QueryWmiAdvanced (Macros.WmiMacros.ScopeItem.Creation("\\\\strComputer\\root\\MicrosoftIISv2", true,true)) "SELECT Name,Path,AppPoolId FROM IIsWebVirtualDirSetting"
|> Seq.map (fun e -> e.Properties.["Name"].Value,e.Properties.["Path"].Value,e.Properties.["AppPoolId"].Value)
// webServerSettings.Dump("ss");
// webVirtualDirs.Dump("vd");
query {
for name,sc in webServerSettings do
join (vname,appRoot) in webVirtualDirs on ((name.ToString() + "/ROOT") = vname.ToString())
join (sname,path,appPoolId) in webVirtualDirSettings on (name.ToString()+ "/ROOT" = sname.ToString() )
select (appRoot,name,sc,path,appPoolId)
}
자세한 구현 코드 :
type ScopeItem =
| Scope of ManagementScope
| Creation of string*bool*bool
let private createAdvancedScope (path:string) requiresDomainSecurity requiresPacketSecurity =
let scope =
if requiresDomainSecurity then
let conn = ConnectionOptions(Authority=sprintf "ntlmdomain:%s" Environment.UserDomainName)
ManagementScope(path, conn)
else
ManagementScope(path, null)
if requiresPacketSecurity then scope.Options.Authentication <- AuthenticationLevel.PacketPrivacy
scope.Connect()
scope
let QueryWmiAdvanced (scopeInput: ScopeItem) query =
let scope =
match scopeInput with
| Scope s -> s
| Creation (path, requiresDomainSecurity, requiresPacketSecurity) -> createAdvancedScope path requiresDomainSecurity requiresPacketSecurity
// createAdvancedScope path requiresDomainSecurity requiresPacketSecurity
let query = new ObjectQuery(query)
use searcher = new ManagementObjectSearcher(scope, query)
use results = searcher.Get()
results |> Seq.cast<ManagementObject> |> Array.ofSeq