Presentation is loading. Please wait.

Presentation is loading. Please wait.

ADM 331 Administrative Scripting for IIS 6.0 Using WMI Alexis Eller Program Manager Internet Information Services (IIS)

Similar presentations


Presentation on theme: "ADM 331 Administrative Scripting for IIS 6.0 Using WMI Alexis Eller Program Manager Internet Information Services (IIS)"— Presentation transcript:

1 ADM 331 Administrative Scripting for IIS 6.0 Using WMI Alexis Eller Program Manager Internet Information Services (IIS)

2 Agenda Overview of the Windows Script Host Manageability improvements in IIS 6.0 Overview of Windows Management Instrumentation IIS 6.0 WMI Provider Practical examples Special notes regarding JScript & WMI

3 Overview of the Windows Script Host Automation Provisioning Custom tools Rich object model Access to automation COM objects

4 Manageability Improvements in IIS 6.0 Metabase stored in XML Editable while the server is running Automatic versioning and history Password protected backups Import & Export Command line administration Remote administration IIS WMI Provider

5 The XML Metabase demo demo

6 Command line Administration for IIS 6.0 Use the IIS WMI provider Supplied VBScript scripts manage Common web and FTP tasks Use from command line, batch jobs Serve as IIS WMI scripting examples ADSI provider still supported Create scripts using the IIS providers

7 Playing with the command line scripts demo demo

8 In the System32 Directory Web: iisweb.vbs, iisvdir.vbs FTP: iisftp.vbs, iisftpdr.vbs Metabase backup/restore: iisback.vbs Import/export: iiscnfg.vbs Application extensions, dependencies, files: iisext.vbs Mapping between worker process and application pool: iisapp.vbs

9 WMI Overview Introduced in Windows 2000 Uses the object oriented model Universal way to access machine information Consistent, unified view of managed objects Supports SQL-like queries (WQL)

10 Using CIM Studio (from WMI Tools) demo demo

11 IIS 6.0 WMI Provider Extends WMI schema to include IIS classes Represents the IIS metabase Equivalent ADSI classes and more… Class/Instance provider Method provider IIS Namespace: root\MicrosoftIISv2

12 IIS 6.0 WMI Provider Each IIS object available through WMI IIsWebServer, IIsFtpServer, etc. Similar to ADSI IIS classes Separates read-only from read-write properties IIsWebServer vs. IIsWebServerSetting Association classes represent relationships

13 IIS 6.0 WMI Provider New classes to represent structured data ServerBinding, SecureBinding ScriptMap, MimeMap ApplicationDependency, WebSvcExtRestrictionList HttpError, HttpCustomHeader, CustomErrorDescription

14 Browsing through IIS WMI Classes using CIM Studio: classes, instances and properties demo demo

15 How the command line scripts work: going inside iisweb.vbs demo demo

16 Going Deeper Monitoring Using notification queries Security Audit Look for properties set with suspicious values Bulk operations Multiple operations

17 Monitoring: keeping an eye on that application pool demo demo

18 Security: Looking for sites with WRITE access enabled demo demo

19 Friendly name to site ID translation demo demo

20 Bulk changes: Disabling a web service extension on multiple machines demo demo

21 Working across WMI namespaces demo demo

22 Scripting WMI Using JScript Method Output Parameters VBScript: Methods can be called directly JScript: Methods are called with the SWbemMethod, InParam and OutParam objects. SWbemMethod WMI Arrays VBScript: handle as usual JScript: use the toArray() function to convert the WMI safearray to an array recognized by the JScript engine

23 Methods with OutParameters vdirPath = WScript.Arguments( 0 ) Set win32svc = GetObject( "winmgmts:/root/CIMv2" ) Set iissvc = GetObject( "winmgmts:/root/MicrosoftIISv2" ) Set vdir = iissvc.Get( "IIsWebVirtualDirSetting='" & vdirPath & "'" ) Set obj = win32svc.Get( "Win32_LogicalFileSecuritySetting='" & vdir.Path & "'" ) result = obj.GetSecurityDescriptor( sd ) WScript.Echo "Result: " & result WScript.Echo sd.GetObjectText_ var vdirPath = WScript.Arguments( 0 ); var win32svc = GetObject( "winmgmts:/root/CIMv2" ); var iissvc = GetObject( "winmgmts:/root/MicrosoftIISv2" ); var vdir = iissvc.Get( "IIsWebVirtualDirSetting='" + vdirPath + "'" ); var obj = win32svc.Get( "Win32_LogicalFileSecuritySetting='" + vdir.Path + "'" ); var result = obj.ExecMethod_("GetSecurityDescriptor"); WScript.Echo("Result: " + result.ReturnValue); WScript.Echo( result.Descriptor.GetObjectText_() ); VBScript – perm.vbs JScript – perm.js (includes a helper function for displaying object properties) Direct Call Call using ExecMethod_

24 Handling WMI Arrays in JScript set wmi = GetObject("winmgmts:/root/MicrosoftIISv2") set site = wmi.Get(“IIsWebServerSetting='w3svc/1'") for each binding in site.ServerBindings WScript.Echo "IP: " & binding.IP WScript.Echo "Port: " & binding.Port WScript.Echo "Hostname: " & binding.Hostname WScript.Echo next var wmi = GetObject( "winmgmts:/root/MicrosoftIISv2" ); var site = wmi.Get("IIsWebServerSetting='w3svc/1'"); var bindings = site.ServerBindings.toArray() ; for ( i = 0; i < bindings.length; i++ ) { WScript.Echo("IP: " + bindings[i].IP); WScript.Echo("Hostname: " + bindings[i].Hostname); WScript.Echo("Port: " + bindings[i].Port); } VBScript – enumerateBindings.vbs JScript – enumerateBindings.js

25 Call To Action Consider Scripting Leverage IIS WMI provider advantages Unified object model Querying capabilities Monitoring capabilities Review IIS 6.0 command line scripts Use them Learn from them

26 Ask The Experts Get Your Questions Answered I will be available in the “Ask The Experts” area after this presentation from 11:30 – 13:00

27 Community Resources IIS Community Portal http://www.microsoft.com/windowsserver2003/community/ce nters/iis/ IIS Portal http://www.microsoft.com/iis IIS Newsgroups Microsoft.public.inetserver.iis Microsoft.public.inetserver.iis.ftp Microsoft.public.inetserver.iis.security Third-party sites: http://iisanswers.com http://iisfaq.com

28 Suggested Reading & Resources Using WMI to Manage IIS http://msdn.microsoft.com/library/en- us/iisref/htm/prog_wmi_using.asp http://msdn.microsoft.com/library/en- us/iisref/htm/prog_wmi_using.asp WMI Downloads – WMI Tools http://msdn.microsoft.com/downloads/list/wmi.asp http://msdn.microsoft.com/downloads/list/wmi.asp Writing WMI Scripts in JScript – describes how this is different from using VBScript http://msdn.microsoft.com/library/default.asp?url=/library /en-us/wmisdk/wmi/writing_wmi_scripts_in_jscript.asp http://msdn.microsoft.com/library/default.asp?url=/library /en-us/wmisdk/wmi/writing_wmi_scripts_in_jscript.asp Enumerating WMI Namespaces (ie. What other WMI providers exist?) http://www.microsoft.com/technet/treeview/default.asp? url=/technet/scriptcenter/scrguide/sas_wmi_khjg.asp http://www.microsoft.com/technet/treeview/default.asp? url=/technet/scriptcenter/scrguide/sas_wmi_khjg.asp

29 Additional IIS Resources IIS 6.0 Deployment Guides: Medium to Large Organizations http://www.microsoft.com/downloads/details.aspx?f amilyid=f31a5fd5-03db-46d2-9f34- 596edd039eb9&displaylang=en http://www.microsoft.com/downloads/details.aspx?f amilyid=f31a5fd5-03db-46d2-9f34- 596edd039eb9&displaylang=en Small Organizations http://download.microsoft.com/download/d/a/7/da7 67448-6875-489c-96e6- 2003e036de6d/06NT4IIS.doc http://download.microsoft.com/download/d/a/7/da7 67448-6875-489c-96e6- 2003e036de6d/06NT4IIS.doc IIS 6.0 Resource Kit Tools http://www.microsoft.com/downloads/details.asp x?FamilyID=56fc92ee-a71a-4c73-b628- ade629c89499&DisplayLang=en http://www.microsoft.com/downloads/details.asp x?FamilyID=56fc92ee-a71a-4c73-b628- ade629c89499&DisplayLang=en

30 evaluations evaluations

31 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt "ADM 331 Administrative Scripting for IIS 6.0 Using WMI Alexis Eller Program Manager Internet Information Services (IIS)"

Similar presentations


Ads by Google