The Portable Script Center Versi

The Portable Script Center
Version 3.0, November 2004

This help file contains all the scripts found in the TechNet Script Center (http://www.microsoft.com/technet/scriptcenter) as of November 5, 2004. Most of the scripts are designed to run with either Windows 2000, Windows XP, or Windows Server 2003, although many will also run on Windows NT 4.0 or Windows 98; in the latter two cases, however, you might need to install additional scripting technologies such as ADSI or WMI before the scripts will work. For more information about obtaining and installing ADSI, WMI, and the latest version of Windows Script Host (WSH 5.6), see the Script Center’s Scripting FAQ.

To help you identify which scripts will work with your computers, each script is accompanied by a table similar to this:

Supported Platforms

Windows Server 2003

Yes

Windows XP

Yes

Windows 2000

Yes

Windows NT 4.0

Yes, with Active Directory Client Extensions installed

Windows 98

Yes, with Active Directory Client Extensions installed

To use the scripts, copy the appropriate script code, paste the code into Notepad or another text editor, and save the file with a .vbs file extension. You can then run the script either by double-clicking the icon in Windows Explorer or by typing cscript at the command-line followed by the script name (this is generally preferred method of running the scripts). For example, to run the script my_script.vbs, type the following:

cscript my_script.vbs

For more information about these scripts, contact the Microsoft Scripting Guys at scripter@microsoft.com. If you would like to keep informed of the latest additions to the Script Center, receive beta copies of scripting utilities, and otherwise keep up-to-date on what’s going on in the world of scripting, subscribe to the Scripting Newswire. To subscribe to this free service (which is nothing more than periodic emails sent by the Scripitng Guys), send mail to scripter@microsoft.com, with the subject line Subscribe.

If you are interested in learning more about these scripts and how they work, check out the Microsoft Windows 2000 Scripting Guide. Many (but by no means all) of these scripts are featured in the Scripting Guide, along with a step-by-step explanation of what they do, how they work, and how they can be modified to better fit your individual needs. The Scripting Guide also provides a good introduction to basic scripting technologies such as WSH, VBScript, WMI, and ADSI.

A Note About the WMI Scripts

Most of the WMI scripts in this repository create a variable named strComputer, and then set the value of that variable to "." Thus, the scripts generally include this line:

strComputer = "."

This causes the script to run against the local computer. This is due to the way that the script has been composed, and the fact that WMI views a computer named "." as being the local computer. If you want to run the script against a remote computer, simply replace the "." with the name of the remote computer, surrounded by double quotation marks. For example, this line of code runs the script against a remote computer named PrintServer1:

strComputer = "PrintServer1"

This is the only change you need to make in order to run the WMI scripts against a remote computer. Bear in mind, however, that you will need to have administrative rights on the remote computer in order for the script to succeed. In addition, WMI must be installed both on the local computer and on the remote computer.


Copy an Active Directory Computer Account

Description
Retrieves the attributes of an existing computer object and copies the attributes to a new computer object created by the script.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objCompt = _
    GetObject("LDAP://cn=Computers,dc=NA,dc=fabrikam,dc=com")
Set objComptCopy = objCompt.Create("computer", "cn=SEA-SQL-01")
objComptCopy.Put "sAMAccountName", "sea-sql-01"
objComptCopy.SetInfo

Set objComptTemplate = GetObject _
    ("LDAP://cn=SEA-PM-01,cn=Computers,dc=NA,dc=fabrikam,dc=com")
arrAttributes = Array("description", "location")

For Each strAttrib in arrAttributes
    strValue = objComptTemplate.Get(strAttrib)
    objComptCopy.Put strAttrib, strValue
Next

objComptCopy.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Computer Account For a Specific User

Description
Creates and enables a computer account in Active Directory. A specific, authenticated user can then use this account to add his or her workstation to the domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-pro-002"
strComputerUser = "fabrikam\lewjudy"

Const ADS_UF_PASSWD_NOTREQD = &h0020
Const ADS_UF_WORKSTATION_TRUST_ACCOUNT = &h1000
Const ADS_ACETYPE_ACCESS_ALLOWED = &h0
Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &h5
Const ADS_FLAG_OBJECT_TYPE_PRESENT = &h1
Const ADS_RIGHT_GENERIC_READ = &h80000000
Const ADS_RIGHT_DS_SELF = &h8
Const ADS_RIGHT_DS_WRITE_PROP = &h20
Const ADS_RIGHT_DS_CONTROL_ACCESS = &h100

Const ALLOWED_TO_AUTHENTICATE = _
    "{68B1D179-0D15-4d4f-AB71-46152E79A7BC}"
Const RECEIVE_AS = "{AB721A56-1E2f-11D0-9819-00AA0040529B}"
Const SEND_AS = "{AB721A54-1E2f-11D0-9819-00AA0040529B}"
Const USER_CHANGE_PASSWORD = _
    "{AB721A53-1E2f-11D0-9819-00AA0040529b}"
Const USER_FORCE_CHANGE_PASSWORD = _
    "{00299570-246D-11D0-A768-00AA006E0529}"
Const USER_ACCOUNT_RESTRICTIONS = _
    "{4C164200-20C0-11D0-A768-00AA006E0529}"
Const VALIDATED_DNS_HOST_NAME = _
    "{72E39547-7B18-11D1-ADEF-00C04FD8D5CD}"
Const VALIDATED_SPN = "{F3A64788-5306-11D1-A9C5-0000F80367C1}"

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Computers," & _
    objRootDSE.Get("defaultNamingContext"))

Set objComputer = objContainer.Create _
    ("Computer", "cn=" & strComputer)
objComputer.Put "sAMAccountName", strComputer & "$"
objComputer.Put "userAccountControl", _
    ADS_UF_PASSWD_NOTREQD Or ADS_UF_WORKSTATION_TRUST_ACCOUNT
objComputer.SetInfo

Set objSecurityDescriptor = objComputer.Get("ntSecurityDescriptor")
Set objDACL = objSecurityDescriptor.DiscretionaryAcl

Set objACE1 = CreateObject("AccessControlEntry")
objACE1.Trustee    = strComputerUser
objACE1.AccessMask = ADS_RIGHT_GENERIC_READ
objACE1.AceFlags   = 0
objACE1.AceType    = ADS_ACETYPE_ACCESS_ALLOWED

Set objACE2 = CreateObject("AccessControlEntry")
objACE2.Trustee    = strComputerUser
objACE2.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objACE2.AceFlags   = 0
objACE2.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE2.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE2.ObjectType = ALLOWED_TO_AUTHENTICATE

Set objACE3 = CreateObject("AccessControlEntry")
objACE3.Trustee    = strComputerUser
objACE3.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objACE3.AceFlags   = 0
objACE3.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE3.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE3.ObjectType = RECEIVE_AS

Set objACE4 = CreateObject("AccessControlEntry")
objACE4.Trustee    = strComputerUser
objACE4.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objACE4.AceFlags   = 0
objACE4.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE4.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE4.ObjectType = SEND_AS

Set objACE5 = CreateObject("AccessControlEntry")
objACE5.Trustee    = strComputerUser
objACE5.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objACE5.AceFlags   = 0
objACE5.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE5.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE5.ObjectType = USER_CHANGE_PASSWORD

Set objACE6 = CreateObject("AccessControlEntry")
objACE6.Trustee    = strComputerUser
objACE6.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
objACE6.AceFlags   = 0
objACE6.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE6.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE6.ObjectType = USER_FORCE_CHANGE_PASSWORD

Set objACE7 = CreateObject("AccessControlEntry")
objACE7.Trustee    = strComputerUser
objACE7.AccessMask = ADS_RIGHT_DS_WRITE_PROP
objACE7.AceFlags   = 0
objACE7.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE7.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE7.ObjectType = USER_ACCOUNT_RESTRICTIONS

Set objACE8 = CreateObject("AccessControlEntry")
objACE8.Trustee    = strComputerUser
objACE8.AccessMask = ADS_RIGHT_DS_SELF
objACE8.AceFlags   = 0
objACE8.AceType    = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE8.Flags      = ADS_FLAG_OBJECT_TYPE_PRESENT
objACE8.ObjectType = VALIDATED_DNS_HOST_NAME

Set objACE9 = CreateObject("AccessControlEntry")
objACE9.Trustee    = strComputerUser
objACE9.AccessMask = ADS_RIGHT_DS_SELF
objACE9.AceFlags   = 0
objACE9.AceType  = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT
objACE9.Flags  =  ADS_FLAG_OBJECT_TYPE_PRESENT
objACE9.ObjectType = VALIDATED_SPN

objDACL.AddAce objACE1
objDACL.AddAce objACE2
objDACL.AddAce objACE3
objDACL.AddAce objACE4
objDACL.AddAce objACE5
objDACL.AddAce objACE6
objDACL.AddAce objACE7
objDACL.AddAce objACE8
objDACL.AddAce objACE9

objSecurityDescriptor.DiscretionaryAcl = objDACL
objComputer.Put "ntSecurityDescriptor", objSecurityDescriptor
objComputer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Computer Account

Description
Deletes an individual computer account in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-pro-040"

set objComputer = GetObject("LDAP://CN=" & strComputer & _
    ",CN=Computers,DC=fabrikam,DC=com")
objComputer.DeleteObject (0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Global Catalog Server

Description
Disables the global catalog service on the domain controller atl-dc-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-dc-01"

Const NTDSDSA_OPT_IS_GC = 1

Set objRootDSE = GetObject("LDAP://" & strComputer & "/rootDSE")
strDsServiceDN = objRootDSE.Get("dsServiceName")
Set objDsRoot  = GetObject _
    ("LDAP://" & strComputer & "/" & strDsServiceDN)
intOptions = objDsRoot.Get("options")

If intOptions And NTDSDSA_OPT_IS_GC Then
    objDsRoot.Put "options", intOptions Xor NTDSDSA_OPT_IS_GC
    objDsRoot.Setinfo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a Global Catalog Server

Description
Enables the global catalog service on the domain controller atl-dc-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-dc-01"

Const NTDSDSA_OPT_IS_GC = 1

Set objRootDSE = GetObject("LDAP://" & strComputer & "/RootDSE")
strDsServiceDN = objRootDSE.Get("dsServiceName")
Set objDsRoot  = GetObject _
    ("LDAP://" & strComputer & "/" & strDsServiceDN)
intOptions = objDsRoot.Get("options")

If (intOptions And NTDSDSA_OPT_IS_GC) = FALSE Then
    objDsRoot.Put "options" , intOptions Or NTDSDSA_OPT_IS_GC
    objDsRoot.Setinfo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Join a Computer to a Domain

Description
Joins the local computer to a domain and creates the computer's account in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144

strDomain = "FABRIKAM"
strPassword = "ls4k5ywA"
strUser = "shenalan"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
        strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain & "\" & strUser, NULL, _
        JOIN_DOMAIN + ACCT_CREATE)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Computer Accounts in Active Directory

Description
Returns the name and location for all the computer accounts in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
        & "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FSMO Role Holders

Description
Identifies the Active Directory domain controllers providing the five FSMO roles: Schema Master, Domain Naming Master, PDC Emulator, RID Master, and Infrastructure Master.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objRootDSE = GetObject("LDAP://rootDSE")

Set objSchema = GetObject _
    ("LDAP://" & objRootDSE.Get("schemaNamingContext"))
strSchemaMaster = objSchema.Get("fSMORoleOwner")
Set objNtds = GetObject("LDAP://" & strSchemaMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo "Forest-wide Schema Master FSMO: " & objComputer.Name

Set objNtds = Nothing
Set objComputer = Nothing

Set objPartitions = GetObject("LDAP://CN=Partitions," & _
    objRootDSE.Get("configurationNamingContext"))
strDomainNamingMaster = objPartitions.Get("fSMORoleOwner")
Set objNtds = GetObject("LDAP://" & strDomainNamingMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo "Forest-wide Domain Naming Master FSMO: " & objComputer.Name

Set objDomain = GetObject _
    ("LDAP://" & objRootDSE.Get("defaultNamingContext"))
strPdcEmulator = objDomain.Get("fSMORoleOwner")
Set objNtds = GetObject("LDAP://" & strPdcEmulator)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo "Domain's PDC Emulator FSMO: " & objComputer.Name

Set objRidManager = GetObject("LDAP://CN=RID Manager$,CN=System," & _
    objRootDSE.Get("defaultNamingContext"))
strRidMaster = objRidManager.Get("fSMORoleOwner")
Set objNtds = GetObject("LDAP://" & strRidMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo "Domain's RID Master FSMO: " & objComputer.Name

Set objInfrastructure = GetObject("LDAP://CN=Infrastructure," & _
    objRootDSE.Get("defaultNamingContext"))
strInfrastructureMaster = objInfrastructure.Get("fSMORoleOwner")
Set objNtds = GetObject("LDAP://" & strInfrastructureMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo "Domain's Infrastructure Master FSMO: " & objComputer.Name

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Selected Computer Account Attributes

Description
Demonstration script that retrieves the location and description attributes for a computer account in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objComputer = GetObject _
    ("LDAP://CN=atl-dc-01,CN=Computers,DC=fabrikam,DC=com")

objProperty = objComputer.Get("Location")
If IsNull(objProperty) Then
    Wscript.Echo "The location has not been set."
Else
    Wscript.Echo "Location: " & objProperty
    objProperty = Null
End If

objProperty = objComputer.Get("Description")
If IsNull(objProperty) Then
    Wscript.Echo "The description has not been set."
Else
    Wscript.Echo "Description: " & objProperty
    objProperty = Null
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Computer Location Attribute

Description
Demonstration script that changes the location attribute for a computer account in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objComputer = GetObject _
    ("LDAP://CN=atl-dc-01,CN=Computers,DC=fabrikam,DC=com")

objComputer.Put "Location" , "Building 37, Floor 2, Room 2133"
objComputer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Computer Account

Description
Moves a computer account from the Computers container in Active Directory to the Finance OU in the same domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")

Set objMoveComputer = objNewOU.MoveHere _
    ("LDAP://CN=atl-pro-03,CN=Computers,DC=fabrikam,DC=com", "CN=atl-pro-03")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Computer Account to a New Domain

Description
Uses the MoveHere method to move an object to another domain. Note that there are a number of restrictions associated with performing this type of move operation. For details, see the Directory Services Platform SDK.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://cn=Computers,dc=NA,dc=fabrikam,dc=com")

objOU.MoveHere "LDAP://cn=Computer01,cn=Users,dc=fabrikam,dc=com", _
    vbNullString

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Computer Account

Description
Renames an Active Directory computer account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")

Set objMoveComputer = objNewOU.MoveHere _
    ("LDAP://CN=atl-pro-037,OU=Finance,DC=fabrikam,DC=com", _
        "CN=atl-pro-003")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Computer and Computer Account

Description
Renames a computer and its corresponding Active Directory computer account. Requires Windows XP or Windows Server 2003, and must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputers
    err = objComputer.Rename("WebServer")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Reset a Computer Account Password

Description
Resets a computer account password in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objComputer = GetObject _
    ("LDAP://CN=atl-dc-01,CN=Computers,DC=Reskit,DC=COM")

objComputer.SetPassword "atl-dc-01$"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Specific Computer Accounts

Description
Returns the name and location for all the computers in the domain that are running Windows Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    "Select Name, Location, operatingSystemVersion from " & _
        "'LDAP://DC=fabrikam,DC=com' where objectClass='computer'" & _
            " and operatingSystemVersion = '5.1 (3600)'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
    Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Computer Role

Description
Returns the basic role (domain controller, member server, workstation, etc.) for a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
    ("Select DomainRole from Win32_ComputerSystem")

For Each objComputer in colComputers
    Select Case objComputer.DomainRole
        Case 0
            strComputerRole = "Standalone Workstation"
        Case 1
            strComputerRole = "Member Workstation"
        Case 2
            strComputerRole = "Standalone Server"
        Case 3
            strComputerRole = "Member Server"
        Case 4
            strComputerRole = "Backup Domain Controller"
        Case 5
            strComputerRole = "Primary Domain Controller"
    End Select
    Wscript.Echo strComputerRole
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that a Computer is a Global Catalog Server

Description
Indicates whether or not the atl-dc-01 domain controller is a global catalog server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-dc-01"

Const NTDSDSA_OPT_IS_GC = 1

Set objRootDSE = GetObject("LDAP://" & strComputer & "/rootDSE")
strDsServiceDN = objRootDSE.Get("dsServiceName")
Set objDsRoot  = GetObject("LDAP://" & strComputer & "/" & strDsServiceDN)
intOptions = objDsRoot.Get("options")

If intOptions And NTDSDSA_OPT_IS_GC Then
    WScript.Echo strComputer & " is a global catalog server."
Else
    Wscript.Echo strComputer & " is not a global catalog server."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Domain Information Using WMI

Description
Retrieves information about domains discovered on the network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NTDomain")

For Each objItem in colItems
    Wscript.Echo "Client Site Name: " & objItem.ClientSiteName
    Wscript.Echo "DC Site Name: " & objItem.DcSiteName
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DNS Forest Name: " & objItem.DnsForestName
    Wscript.Echo "Domain Controller Address: " & _
        objItem.DomainControllerAddress
    Wscript.Echo "Domain Controller Address Type: " & _
        objItem.DomainControllerAddressType
    Wscript.Echo "Domain Controller Name: " & objItem.DomainControllerName
    Wscript.Echo "Domain GUID: " & objItem.DomainGuid
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "DS Directory Service Flag: " & objItem.DSDirectoryServiceFlag
    Wscript.Echo "DS DNS Controller Flag: " & objItem.DSDnsControllerFlag
    Wscript.Echo "DS DNS Domain Flag: " & objItem.DSDnsDomainFlag
    Wscript.Echo "DS DNS Forest Flag: " & objItem.DSDnsForestFlag
    Wscript.Echo "DS Global Catalog Flag: " & objItem.DSGlobalCatalogFlag
    Wscript.Echo "DS Kerberos Distribution Center Flag: " & _
        objItem.DSKerberosDistributionCenterFlag
    Wscript.Echo "DS Primary Domain Controller Flag: " & _
        objItem.DSPrimaryDomainControllerFlag
    Wscript.Echo "DS Time Service Flag: " & objItem.DSTimeServiceFlag
    Wscript.Echo "DS Writable Flag: " & objItem.DSWritableFlag
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Primary Owner Contact: " & objItem.PrimaryOwnerContact
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add 1000 Sample Users to a Security Group

Description
Demonstration script that creates a security group named Group1, and adds one thousand users (UserNo1 through UserNo10000) to that group. This script is not intended for use in a production environment.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objRootDSE = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://cn=Users," & _
    objRootDSE.Get("defaultNamingContext"))
Set objGroup = objContainer.Create("Group", "cn=Group1")
objGroup.Put "sAMAccountName","Group1"
objGroup.SetInfo

For i = 1 To 1000
    strDN = ",cn=Users," & objRootDSE.defaultNamingContext
    objGroup.PutEx ADS_PROPERTY_APPEND, "member", _
        Array("cn=UserNo" & i & strDN)
    objGroup.SetInfo
Next
WScript.Echo "Group1 created and 1000 Users added to the group."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a User to Two Security Groups

Description
Adds a user (MyerKen) to two different Active Directory security groups: Atl-Users and NA-Employees.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objGroup = GetObject _
    ("LDAP://cn=Atl-Users,cn=Users,dc=NA,dc=fabrikam,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objGroup.SetInfo

Set objGroup = GetObject _
    ("LDAP://cn=NA-Employees,cn=Users,dc=NA,dc=fabrikam,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add New Members to a Security Group

Description
Adds two groups (Executives and Scientists) and one user account (MyerKen) to the Sea-Users group in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objGroup = GetObject _
  ("LDAP://cn=Sea-Users,cn=Users,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_APPEND, "member", _
    Array("cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com", _
        "cn=Executives,ou=Management,dc=NA,dc=fabrikam,dc=com", _
            "cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Group Manager

Description
Assigns user MyerKen as the manager of an Active Directory security group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objGroup = GetObject _
  ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.Put "managedBy", "cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com"
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Change the Scope of a Security Group

Description
Changes a global distribution group named Scientists to a universal security group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.Put "groupType", _
    ADS_GROUP_TYPE_GLOBAL_GROUP + ADS_GROUP_TYPE_SECURITY_ENABLED

objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Domain Local Distribution Group

Description
Creates a domain local Active Directory distribution group named Vendors.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4

Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=Vendors")

objGroup.Put "sAMAccountName", "vendors"
objGroup.Put "groupType", ADS_GROUP_TYPE_LOCAL_GROUP
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Domain Local Security Group

Description
Creates a domain local Active Directory security group named DB-Servers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objOU = GetObject("LDAP://cn=Computers,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=DB-Servers")

objGroup.Put "sAMAccountName", "DBServers"
objGroup.Put "groupType", ADS_GROUP_TYPE_LOCAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Global Distribution Group

Description
Creates a global Active Directory distribution group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2

Set objOU = GetObject("LDAP://ou=R&D,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=Scientists")

objGroup.Put "sAMAccountName", "scientists"
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Global Security Group

Description
Creates a global Active Directory security group named HR-Employees.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=HR-Employees")

objGroup.Put "sAMAccountName", "HRStaff"
objGroup.Put "groupType", ADS_GROUP_TYPE_GLOBAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Universal Distribution Group

Description
Creates a universal Active Directory distribution group named Customers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8

Set objOU = GetObject("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=Customers")

objGroup.Put "sAMAccountName", "customers"
objGroup.Put "groupType", ADS_GROUP_TYPE_UNIVERSAL_GROUP
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Universal Security Group

Description
Creates a universal Active Directory security group named All-Employees.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objOU = GetObject("LDAP://cn=Users,dc=NA,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=All-Employees")

objGroup.Put "sAMAccountName", "AllEmployees"
objGroup.Put "groupType", ADS_GROUP_TYPE_UNIVERSAL_GROUP Or _
    ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Group from Active Directory

Description
Deletes a group named atl-users from the HR organizational unit in the domain fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com")

objOU.Delete "group", "cn=atl-users"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Members of a Group

Description
Returns the members of an Active Directory group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objGroup = GetObject _
  ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo

arrMemberOf = objGroup.GetEx("member")

WScript.Echo "Members:"
For Each strMember in arrMemberOf
    WScript.echo strMember
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Group Memberships for All the Users in an OU

Description
Retrieves the memberOf and primaryGroupID attributes of a user account to display group membership. Note that the primaryGroupID attribute contains an integer that maps to the name of the primary group. The memberOf attribute does not contain the name of the primary group of which the user is a member.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Set objOU = GetObject _
    ("LDAP://cn=Users,dc=NA,dc=fabrikam,dc=com")

ObjOU.Filter= Array("user")

For Each objUser in objOU
    WScript.Echo objUser.cn & " is a member of: "
    WScript.Echo vbTab & "Primary Group ID: " & _
        objUser.Get("primaryGroupID")

    arrMemberOf = objUser.GetEx("memberOf")

    If Err.Number <>  E_ADS_PROPERTY_NOT_FOUND Then
        For Each Group in arrMemberOf
            WScript.Echo vbTab & Group
        Next
    Else
        WScript.Echo vbTab & "memberOf attribute is not set"
        Err.Clear
    End If
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Group Object Information

Description
Retrieves the information found on the Object page in Active Directory Users and Computers for a security group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objGroup = GetObject _
  ("GC://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

strWhenCreated = objGroup.Get("whenCreated")
strWhenChanged = objGroup.Get("whenChanged")

Set objUSNChanged = objGroup.Get("uSNChanged")
dblUSNChanged = _
    Abs(objUSNChanged.HighPart * 2^32 + objUSNChanged.LowPart)

Set objUSNCreated = objGroup.Get("uSNCreated")
dblUSNCreated = _
    Abs(objUSNCreated.HighPart * 2^32 + objUSNCreated.LowPart)

objGroup.GetInfoEx Array("canonicalName"), 0
arrCanonicalName = objGroup.GetEx("canonicalName")

WScript.echo "CanonicalName of object:"
For Each strValue in arrCanonicalName
    WScript.Echo vbTab & strValue
Next
WScript.Echo

WScript.Echo "Object class: " & objGroup.Class
WScript.Echo "When Created: " & strWhenCreated & " (Created - GMT)"
WScript.Echo "When Changed: " & strWhenChanged & " (Modified - GMT)"
WScript.Echo
WScript.Echo "USN Changed: " & dblUSNChanged & " (USN Current)"
WScript.Echo "USN Created: " & dblUSNCreated & " (USN Original)"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Other Groups a Group Belongs To

Description
Returns a list of all the groups that the Active Directory security group Scientists is a member of.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfo

arrMembersOf = objGroup.GetEx("memberOf")

WScript.Echo "MembersOf:"
For Each strMemberOf in arrMembersOf
    WScript.Echo strMemberOf
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Active Directory Groups a User Belongs To

Description
Returns a list of all the Active Directory security groups (including the primary group) that include the MyerKen user account as a member.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next
Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

intPrimaryGroupID = objUser.Get("primaryGroupID")
arrMemberOf = objUser.GetEx("memberOf")

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "The memberOf attribute is not set."
Else
    WScript.Echo "Member of: "
    For Each Group in arrMemberOf
        WScript.Echo Group
    Next
End If

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    ";(objectCategory=Group);" & _
        "distinguishedName,primaryGroupToken;subtree"
Set objRecordSet = objCommand.Execute

Do Until objRecordset.EOF
    If objRecordset.Fields("primaryGroupToken") = intPrimaryGroupID Then
        WScript.Echo "Primary group:"
        WScript.Echo objRecordset.Fields("distinguishedName") & _
            " (primaryGroupID: " & intPrimaryGroupID & ")"
    End If
    objRecordset.MoveNext
Loop

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Attributes of the Group Class

Description
Returns a list of mandatory and optional attributes of the group class (as stored in the Active Directory schema).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objGroupClass = GetObject("LDAP://schema/group")
Set objSchemaClass = GetObject(objGroupClass.Parent)

i = 0
WScript.Echo "Mandatory attributes:"
For Each strAttribute in objGroupClass.MandatoryProperties
    i= i + 1
    WScript.Echo i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    WScript.Echo " (Syntax: " & objAttribute.Syntax & ")"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

WScript.Echo VbCrLf & "Optional attributes:"
For Each strAttribute in objGroupClass.OptionalProperties
    i= i + 1
    Wscript.Echo i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    Wscript.Echo " [Syntax: " & objAttribute.Syntax & "]"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the General Properties of a Group

Description
Reads the values found on the General Properties page in Active Directory Users and Computers for a group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "Name: " & objGroup.Name
WScript.Echo "SAM Account Name: " & objGroup.SAMAccountName
WScript.Echo "Mail: " & objGroup.Mail
WScript.Echo "Info: " & objGroup.Info

If intGroupType AND ADS_GROUP_TYPE_LOCAL_GROUP Then
    WScript.Echo "Group scope: Domain local"
ElseIf intGroupType AND ADS_GROUP_TYPE_GLOBAL_GROUP Then
    WScript.Echo "Group scope: Global"
ElseIf intGroupType AND ADS_GROUP_TYPE_UNIVERSAL_GROUP Then
    WScript.Echo "Group scope: Universal"
Else
    WScript.Echo "Group scope: Unknown"
End If

If intGroupType AND ADS_GROUP_TYPE_SECURITY_ENABLED Then
    WScript.Echo "Group type: Security group"
Else
    WScript.Echo "Group type: Distribution group"
End If

For Each strValue in objGroup.Description
    WScript.Echo "Description: " & strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Managed By Information for a Group

Description
Returns information about the manager assigned to an Active Directory security group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

strManagedBy = objGroup.Get("managedBy")

If IsEmpty(strManagedBy) = TRUE Then
    WScript.Echo "No user account is assigned to manage " & _
        "this group."
Else
    Set objUser = GetObject("LDAP://" & strManagedBy)

    Call GetUpdateMemberList

    WScript.Echo "Office: " & _
        objUser.physicalDeliveryOfficeName
    WScript.Echo "Street Address: " & objUser.streetAddress
    WScript.Echo "Locality: " & objUser.l
    WScript.Echo "State/Province: " & objUser.st
    WScript.Echo "Country: " & objUser.c
    WScript.Echo "Telephone Number: " & objUser.telephoneNumber
    WScript.Echo "Fax Number: " & _
        objUser.facsimileTelephoneNumber
End If

Sub GetUpdateMemberList
    Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &H5
    Const Member_SchemaIDGuid = "{BF9679C0-0DE6-11D0-A285-00AA003049E2}"
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    objUser.GetInfoEx Array("canonicalName"),0
    strCanonicalName = objUser.Get("canonicalName")
    strDomain = Mid(strCanonicalName,1,InStr(1,strCanonicalName,".")-1)
    strSAMAccountName = objUser.Get("sAMAccountName")

    Set objNtSecurityDescriptor = objGroup.Get("ntSecurityDescriptor")
    Set objDiscretionaryAcl = objNtSecurityDescriptor.DiscretionaryAcl

    blnMatch = False
    For Each objAce In objDiscretionaryAcl
        If LCase(objAce.Trustee) = _
            LCase(strDomain & "\" & strSAMAccountName) AND _
            objAce.ObjectType =  Member_SchemaIDGuid AND _
                objAce.AceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT AND _
                    objAce.AccessMask And ADS_RIGHT_DS_WRITE_PROP Then
                        blnMatch = True
        End If
    Next
    If blnMatch Then
        WScript.Echo "Manager can update the member list"
    Else
        WScript.Echo "Manager cannot update the member list."
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Owner of a Group

Description
Returns the owner of an Active Directory security group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objGroup = GetObject _
  ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objGroup.Get("ntSecurityDescriptor")

WScript.Echo "Owner Tab"
WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Primary Group for a User Account

Description
Reports the primary group for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
intPrimaryGroupID = objUser.Get("primaryGroupID")

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    ";(objectCategory=Group);" & _
        "distinguishedName,primaryGroupToken;subtree"
Set objRecordSet = objCommand.Execute

Do Until objRecordset.EOF
    If objRecordset.Fields("primaryGroupToken") = intPrimaryGroupID Then
        WScript.Echo "Primary group:"
        WScript.Echo objRecordset.Fields("distinguishedName") & _
            " (primaryGroupID: " & intPrimaryGroupID & ")"
    End If
    objRecordset.MoveNext
Loop

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Security Descriptor for a Group

Description
Returns information found on the security descriptor for the Active Directory group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_DACL_PROTECTED = &H1000

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objGroup.Get("ntSecurityDescriptor")

intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Permissions Tab"
strMessage = "Allow inheritable permissions from the parent to " & _
     "propogate to this object and all child objects "
If (intNtSecurityDescriptorControl And SE_DACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objDiscretionaryAcl = objNtSecurityDescriptor.DiscretionaryAcl
DisplayAceInformation objDiscretionaryAcl, "DACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_ACCESS_ALLOWED = &H0
    Const ADS_ACETYPE_ACCESS_DENIED = &H1
    Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &H5
    Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            If (intAceType = ADS_ACETYPE_ACCESS_ALLOWED Or _
                intAceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT) Then
                WScript.Echo "Type: Allow Access"
            ElseIf (intAceType = ADS_ACETYPE_ACCESS_DENIED Or _
                intAceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) Then
                WScript.Echo "Type: Deny Acess"
            Else
                WScript.Echo "Acess Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo VbCr
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
       WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
        WScript.Echo "-None"
    Else
        If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
            WScript.Echo vbTab & "-Extended access rights."
        If (AccessMask And ADS_RIGHT_DS_SELF) Then
            WScript.Echo vbTab & "-Active Directory must validate a property "
            WScript.Echo vbTab & " write operation beyond the schema " & _
                "definition "
            WScript.Echo vbTab & " for the attribute."
      End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the System Access Control List for a Group

Description
Returns information found on the System Access Control List (SACL) for an Active Directory security group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_SACL_PROTECTED = &H2000
Const ADS_SECURITY_INFO_OWNER = &H1
Const ADS_SECURITY_INFO_GROUP = &H2
Const ADS_OPTION_SECURITY_MASK =&H3
Const ADS_SECURITY_INFO_DACL = &H4
Const ADS_SECURITY_INFO_SACL = &H8

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.SetOption ADS_OPTION_SECURITY_MASK, ADS_SECURITY_INFO_OWNER _
    Or ADS_SECURITY_INFO_GROUP Or ADS_SECURITY_INFO_DACL _
    Or ADS_SECURITY_INFO_SACL

Set objNtSecurityDescriptor = objGroup.Get("ntSecurityDescriptor")

intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Auditing Tab"
strMessage = "Allow inheritable auditing entries from" & _
    "the parent to "
strMessage = strMessage & "propogate to this object and all child objects "

If (intNtSecurityDescriptorControl And SE_SACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objSacl = objNtSecurityDescriptor.SystemAcl
DisplayAceInformation objSacl, "SACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_SYSTEM_AUDIT = &H2
    Const ADS_ACETYPE_SYSTEM_AUDIT_OBJECT = &H7

    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            WScript.Echo "ACETYPE IS: " & intAceType
            If (intAceType = ADS_ACETYPE_SYSTEM_AUDIT or _
                intAceType = ADS_ACETYPE_SYSTEM_AUDIT_OBJECT) Then
                WScript.Echo "Type: Success or Failure Audit"
            Else
                WScript.Echo "Audit Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
        WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
            WScript.Echo "-None"
    Else
        If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
            WScript.Echo vbTab & "-Extended access rights."
        If (AccessMask And ADS_RIGHT_DS_SELF) Then
            WScript.Echo vbTab & "-Active Directory must validate a property "
            WScript.Echo vbTab & " write operation beyond the schema " & _
                "definition "
            WScript.Echo vbTab & " for the attribute."
        End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Group Attributes

Description
Modifies both single-value (samAccountName, mail, info) and multi-value (description) attributes for a group named Scientists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objGroup = GetObject _
   ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.Put "sAMAccountName", "Scientist01"
objGroup.Put "mail", "YoungRob@fabrikam.com"
objGroup.Put "info", "Use this group for official communications " & _
  "with scientists who are contracted to work with Contoso.com."
objGroup.PutEx ADS_PROPERTY_UPDATE, _
    "description", Array("Scientist Mailing List")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Group Type

Description
Changes a local group named Scientists to a global security group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_GROUP_TYPE_GLOBAL_GROUP = &h2
Const ADS_GROUP_TYPE_LOCAL_GROUP = &h4
Const ADS_GROUP_TYPE_UNIVERSAL_GROUP = &h8
Const ADS_GROUP_TYPE_SECURITY_ENABLED = &h80000000

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.Put "groupType", _
    ADS_GROUP_TYPE_UNIVERSAL_GROUP + ADS_GROUP_TYPE_SECURITY_ENABLED
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Group Within a Domain

Description
Moves a group account from the HR OU to the Users container.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://cn=Users,dc=NA,dc=fabrikam,dc=com")

objOU.MoveHere "LDAP://cn=atl-users,ou=HR,dc=NA,dc=fabrikam,dc=com", _
    vbNullString

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove a User from a Group

Description
Removes user MyerKen from the group Sea-Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_DELETE = 4

Set objGroup = GetObject _
   ("LDAP://cn=Sea-Users,cn=Users,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_DELETE, _
    "member",Array("cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove All Group Memberships for a User Account

Description
Removes the MyerKen user account from all Active Directory security groups.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_PROPERTY_DELETE = 4
Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
arrMemberOf = objUser.GetEx("memberOf")

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "This account is not a member of any security groups."
    WScript.Quit
End If

For Each Group in arrMemberOf
    Set objGroup = GetObject("LDAP://" & Group)
    objGroup.PutEx ADS_PROPERTY_DELETE, _
        "member", Array("cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
    objGroup.SetInfo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove All the Members of a Group

Description
Removes all the members of an Active Directory group named Sea-Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objGroup = GetObject _
    ("LDAP://cn=Sea-Users,cn=Users,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_CLEAR, "member", 0
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove the Manager of a Group

Description
Removes the manager entry for the Active Directory security group named Scientists. When this script is run, the group will no longer have an assigned manager.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objGroup = GetObject _
   ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_CLEAR, "managedBy", 0
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Replace Group Membership with All-New Members

Description
Replaces the existing membership of a group named Scientists with two new group members: YoungRob and ShenAlan.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objGroup = GetObject _
    ("LDAP://cn=Scientists,ou=R&D,dc=NA,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_UPDATE, "member", _
      Array("cn=YoungRob,ou=R&D,dc=NA,dc=fabrikam,dc=com", _
          "cn=ShenAlan,ou=R&D,dc=NA,dc=fabrikam,dc=com")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Configure Trust Relationship Properties

Description
Configures trust relationship refresh and validation properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\MicrosoftActiveDirectory")

Set colTrustList = objWMIService.ExecQuery _
    ("Select * from Microsoft_TrustProvider")

For Each objTrust in colTrustList
    objTrust.TrustListLifetime = 25
    objTrust.TrustStatusLifetime = 10
    objTrust.TrustCheckLevel = 1
    objTrust.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Active Directory Database Performance Counters

Description
Installs the Active Database performance counters on a domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
objFSO.CreateFolder ("C:\Performance")
Set objCopyFile = objFSO.GetFile("C:\windows\system32\esentprf.dll ")
objCopyFile.Copy ("C:\performance\esentprf.dll ")

WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\Esent\Performance\Open", _
        "OpenPerformanceData", "REG_SZ"
WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\Esent\Performance\Collect", _
        "CollectPerformanceData", "REG_SZ"
WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\Esent\Performance\Close", _
        "ClosePerformanceData", "REG_SZ"
WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\Esent\Performance\Library", _
        "C:\Performance\Esentprf.dll", "REG_SZ"
strCommandText = "%comspec% /c lodctr.exe c:\windows\system32\esentprf.ini"
WshShell.Run strCommandText

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory Database Replication Partners

Description
Configures trust relationship refresh and validation properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\MicrosoftActiveDirectory")

Set colReplicationOperations = objWMIService.ExecQuery _
    ("Select * from MSAD_ReplNeighbor")

For each objReplicationJob in colReplicationOperations
    Wscript.Echo "Domain: " & objReplicationJob.Domain
    Wscript.Echo "Naming context DN: " & objReplicationJob.NamingContextDN
    Wscript.Echo "Source DSA DN: " & objReplicationJob.SourceDsaDN
    Wscript.Echo "Last synch result: " & objReplicationJob.LastSyncResult
    Wscript.Echo "Number of consecutive synchronization failures: " & _
        objReplicationJob.NumConsecutiveSyncFailures
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Domain Information for Trust Partners

Description
Returns local domain information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\MicrosoftActiveDirectory")

Set colDomainInfo = objWMIService.ExecQuery _
    ("Select * from Microsoft_LocalDomainInfo")

For each objDomain in colDomainInfo
    Wscript.Echo "DNS name: " & objDomain.DNSName
    Wscript.Echo "Flat name: " & objDomain.FlatName
    Wscript.Echo "SID: " & objDomain.SID
    Wscript.Echo "Tree name: " & objDomain.TreeName
    Wscript.Echo "Domain controller name: " & objDomain.DCName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Trust Relationships

Description
Enumerates trust relationships.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\MicrosoftActiveDirectory")

Set colTrustList = objWMIService.ExecQuery _
    ("Select * from Microsoft_DomainTrustStatus")

For each objTrust in colTrustList
    Wscript.Echo "Trusted domain: " & objTrust.TrustedDomain
    Wscript.Echo "Trust direction: " & objTrust.TrustDirection
    Wscript.Echo "Trust type: " & objTrust.TrustType
    Wscript.Echo "Trust attributes: " & objTrust.TrustAttributes
    Wscript.Echo "Trusted domain controller name: " & objTrust.TrustedDCName
    Wscript.Echo "Trust status: " & objTrust.TrustStatus
    Wscript.Echo "Trust is OK: " & objTrust.TrustIsOK
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Active Directory Database Performance

Description
Uses cooked performance counters to monitor the performance of the Active Directory database on a domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDatabases = objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_Esent_Database " _
        & "Where Name = 'NT Directory'")

For Each objADDatabase in colDatabases
    Wscript.Echo "Database cache hit percent: " & _
        objADDatabase.DatabaseCachePercentHit
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Active Directory Replication

Description
Returns a list of pending replication jobs on a domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\MicrosoftActiveDirectory")

Set colReplicationOperations = objWMIService.ExecQuery _
        ("Select * from MSAD_ReplPendingOp")

If colReplicationOperations.Count = 0 Then
    Wscript.Echo "There are no replication jobs pending."
    Wscript.Quit
Else
    For each objReplicationJob in colReplicationOperations
        Wscript.Echo "Serial number: " & objReplicationJob.SerialNumber
        Wscript.Echo "Time in queue: " & objReplicationJob.TimeEnqueued
        Wscript.Echo "DSA DN: " & objReplicationJob.DsaDN
        Wscript.Echo "DSA address: " & objReplicationJob.DsaAddress
        Wscript.Echo "Naming context DN: " & objReplicationJob.NamingContextDn
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Domain Controller Performance

Description
Monitors the performance of an Active Directory domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDatabases = objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_NTDS_NTDS")

For Each objADDatabase in colDatabases
    Wscript.Echo "DS threads in use: " & objADDatabase.DSThreadsInUse
    Wscript.Echo "LDAP bind time: " & objADDatabase.LDAPBindTime
    Wscript.Echo "LDAP client sessions: " & objADDatabase.LDAPClientSessions
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor FRS Replication

Description
Uses cooked performance counters to monitor File Replication Service performance on a domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFRSSet = objWMIService.ExecQuery _
 ("Select * from Win32_PerfFormattedData_FileReplicaConn_FileReplicaConn")

For Each objFRSInstance in colFRSSet
    Wscript.Echo "Remote change orders received: " & _
        objFRSInstance.RemoteChangeOrdersReceived
    Wscript.Echo "Remote change orders sent: " & _
        objFRSInstance.RemoteChangeOrdersSent
    Wscript.Echo "Packets sent: " & objFRSInstance.PacketsSent
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NTDS Performance

Description
Uses cooked performance counters to monitor NTDS performance on a domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_NTDS_NTDS").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
    Wscript.Echo "Directory service threads in use: " & _
        objItem.DSThreadsInUse
    Wscript.Sleep 2000
    objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a New Group Policy Link to an OU

Description
Assigns the Group Policy link Sales Policy to the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strExistingGPLink = objContainer.Get("gPLink")

strGPODisplayName = "Sales Policy"
strGPOLinkOptions = 2
strNewGPLink = "[" & GetGPOADsPath & ";" & strGPOLinkOptions & "]"

objContainer.Put "gPLink", strExistingGPLink & strNewGPLink
objContainer.Put "gPOptions", "0"

objContainer.SetInfo

Function GetGPOADsPath
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"

    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection

    objCommand.CommandText = _
      ";;" & _
          "distinguishedName,displayName;onelevel"
    Set objRecordSet = objCommand.Execute

    Do Until objRecordSet.EOF
        If objRecordSet.Fields("displayName") = strGPODisplayName Then
          GetGPOADsPath = "LDAP://" & objRecordSet.Fields("distinguishedName")
          objConnection.Close
          Exit Function
        End If
        objRecordSet.MoveNext
    Loop
    objConnection.Close
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a New Manager to an OU

Description
Assigns the user account AkersKim as manager of the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.Put "managedBy", "cn=AkersKim,ou=Sales,dc=NA,dc=fabrikam,dc=com"
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear COM+ Attributes from a User Account

Description
Removes all information from the msCOM-UserPartitionSetLink attribute of the MyerKen user account in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "msCOM-UserPartitionSetLink", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear the COM+ Partition Link Set of an OU

Description
Removes the COM+ partition link set assigned to the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.PutEx ADS_PROPERTY_CLEAR, "msCOM-UserPartitionSetLink", 0
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear the General Properties of an OU

Description
Modifies the attribute values found on the General Properties page in Active Directory Users and Computers for an OU named Sales.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.PutEx ADS_PROPERTY_CLEAR, "description", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "street", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "l", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "st", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "postalCode", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "c", 0
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear the Group Policy Links Assigned to an OU

Description
Removes all the Group Policy links assigned to the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.PutEx ADS_PROPERTY_CLEAR, "gPLink", 0
objContainer.PutEx ADS_PROPERTY_CLEAR, "gPOptions", 0
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an OU

Description
Creates a new organizational unit within Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")

Set objOU = objDomain.Create("organizationalUnit", "ou=Management")
objOU.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an OU in an Existing OU

Description
Creates a new organizational unit (OU2) in an existing organizational unit (OU1).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU1 = GetObject("LDAP://ou=OU1,dc=na,dc=fabrikam,dc=com")

Set objOU2 = objOU1.Create("organizationalUnit", "ou=OU2")
objOU2.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an OU

Description
Deletes an organizational unit named HR from the domain fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")

objDomain.Delete "organizationalUnit", "ou=hr"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List COM+ Partition Information for a Domain

Description
Returns COM+ partition information for the domain na.fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objCOMPartitionSets = GetObject _
    ("LDAP://cn=ComPartitionSets,cn=System,dc=NA,dc=fabrikam,dc=com")

For Each objPartitionSet in objCOMPartitionSets
    WScript.Echo "Name: " & objPartitionSet.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List COM+ Partition Sets

Description
Returns a list of Active Directory COM+ partition sets.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objCOMPartitionSets = GetObject _
    ("LDAP://cn=ComPartitionSets,cn=System,dc=NA,dc=fabrikam,dc=com")

For Each objPartitionSet in objCOMPartitionSets
    WScript.Echo "Name: " & objPartitionSet.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Group Policy Information for an OU

Description
Returns the values found on the Group Policy page in Active Directory Users and Computers for the Sales OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strGpLink = objContainer.Get("gPLink")
intGpOptions = objContainer.Get("gPOptions")

If strGpLink <> " " Then
    arrGpLinkItems = Split(strGpLink,"]")
    For i = UBound(arrGPLinkItems) to LBound(arrGpLinkItems) + 1 Step -1
        arrGPLink = Split(arrGpLinkItems(i-1),";")
        strDNGPLink = Mid(arrGPLink(0),9)
        WScript.Echo GetGPOName
        Select Case arrGPLink(1)
        Case 0
            WScript.Echo "No Override is cleared and the GPO is enabled."
        Case 1
            WScript.Echo "No Override is cleared and the GPO is disabled."
        Case 2
            WScript.Echo "No Override is checked and the GPO is enabled."
        Case 3
            WScript.Echo "No Override is checked and the GPO is disabled."
      End Select
    Next
    WScript.Echo VbCrLf
End If

If intGpOptions = 1 Then
    WScript.Echo "Block Policy Inheritance is checked."
Else
    WScript.Echo "Block Policy Inheritance is not checked."
End If

Function GetGPOName
    Set objConnection = CreateObject("ADODB.Connection")
    objConnection.Open "Provider=ADsDSOObject;"

    Set objCommand = CreateObject("ADODB.Command")
    objCommand.ActiveConnection = objConnection

    objCommand.CommandText = _
        ";;" & _
            "distinguishedName,displayName;onelevel"
    Set objRecordSet = objCommand.Execute

    Do Until objRecordSet.EOF
        If objRecordSet.Fields("distinguishedName") = strDNGPLink Then
            GetGPOName = objRecordSet.Fields("displayName")
            objConnection.Close
            Exit Function
      End If
      objRecordSet.MoveNext
    Loop
    objConnection.Close
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Attributes of the organizationalUnit Class

Description
Returns both the mandatory and optional attributes for the organizationalUnit class (as found in the Active Directory schema).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOrganizationalUnitClass = _
    GetObject("LDAP://schema/organizationalUnit")

Set objSchemaClass = GetObject(objOrganizationalUnitClass.Parent)

i = 0
WScript.Echo "Mandatory attributes:"

For Each strAttribute in objOrganizationalUnitClass.MandatoryProperties
    i= i + 1
    WScript.Echo i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    WScript.Echo " (Syntax: " & objAttribute.Syntax & ")"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

WScript.Echo VbCrLf & "Optional attributes:"
For Each strAttribute in objOrganizationalUnitClass.OptionalProperties
    i= i + 1
    WScript.StdOut.Write i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    Wscript.Echo " [Syntax: " & objAttribute.Syntax & "]"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the COM+ Properties of an OU

Description
Returns information about the COM+ properties configured for the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strMsCOMUserPartitionSetLink = objContainer.Get("msCOM-UserPartitionSetLink")
WScript.Echo "ms-COMUserPartitionSetLink: " & strMsCOMUserPartitionSetLink

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the General Properties of an OU

Description
Returns information found on the General Properties page in Active Directory Users and Computers for an OU named Sales.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

For Each strValue in objContainer.description
  WScript.Echo "Description: " & strValue
Next

Wscript.Echo "Street Address: " & strStreetAddress
Wscript.Echo "Locality: " &
Wscript.Echo "State/porvince: " & objContainer.st
Wscript.Echo "Postal Code: " & objContainer.postalCode
Wscript.Echo "Country: " & objContainer.c

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Managed By Information for an OU

Description
Returns information about the account assigned as manager of the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objContainer = GetObject _
   ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strManagedBy = objContainer.Get("managedBy")

If IsEmpty(strManagedBy) = TRUE Then
    WScript.Echo "No user account is assigned to manage " & _
        "this OU."
Else
    Set objUser = GetObject("LDAP://" & strManagedBy)
    WScript.Echo "Manager: " & objUser.streetAddress
    WScript.Echo "Office: " & _
      objUser.physicalDeliveryOfficeName
    WScript.Echo "Street Address: " & strStreetAddress
    WScript.Echo "Locality: " & objUser.l
    WScript.Echo "State/province: " & objUser.st
    WScript.Echo "Country: " & objUser.c
    WScript.Echo "Telephone Number: " & objUser.telephoneNumber
    WScript.Echo "Fax Number: " & _
      objUser.facsimileTelephoneNumber
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Owner of an OU

Description
Returns the owner of the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objContainer.Get("ntSecurityDescriptor")

WScript.Echo "Owner Tab"
WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Properties of an OU Object

Description
Returns information found on the Object page in Active Directory Users and Computers for the Sales OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objContainer = GetObject _
   ("GC://ou=Sales,dc=NA,dc=fabrikam,dc=com")

strWhenCreated = objContainer.Get("whenCreated")
strWhenChanged = objContainer.Get("whenChanged")

Set objUSNChanged = objContainer.Get("uSNChanged")
dblUSNChanged = _
    Abs(objUSNChanged.HighPart * 2^32 + objUSNChanged.LowPart)

Set objUSNCreated = objContainer.Get("uSNCreated")
dblUSNCreated = _
    Abs(objUSNCreated.HighPart * 2^32 + objUSNCreated.LowPart)

objContainer.GetInfoEx Array("canonicalName"), 0
arrCanonicalName = objContainer.GetEx("canonicalName")

WScript.Echo "CanonicalName of object:"
For Each strValue in arrCanonicalName
    WScript.Echo vbTab & strValue
Next
WScript.Echo

WScript.Echo "Object class: " & objContainer.Class & vbCrLf
WScript.Echo "whenCreated: " & strWhenCreated & " (Created - GMT)"
WScript.Echo "whenChanged: " & strWhenChanged & " (Modified - GMT)"
WScript.Echo VbCrLf
WScript.Echo "uSNChanged: " & dblUSNChanged & " (USN Current)"
WScript.Echo "uSNCreated: " & dblUSNCreated & " (USN Original)"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Security Descriptor for an OU

Description
Returns the information found on the security descriptor for the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_DACL_PROTECTED = &H1000

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objContainer.Get("ntSecurityDescriptor")

intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Permissions Tab"
strMessage = "Allow inheritable permissions from the parent to " & _
    "propogate to this object and all child objects "
If (intNtSecurityDescriptorControl And SE_DACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objDiscretionaryAcl = objNtSecurityDescriptor.DiscretionaryAcl
DisplayAceInformation objDiscretionaryAcl, "DACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_ACCESS_ALLOWED = &H0
    Const ADS_ACETYPE_ACCESS_DENIED = &H1
    Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &H5
    Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            If (intAceType = ADS_ACETYPE_ACCESS_ALLOWED Or _
                intAceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT) Then
                WScript.Echo "Type: Allow Access"
            ElseIf (intAceType = ADS_ACETYPE_ACCESS_DENIED Or _
                intAceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) Then
                WScript.Echo "Type: Deny Acess"
            Else
                WScript.Echo "Acess Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo VbCr
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
      WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
          WScript.Echo "-None"
      Else
      If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
          WScript.Echo vbTab & "-Extended access rights."
      If (AccessMask And ADS_RIGHT_DS_SELF) Then
          WScript.Echo vbTab & "-Active Directory must validate a property "
          WScript.Echo vbTab & " write operation beyond the schema definition "
          WScript.Echo vbTab & " for the attribute."
      End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the System Access Control List of an OU

Description
Returns information found on the System Access Control List (SACL) for the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_SACL_PROTECTED = &H2000
Const ADS_SECURITY_INFO_OWNER = &H1
Const ADS_SECURITY_INFO_GROUP = &H2
Const ADS_OPTION_SECURITY_MASK =&H3
Const ADS_SECURITY_INFO_DACL = &H4
Const ADS_SECURITY_INFO_SACL = &H8

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.SetOption ADS_OPTION_SECURITY_MASK, ADS_SECURITY_INFO_OWNER _
    Or ADS_SECURITY_INFO_GROUP Or ADS_SECURITY_INFO_DACL _
    Or ADS_SECURITY_INFO_SACL

Set objNtSecurityDescriptor = objContainer.Get("ntSecurityDescriptor")

intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Auditing Tab"
strMessage = "Allow inheritable auditing entries from" & _
    "the parent to propogate to this object and all child objects "
If (intNtSecurityDescriptorControl And SE_SACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objSacl = objNtSecurityDescriptor.SystemAcl
DisplayAceInformation objSacl, "SACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_SYSTEM_AUDIT = &H2
    Const ADS_ACETYPE_SYSTEM_AUDIT_OBJECT = &H7

    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            WScript.Echo "ACETYPE IS: " & intAceType
            If (intAceType = ADS_ACETYPE_SYSTEM_AUDIT or _
                intAceType = ADS_ACETYPE_SYSTEM_AUDIT_OBJECT) Then
                WScript.StdOut.Write "Type: Success or Failure Audit"
            Else
                WScript.StdOut.Write "Audit Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
        WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
            WScript.Echo "-None"
    Else
        If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
            WScript.Echo vbTab & "-Extended access rights."
        If (AccessMask And ADS_RIGHT_DS_SELF) Then
            WScript.Echo vbTab & "-Active Directory must validate a property "
            WScript.Echo vbTab & " write operation beyond the schema " & _
                "definition "
            WScript.Echo vbTab & " for the attribute."
        End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the COM+ Partition Set Link of an OU

Description
Assigns the COM+ partition set PartitionSet1 to the Sales OU in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.Put "msCOM-UserPartitionSetLink", _
    "cn=PartitionSet1,cn=ComPartitionSets,cn=System,dc=NA,dc=fabrikam,dc=com"
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the General Properties of an OU

Description
Modifies the attribute values found on the General Properties page in Active Directory Users and Computers for an OU named Sales.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objContainer = GetObject _
    ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.Put "street", "Building 43" & vbCrLf & "One Microsoft Way"
objContainer.Put "l", "Redmond"
objContainer.Put "st", "Washington"
objContainer.Put "postalCode", "98053"
objContainer.Put "c", "US"
objContainer.PutEx ADS_PROPERTY_UPDATE, _
    "description", Array("Sales staff")
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove an OU Manager

Description
Removes the manager entry for the Active Directory OU named Sales. When this group is run, the OU will no longer have an assigned manager.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")

objContainer.PutEx ADS_PROPERTY_CLEAR, "managedBy", 0
objContainer.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Active Directory Site

Description
Creates an Active Directory site and sets the site link for the new site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSiteRDN      = "cn=Ga-Atl-Sales"
strSiteLinkRDN  = "cn=DEFAULTIPSITELINK"
strSiteLinkType = "IP"

Const ADS_PROPERTY_APPEND = 3

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC

Set objSitesContainer = GetObject(strSitesContainer)

Set objSite = objSitesContainer.Create("site", strSiteRDN)
objSite.SetInfo

Set objLicensingSiteSettings = objSite.Create("licensingSiteSettings", _
    "cn=Licensing Site Settings")
objLicensingSiteSettings.SetInfo

Set objNtdsSiteSettings = objSite.Create("nTDSSiteSettings", _
     "cn=NTDS Site Settings")
objNtdsSiteSettings.SetInfo

Set objServersContainer = objSite.Create("serversContainer", "cn=Servers")
objServersContainer.SetInfo

strSiteLinkPath = "LDAP://" & strSiteLinkRDN & ",cn=" & strSiteLinkType & _
    ",cn=Inter-Site Transports,cn=Sites," & strConfigurationNC

Set objSiteLink = GetObject(strSiteLinkPath)
objSiteLink.PutEx ADS_PROPERTY_APPEND, "siteList", _
                  Array(objSite.Get("distinguishedName"))
objSiteLink.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Active Directory Site Link

Description
Creates an Active Directory site link.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSite1Name    = "Ga-Atl-Sales"
strSite2Name    = "Wa-Red-Sales"
strSiteLinkRDN  = "cn=[" & strSite1Name & "][" & strSite2Name & "]"
intCost         = 100
intReplInterval = 60
strDescription  = "[" & strSite1Name & "][" & strSite2Name & "]"

Const ADS_PROPERTY_UPDATE = 2

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSite1DN = "cn=" & strSite1Name & ",cn=Sites," & strConfigurationNC
strSite2DN = "cn=" & strSite2Name & ",cn=Sites," & strConfigurationNC

Set objInterSiteTransports = GetObject("LDAP://" & _
    "cn=IP,cn=Inter-Site Transports,cn=Sites," & strConfigurationNC)

Set objSiteLink = objInterSiteTransports.Create("siteLink", strSiteLinkRDN)
objSiteLink.Put "cost",         intCost
objSiteLink.Put "replInterval", intReplInterval
objSiteLink.Put "description",  strDescription

objSiteLink.PutEx ADS_PROPERTY_UPDATE, "siteList", _
                  Array(strSite1DN, strSite2DN)
objSiteLink.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Active Directory Subnet

Description
Creates an Active Directory subnet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSubnetRDN     = "cn=192.168.1.0/26"
strSiteObjectRDN = "cn=Ga-Atl-Sales"
strDescription   = "192.168.1.0/255.255.255.192"
strLocation      = "USA/GA/Atlanta"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSiteObjectDN = strSiteObjectRDN & ",cn=Sites," & strConfigurationNC

strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC

Set objSubnetsContainer = GetObject(strSubnetsContainer)

Set objSubnet = objSubnetsContainer.Create("subnet", strSubnetRDN)
objSubnet.Put "siteObject", strSiteObjectDN
objSubnet.Put "description", strDescription

objSubnet.Put "location", strLocation
objSubnet.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Active Directory Subnet

Description
Deletes an Active Directory subnet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSubnetCN = "cn=192.168.1.0/26"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC

Set objSubnetsContainer = GetObject(strSubnetsContainer)
objSubnetsContainer.Delete "subnet", strSubnetCN

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory Connections

Description
Lists Active Directory connections (nTDSConnection objects) for a specified domain controller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strDcRDN   = "cn=atl-dc-01"
strSiteRDN = "cn=Ga-Atl-Sales"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strNtdsSettingsPath = "LDAP://cn=NTDS Settings," & strDcRDN & _
    ",cn=Servers," & strSiteRDN & ",cn=Sites," & strConfigurationNC

Set objNtdsSettings = GetObject(strNtdsSettingsPath)

objNtdsSettings.Filter = Array("nTDSConnection")

WScript.Echo strDcRDN & " NTDS Connection Objects" & vbCrLf & _
    String(Len(strDcRDN) + 24, "=")

For Each objConnection In objNtdsSettings
    WScript.Echo "Name:      " & objConnection.Name
    WScript.Echo "Enabled:   " & objConnection.enabledConnection
    WScript.Echo "From:      " & Split(objConnection.fromServer, ",")(1)
    WScript.Echo "Options:   " & objConnection.Options
    WScript.Echo "Transport: " & Split(objConnection.transportType, ",")(0)
    WScript.Echo "Naming Contexts"
    WScript.Echo "---------------"
    For Each objDNWithBin In objConnection.GetEx("ms-DS-ReplicatesNCReason")
        Wscript.Echo objDNWithBin.DNString
    Next
    WScript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory Sites

Description
Lists Active Directory sites.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
Set objSitesContainer = GetObject(strSitesContainer)
objSitesContainer.Filter = Array("site")

For Each objSite In objSitesContainer
    WScript.Echo "Name: " & objSite.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Domain Controllers

Description
Returns a list of all the domain controllers in the fabrikam.com domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection

objCommand.CommandText = _
    "Select distinguishedName from " & _
        "'LDAP://cn=Configuration,DC=fabrikam,DC=com' " _
            & "where objectClass='nTDSDSA'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Computer Name: " & _
        objRecordSet.Fields("distinguishedName").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Servers in an Active Directory Site

Description
Lists servers in a specified Active Directory site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSiteRDN = "cn=Ga-Atl-Sales"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strServersPath = "LDAP://cn=Servers," & strSiteRDN & ",cn=Sites," & _
    strConfigurationNC
Set objServersContainer = GetObject(strServersPath)

For Each objServer In objServersContainer
    WScript.Echo "Name: " & objServer.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Protocols Over Which a Bridgehead Server Replicates

Description
Reads the bridgehead transport list from a domain controller in a site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objServer = GetObject _
    ("LDAP://CN=SEA-DC-01,CN=Servers,CN=Default-First-Site-Name,"  & _
        " CN=Sites,CN=Configuration,DC=fabrikam,DC=com")

dnBHTList = objServer.GetEx("bridgeheadTransportList")

WScript.Echo "Bridge Head Transport List:"
WScript.Echo "This multi-valued attribute lists the protocol" & _
    "transports over which this BridgeHead Server replicates"
For Each dnValue in dnBHTList
    WScript.Echo "Value: " & dnValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Site Name for a Domain Controller

Description
Reports the site name for a specified computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDcName = "atl-dc-01"
Set objADSysInfo = CreateObject("ADSystemInfo")

strDcSiteName = objADSysInfo.GetDCSiteName(strDcName)
WScript.Echo "DC Site Name: " & strDcSiteName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Site Name for the Local Computer

Description
Reports the site name for the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objADSysInfo = CreateObject("ADSystemInfo")

WScript.Echo "Current site name: " & objADSysInfo.SiteName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Subnets in all Active Directory Sites

Description
Lists subnets in all Active Directory sites.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," & strConfigurationNC

Set objSubnetsContainer = GetObject(strSubnetsContainer)

objSubnetsContainer.Filter = Array("subnet")

Set objHash = CreateObject("Scripting.Dictionary")

For Each objSubnet In objSubnetsContainer
    objSubnet.GetInfoEx Array("siteObject"), 0
    strSiteObjectDN = objSubnet.Get("siteObject")
    strSiteObjectName = Split(Split(strSiteObjectDN, ",")(0), "=")(1)

    If objHash.Exists(strSiteObjectName) Then
        objHash(strSiteObjectName) = objHash(strSiteObjectName) & "," & _
            Split(objSubnet.Name, "=")(1)
    Else
        objHash.Add strSiteObjectName, Split(objSubnet.Name, "=")(1)
    End If
Next

For Each strKey In objHash.Keys
    WScript.Echo strKey & "," & objHash(strKey)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Subnets in an Active Directory Site

Description
Lists subnets in a specified Active Directory site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSiteRDN = "cn=Ga-Atl-Sales"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSitePath = "LDAP://" & strSiteRDN & ",cn=Sites," & strConfigurationNC

Set objSite = GetObject(strSitePath)

objSite.GetInfoEx Array("siteObjectBL"), 0
arrSiteObjectBL = objSite.GetEx("siteObjectBL")

WScript.Echo strSiteRDN & " Subnets" & vbCrLf & _
    String(Len(strSiteRDN) + 8, "-")

For Each strSiteObjectBL In arrSiteObjectBL
    WScript.Echo Split(Split(strSiteObjectBL, ",")(0), "=")(1)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Your Domain Controller

Description
Returns the name of the domain controller used to authenticate the logged-on user of a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("LDAP://rootDse")

objDC = objDomain.Get("dnsHostName")
Wscript.Echo "Authenticating domain controller:" & objDC

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Domain Controller to a New Active Directory Site

Description
Moves a domain controller from one Active Directory site (strSourceSiteRDN) to another Active Directory site (strTargetSiteRDN).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strSourceSiteRDN = "cn=Default-First-Site-Name"
strTargetSiteRDN = "cn=Ga-Atl-Sales"
strDcRDN         = "cn=atl-dc-01"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strDcPath = "LDAP://" & strDcRDN & ",cn=Servers," & strSourceSiteRDN & _
    ",cn=Sites," & strConfigurationNC

strTargetSitePath = "LDAP://cn=Servers," & strTargetSiteRDN & _
    ",cn=Sites," & strConfigurationNC

Set objTargetSite = GetObject(strTargetSitePath)
objTargetSite.MoveHere strDcPath, strDcRDN

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename an Active Directory Site

Description
Renames an Active Directory site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strOldSiteRDN = "cn=Default-First-Site-Name"
strNewSiteRDN = "cn=Ga-Atl-Sales"

Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get("configurationNamingContext")

strSitesContainer = "LDAP://cn=Sites," & strConfigurationNC
strOldSitePath = "LDAP://" & strOldSiteRDN & ",cn=Sites," & strConfigurationNC

Set objSitesContainer = GetObject(strSitesContainer)
objSitesContainer.MoveHere strOldSitePath, strNewSiteRDN

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that a Domain Controller is in a Site

Description
Checks to see if a domain controller is in a specific Active Directory site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDcName = "atl-dc-01"
strSiteName = "ga-atl-sales"

Set objADSysInfo = CreateObject("ADSystemInfo")
strDcSiteName = objADSysInfo.GetDCSiteName(strDcName)

If UCase(strSiteName) = UCase(strDcSiteName) Then
    WScript.Echo "TRUE: " & strDcName & " is in site " & strSiteName
Else
    WScript.Echo "FALSE: " & strDcName & " is NOT in site " & strSiteName
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Route to the Dial-In Properties of a User Account

Description
Appends a new route to the Dial-In properties of a user account in Active Directory. This operation adds the new route without deleting any existing routes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objUser.PutEx ADS_PROPERTY_APPEND, _
    "msRASSavedFramedRoute", _
        Array("128.168.0.0/15 0.0.0.0 5")
objUser.PutEx ADS_PROPERTY_APPEND, _
    "msRADIUSFramedRoute", _
        Array("128.168.0.0/15 0.0.0.0 5")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Additional postOfficeBox Information for a User Account

Description
Appends new entries to the postOfficeBox attribute of an Active Directory user account. This operation adds the new post office boxes without deleting any existing entries.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_APPEND, "postOfficeBox", Array("2225","2226")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add an Additional Home Phone Number to a User Account

Description
Appends a new phone number to the otherHomePhone attribute of an Active Directory user account. This operation adds the phone number to the attribute without deleting any existing phone numbers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_APPEND, "otherHomePhone", Array("(425) 555-0116")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add an Additional URL to a User Account

Description
Adds an additional URL to a user account. Demonstrates how to append a new value to a multi-valued attribute.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_APPEND, _
    "url", Array("http://www.fabrikam.com/policy")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign the Primary Group for a User

Description
Sets the primary group for the MyerKen Active Directory user account to MgmtUniversal.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

Set objGroup = GetObject _
    ("LDAP://cn=MgmtUniversal,ou=Management,dc=NA,dc=fabrikam,dc=com")
objGroup.GetInfoEx Array("primaryGroupToken"), 0
intPrimaryGroupToken = objGroup.Get("primaryGroupToken")

objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objGroup.SetInfo
objUser.Put "primaryGroupID", intPrimaryGroupToken
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clearing User Account Address Attributes

Description
Clears selected address-related attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "streetAddress", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "c", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Published Certificate to a User Account

Description
Copies a published certificate from a template account (userTemplate) and assigns it to the MyerKen Active Directory user account. This operation replaces any existing published certificates for the MyerKen account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_PROPERTY_UPDATE = 2

Set objUserTemplate = _
    GetObject("LDAP://cn=userTemplate,OU=Management,dc=NA,dc=fabrikam,dc=com")
arrUserCertificates = objUserTemplate.GetEx("userCertificate")

Set objUser = _
    GetObject("LDAP://cn=MyerKen,OU=Management,dc=NA,dc=fabrikam,dc=com")
objUser.PutEx ADS_PROPERTY_UPDATE, "userCertificate", arrUserCertificates
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Calling Station ID from a User Account

Description
Removes a specific calling station ID from the MyerKen Active Directory user account. This operation only removes the specified calling station ID; no other IDs are deleted.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_DELETE = 4

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_DELETE, _
    "msNPSavedCallingStationID", Array("555-0111")
objUser.PutEx ADS_PROPERTY_DELETE, _
    "msNPCallingStationID", Array("555-0111")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Post Office Box from a User Account

Description
Removes a specified value (2224) from the postOfficeBox attribute of the MyerKen Active Directory user account. This operation removes only the specified post office box; other entries will not be deleted.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_DELETE = 4

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_DELETE, "postOfficeBox", Array("2224")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Address Page Information for a User Account

Description
Removes all information for the c (country) and postOfficeBox attributes of the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "c", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "postOfficeBox", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Department and Direct Report Information from a User Account

Description
Removes all information from the department, directReports, and manager attributes of the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D
Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objUser.PutEx ADS_PROPERTY_CLEAR, "department", 0
objUser.SetInfo

arrDirectReports = objUser.GetEx("directReports")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Quit
Else
    For Each strValue in arrDirectReports
        Set objUserSource = GetObject("LDAP://" & strValue)
        objUserSource.PutEx ADS_PROPERTY_CLEAR, "manager", 0
        objUserSource.SetInfo
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Dial-In Properties for a User Account

Description
Clears all Dial-In attribute values for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "msNPAllowDialin", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msNPCallingStationID", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msNPSavedCallingStationID", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRADIUSServiceType", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRADIUSCallbackNumber", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRASSavedCallbackNumber", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRADIUSFramedIPAddress", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRASSavedFramedIPAddress", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRADIUSFramedRoute", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "msRASSavedFramedRoute", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Published Certificates from a User Account

Description
Removes all published certificates for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "userCertificate", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an otherMobile Phone Number

Description
Deletes a phone number from a user account with multiple mobile phone numbers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_DELETE = 4

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_DELETE, _
    "otherMobile", Array("(425) 555-3334")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Published Certificates from a User Account

Description
Retrieves a set of published certificates from a template account (userTemplate), and then deletes each of those certificates from the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_PROPERTY_DELETE = 4

Set objUserTemplate = _
    GetObject("LDAP://cn=userTemplate,OU=Management,dc=NA,dc=fabrikam,dc=com")
arrUserCertificates = objUserTemplate.GetEx("userCertificate")

Set objUser = _
    GetObject("LDAP://cn=MyerKen,OU=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_DELETE, "userCertificate", arrUserCertificates
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Selected Attributes from a User Account

Description
Deletes selected attributes from a user account. Demonstrates how to delete single-valued attributes as well as how to delete a single entry from a multi-valued attribute.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_DELETE = 4

Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_DELETE, _
   "otherTelephone", Array("(425) 555-1213")
objUser.PutEx ADS_PROPERTY_DELETE, "initials", Array("E.")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Selected User Account Attributes

Description
Clears selected attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "initials", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "otherTelephone", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete User Account Telephone Attributes

Description
Clears selected telephone-related attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "info", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "otherPager", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable the Smartcard Required Attribute for a User Account

Description
Disables the setting that requires MyerKen to use a smartcard when logging on to Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_SMARTCARD_REQUIRED = &h40000

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

intUAC = objUser.Get("userAccountControl")

If (intUAC AND ADS_UF_SMARTCARD_REQUIRED) <> 0 Then
    objUser.Put "userAccountControl", intUAC XOR ADS_UF_SMARTCARD_REQUIRED
    objUser.SetInfo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a User to Log on at Any Time

Description
Configures the MyerKen Active Directory user account so that the user can log on at any time on any day of the week.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "logonHours", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Account Page Information for a User Account

Description
Configures basic account information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "userPrincipalName", "MyerKen@fabrikam.com"
objUser.Put "sAMAccountName", "MyerKen01"
objUser.Put "userWorkstations","wks1,wks2,wks3"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Address Page Information for a User Account

Description
Configures address-related information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "streetAddress", "Building 43" & vbCrLf & "One Microsoft Way"
objUser.Put "l", "Redmond"
objUser.Put "st", "Washington"
objUser.Put "postalCode", "98053"
objUser.Put "c", "US"
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "postOfficeBox", Array("2222", "2223", "2224")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify COM+ Information for a User Account

Description
Sets COM+ information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "msCOM-UserPartitionSetLink", _
  "cn=PartitionSet1,cn=ComPartitionSets,cn=System,dc=NA,dc=fabrikam,dc=com"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Dial-In Properties for a User Account

Description
Configures Dial-In attribute values for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "msNPAllowDialin", TRUE
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "msNPSavedCallingStationID", Array("555-0100", "555-0111")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "msNPCallingStationID", Array("555-0100", "555-0111")
objUser.Put "msRADIUSServiceType", 4
objUser.Put "msRADIUSCallbackNumber", "555-0112"
objUser.Put "msRASSavedFramedIPAddress", 167903442
objUser.Put "msRADIUSFramedIPAddress", 167903442 'value of 10.2.0.210
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "msRASSavedFramedRoute", _
        Array("10.1.0.0/16 0.0.0.0 1", "192.168.1.0/24 0.0.0.0 3")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "msRADIUSFramedRoute", _
        Array("10.1.0.0/16 0.0.0.0 1", "192.168.1.0/24 0.0.0.0 3")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify General User Account Attributes

Description
Configures user account attributes found on the General Properties page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2
Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "givenName", "Ken"
objUser.Put "initials", "E."
objUser.Put "sn", "Myer"
objUser.Put "displayName", "Myer, Ken"
objUser.Put "physicalDeliveryOfficeName", "Room 4358"
objUser.Put "telephoneNumber", "(425) 555-1211"
objUser.Put "mail", "myerken@fabrikam.com"
objUser.Put "wWWHomePage", "http://www.fabrikam.com"
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "description", Array("Management staff")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherTelephone", Array("(800) 555-1212", "(425) 555-1213")
objUser.PutEx ADS_PROPERTY_UPDATE, _
     "url", Array("http://www.fabrikam.com/management")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Organization Properties for a User Account

Description
Configures organization information for the MyerKen Active Directory user account. The script also assigns MyerKen as the manager for LewJudy and AkersKim.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=Myerken,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "title", "Manager"
objUser.Put "department", "Executive Management Team"
objUser.Put "company", "Fabrikam"
objUser.Put "manager", _
    "cn=AckermanPilar,OU=Management,dc=NA,dc=fabrikam,dc=com"
objUser.SetInfo

Set objUser01 = GetObject _
    ("LDAP://cn=LewJudy,OU=Sales,dc=NA,dc=fabrikam,dc=com")
Set objUser02 = GetObject _
    ("LDAP://cn=AckersKim,OU=Sales,dc=NA,dc=fabrikam,dc=com")

objUser01.Put "manager", objUser.Get("distinguishedName")
objUser02.Put "manager", objUser.Get("distinguishedName")
objUser01.SetInfo
objUser02.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Account Address Attributes

Description
Configures address-related attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "streetAddress", "Building 43" & _
    VbCrLf & "One Microsoft Way"
objUser.Put "l", "Redmond"
objUser.Put "st", "Washington"
objUser.Put "postalCode", "98053"
objUser.Put "c", "US"
objUser.Put "postOfficeBox", "2222"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Account General Properties

Description
Configures general attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "userPrincipalName", "MyerKen@fabrikam.com"
objUser.Put "sAMAccountName", "MyerKen01"
objUser.Put "userWorkstations", "wks1,wks2,wks3"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Account Telephone Numbers

Description
Configures telephone numbers and calling information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2
Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.Put "homePhone", "(425) 555-0100"
objUser.Put "pager", "(425) 555-0101"
objUser.Put "mobile", "(425) 555-0102"
objUser.Put "facsimileTelephoneNumber", "(425) 555-0103"
objUser.Put "ipPhone", "5555"
objUser.Put "info", "Please do not call this user account" & _
    " at home unless there is a work-related emergency. Call" & _
    " this user's mobile phone before calling the pager number."
objUser.PutEx ADS_PROPERTY_UPDATE, "otherHomePhone", Array("(425) 555-0110")
objUser.PutEx ADS_PROPERTY_UPDATE, "otherPager", Array("(425) 555-0111")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherMobile", Array("(425) 555-0112", "(425) 555-0113")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherFacsimileTelephoneNumber", Array("(425) 555-0114")
objUser.PutEx ADS_PROPERTY_UPDATE, "otherIpPhone", Array("5556")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Profile Paths

Description
Changes the server name portion of the user profile path to \\fabrikam for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

strCurrentProfilePath = objUser.Get("profilePath")
intStringLen = Len(strCurrentProfilePath)
intStringRemains = intStringLen - 11
strRemains = Mid(strCurrentProfilePath, 12, intStringRemains)
strNewProfilePath = "\\fabrikam" & strRemains
objUser.Put "profilePath", strNewProfilePath
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Profile Properties

Description
Configures user profile settings for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "profilePath", "\\sea-dc-01\Profiles\myerken"
objUser.Put "scriptPath", "logon.bat"
objUser.Put "homeDirectory", "\\sea-dc-01\HomeFolders\myerken"
objUser.Put "homeDrive", "H"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify User Telephone Properties

Description
Configures telephone numbers and telephone-related attributes for a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_UPDATE = 2

Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.Put "homePhone", "(425) 555-1111"
objUser.Put "pager", "(425) 555-2222"
objUser.Put "mobile", "(425) 555-3333"
objUser.Put "facsimileTelephoneNumber", "(425) 555-4444"
objUser.Put "ipPhone", "5555"
objUser.Put "info", "Please do not call this user account" & _
  " at home unless there is a work-related emergency. Call" & _
  " this user's mobile phone before calling the pager number"
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherHomePhone", Array("(425) 555-1112")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherPager", Array("(425) 555-2223")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherMobile", Array("(425) 555-3334", "(425) 555-3335")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherFacsimileTelephoneNumber", Array("(425) 555-4445")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherIpPhone", Array("6666")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Require a User to Logon on Using a Smartcard

Description
Configures the MyerKen user account so that the user must use a smartcard in order to logon to Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_SMARTCARD_REQUIRED = &h40000

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

intUAC = objUser.Get("userAccountControl")

If (intUAC AND ADS_UF_SMARTCARD_REQUIRED) = 0 Then
    objUser.Put "userAccountControl", intUAC XOR ADS_UF_SMARTCARD_REQUIRED
    objUser.SetInfo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Password to a User

Description
Configures a new password for a user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=management,dc=fabrikam,dc=com")

objUser.SetPassword "i5A2sj*!"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Change the Password for a User

Description
Changes the password for a user. Requires you to know the user's previous password.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.ChangePassword "i5A2sj*!", "jl3R86df"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Non-Expiring Password

Description
Configures the domain password for a user account to ensure that the password will never expire.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")

If ADS_UF_DONT_EXPIRE_PASSWD AND intUAC Then
    Wscript.Echo "Already enabled"
Else
    objUser.Put "userAccountControl", intUAC XOR _
        ADS_UF_DONT_EXPIRE_PASSWD
    objUser.SetInfo
    WScript.Echo "Password never expires is now enabled"
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Users to Change Their Passwords

Description
Disables the User Cannot Change Password option, allowing the user to change their password.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const CHANGE_PASSWORD_GUID  = _
    "{ab721a53-1e2f-11d0-9819-00aa0040529b}"

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
Set objSD   = objUser.Get("nTSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl
arrTrustees = Array("nt authority\self", "everyone")

For Each strTrustee In arrTrustees
    For Each ace In objDACL
        If(LCase(ace.Trustee) = strTrustee) Then
            If((ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And _
               (LCase(ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
                   objDACL.RemoveAce ace
            End If
        End If
    Next
Next

objUser.Put "nTSecurityDescriptor", objSD
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Domain Password Policy Settings

Description
Displays password policy settings for the domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MIN_IN_DAY = 1440
Const SEC_IN_MIN = 60

Set objDomain = GetObject("WinNT://fabrikam")
Set objAdS = GetObject("LDAP://dc=fabrikam,dc=com")

intMaxPwdAgeSeconds = objDomain.Get("MaxPasswordAge")
intMinPwdAgeSeconds = objDomain.Get("MinPasswordAge")
intLockOutObservationWindowSeconds = objDomain.Get("LockoutObservationInterval")
intLockoutDurationSeconds = objDomain.Get("AutoUnlockInterval")
intMinPwdLength = objAds.Get("minPwdLength")

intPwdHistoryLength = objAds.Get("pwdHistoryLength")
intPwdProperties = objAds.Get("pwdProperties")
intLockoutThreshold = objAds.Get("lockoutThreshold")
intMaxPwdAgeDays = _
  ((intMaxPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
intMinPwdAgeDays = _
  ((intMinPwdAgeSeconds/SEC_IN_MIN)/MIN_IN_DAY) & " days"
intLockOutObservationWindowMinutes = _
  (intLockOutObservationWindowSeconds/SEC_IN_MIN) & " minutes"

If intLockoutDurationSeconds <> -1 Then
  intLockoutDurationMinutes = _
(intLockOutDurationSeconds/SEC_IN_MIN) & " minutes"
Else
  intLockoutDurationMinutes = _
    "Administrator must manually unlock locked accounts"
End If

WScript.Echo "maxPwdAge = " & intMaxPwdAgeDays
WScript.Echo "minPwdAge = " & intMinPwdAgeDays
WScript.Echo "minPwdLength = " & intMinPwdLength
WScript.Echo "pwdHistoryLength = " & intPwdHistoryLength
WScript.Echo "pwdProperties = " & intPwdProperties
WScript.Echo "lockOutThreshold = " & intLockoutThreshold
WScript.Echo "lockOutObservationWindow = " & intLockOutObservationWindowMinutes
WScript.Echo "lockOutDuration = " & intLockoutDurationMinutes

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Domain Password Property Attributes

Description
Displays password settings for the domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objHash = CreateObject("Scripting.Dictionary")

objHash.Add "DOMAIN_PASSWORD_COMPLEX", &h1
objHash.Add "DOMAIN_PASSWORD_NO_ANON_CHANGE", &h2
objHash.Add "DOMAIN_PASSWORD_NO_CLEAR_CHANGE", &h4
objHash.Add "DOMAIN_LOCKOUT_ADMINS", &h8
objHash.Add "DOMAIN_PASSWORD_STORE_CLEARTEXT", &h16
objHash.Add "DOMAIN_REFUSE_PASSWORD_CHANGE", &h32

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")

intPwdProperties = objDomain.Get("PwdProperties")
WScript.Echo "Password Properties = " & intPwdProperties

For Each Key In objHash.Keys
    If objHash(Key) And intPwdProperties Then
        WScript.Echo Key & " is enabled"
    Else
        WScript.Echo Key & " is disabled"
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Password Attributes for a User Account

Description
Displays password-related attributes for an individual user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_PASSWORD_EXPIRED = &h800000
Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const CHANGE_PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}"

Set objHash = CreateObject("Scripting.Dictionary")
objHash.Add "ADS_UF_PASSWD_NOTREQD", &h00020
objHash.Add "ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED", &h0080
objHash.Add "ADS_UF_DONT_EXPIRE_PASSWD", &h10000

Set objUser = GetObject _
    ("LDAP://CN=MyerKen,OU=management,DC=Fabrikam,DC=com")
intUserAccountControl = objUser.Get("userAccountControl")

Set objUserNT = GetObject("WinNT://fabrikam/myerken")
intUserFlags = objUserNT.Get("userFlags")

If ADS_UF_PASSWORD_EXPIRED And intUserFlags Then
    blnExpiredFlag = True
    Wscript.Echo "ADS_UF_PASSWORD_EXPIRED is enabled"
Else
    Wscript.Echo "ADS_UF_PASSWORD_EXPIRED is disabled"
End If

For Each Key In objHash.Keys
    If objHash(Key) And intUserAccountControl Then
        WScript.Echo Key & " is enabled"
    Else
        WScript.Echo Key & " is disabled"
  End If
Next

Set objSD = objUser.Get("nTSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl

For Each Ace In objDACL
    If ((Ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And _
        (LCase(Ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
            blnACEPresent = True
    End If
Next

If blnACEPresent Then
    Wscript.Echo "ADS_UF_PASSWD_CANT_CHANGE is enabled"
Else
    Wscript.Echo "ADS_UF_PASSWD_CANT_CHANGE is disabled"
End If

If blnExpiredFlag = True Then
    Wscript.echo "pwdLastSet is null"
Else
    Wscript.echo "pwdLastSet is " & objUser.PasswordLastChanged
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List When a Password Expires

Description
Determines the date when a user password will expire.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SEC_IN_DAY = 86400
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

Set objUserLDAP = GetObject _
  ("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com")
intCurrentValue = objUserLDAP.Get("userAccountControl")

If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then
    Wscript.Echo "The password does not expire."
Else
    dtmValue = objUserLDAP.PasswordLastChanged
    Wscript.Echo "The password was last changed on " & _
        DateValue(dtmValue) & " at " & TimeValue(dtmValue) & VbCrLf & _
            "The difference between when the password was last set" &  _
                "and today is " & int(now - dtmValue) & " days"
    intTimeInterval = int(now - dtmValue)

    Set objDomainNT = GetObject("WinNT://fabrikam")
    intMaxPwdAge = objDomainNT.Get("MaxPasswordAge")
    If intMaxPwdAge < 0 Then
        WScript.Echo "The Maximum Password Age is set to 0 in the " & _
            "domain. Therefore, the password does not expire."
    Else
        intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY)
        Wscript.Echo "The maximum password age is " & intMaxPwdAge & " days"
        If intTimeInterval >= intMaxPwdAge Then
          Wscript.Echo "The password has expired."
        Else
          Wscript.Echo "The password will expire on " & _
              DateValue(dtmValue + intMaxPwdAge) & " (" & _
                  int((dtmValue + intMaxPwdAge) - now) & " days from today" & _
                      ")."
        End If
    End If
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List When a Password was Last Changed

Description
Identifies the last time a user password was changed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://CN=myerken,OU=management,DC=Fabrikam,DC=com")

dtmValue = objUser.PasswordLastChanged
WScript.Echo "Password last changed: " & dtmValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Prevent Passwords from Being Stored Using Reversible Encrypted Text

Description
Disables the option allowing a password to be stored using reversible encrypted text.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &H80

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")

If intUAC AND _
    ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED Then
        objUser.Put "userAccountControl", intUAC XOR _
            ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED
        objUser.SetInfo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Prevent Users From Changing Their Passwords

Description
Enables the User Cannot Change Password option, which prevents the user from changing his or her password.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const ADS_ACEFLAG_OBJECT_TYPE_PRESENT = &H1
Const CHANGE_PASSWORD_GUID = "{ab721a53-1e2f-11d0-9819-00aa0040529b}"
Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
Set objSD = objUser.Get("ntSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl
arrTrustees = array("nt authority\self", "EVERYONE")

For Each strTrustee in arrTrustees
    Set objACE = CreateObject("AccessControlEntry")
    objACE.Trustee = strTrustee
    objACE.AceFlags = 0
    objACE.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT
    objACE.Flags = ADS_ACEFLAG_OBJECT_TYPE_PRESENT
    objACE.ObjectType = CHANGE_PASSWORD_GUID
    objACE.AccessMask = ADS_RIGHT_DS_CONTROL_ACCESS
    objDACL.AddAce objACE
Next

objSD.DiscretionaryAcl = objDACL
objUser.Put "nTSecurityDescriptor", objSD
objUser. SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Require Users to Change Their Password

Description
Forces a user to change their password the next time they logon.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://CN=myerken,OU=management,DC=Fabrikam,DC=com")

objUser.Put "pwdLastSet", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Whether Users Can Change Their Passwords

Description
Identifies whether or not a user is allowed to change his or her password.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const CHANGE_PASSWORD_GUID  = _
   "{ab721a53-1e2f-11d0-9819-00aa0040529b}"

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
Set objSD = objUser.Get("nTSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl

For Each Ace In objDACL
    If ((Ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And _
        (LCase(Ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
            blnEnabled = True
    End If
Next

If blnEnabled Then
    WScript.Echo "The user cannot change his or her password."
Else
    WScript.Echo "The user can change his or her password."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Account Page Information for a User Account

Description
Returns basic account information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=Myerken,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "User Principal Name: " & objUser.userPrincipalName
WScript.Echo "SAM Account Name: " & objUser.sAMAccountName
WScript.Echo "User Workstations: " & objUser.userWorkstations

Set objDomain = GetObject("LDAP://dc=NA,dc=fabrikam,dc=com")
WScript.Echo "Domain controller: " & objDomain.dc

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Address Page Information for a User Account

Description
Returns address-related attribute values for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next
Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "Street Address: " & objUser.streetAddress
WScript.Echo "Locality: " & objUser.l
WScript.Echo "State/province: " & objUser.st
WScript.Echo "Postal Code: " & objUser.postalCode
WScript.Echo "Country: " & objUser.c

WScript.Echo "Post Office Boxes:"
For Each strValue in objUser.postOfficeBox
    WScript.echo vbTab & vbTab & strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Telephone Settings for a User Account

Description
Displays all the telephone attribute values for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "Home Phone: " & objUser.homePhone
WScript.Echo "Pager: " & objUser.pager
WScript.Echo "Mobile phone: " & objUser.mobile
WScript.Echo " IP Phone: " & objUser.ipPhone
WScript.Echo "Information: " & objUser.info
WScript.Echo " Fax Number: " & objUser.facsimileTelephoneNumber

WScript.Echo "Other Home Phone:"
For Each strValue in objUser.otherHomePhone
    WScript.Echo strValue
Next

WScript.Echo "Other Pager:"
For Each strValue in objUser.otherPager
    WScript.Echo strValue
Next

WScript.Echo "oOther Mobile Phone:"
For Each strValue in objUser.otherMobile
    WScript.Echo strValue
Next

WScript.Echo "Other IP Phone:"
For Each strValue in objUser.otherIpPhone
    WScript.Echo strValue
Next

WScript.Echo "Other Fax Number:"
For Each strValue in objUser.otherFacsimileTelephoneNumber
    WScript.Echo strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Attributes of the User Class

Description
Returns a list of mandatory and optional attributes for the User class in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUserClass = GetObject("LDAP://schema/user")
Set objSchemaClass = GetObject(objUserClass.Parent)

i = 0
WScript.Echo "Mandatory attributes:"
For Each strAttribute in objUserClass.MandatoryProperties
    i= i + 1
    WScript.Echo i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    WScript.Echo " (Syntax: " & objAttribute.Syntax & ")"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

WScript.Echo VbCrLf & "Optional attributes:"
For Each strAttribute in objUserClass.OptionalProperties
    i=i + 1
    WScript.Echo i & vbTab & strAttribute
    Set objAttribute = objSchemaClass.GetObject("Property",  strAttribute)
    WScript.Echo " [Syntax: " & objAttribute.Syntax & "]"
    If objAttribute.MultiValued Then
        WScript.Echo " Multivalued"
    Else
        WScript.Echo " Single-valued"
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Allowed User Logon Hours

Description
Returns the allowed logon hours for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next
Dim arrLogonHoursBytes(20)
Dim arrLogonHoursBits(167)
arrDayOfWeek = Array _
    ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
arrLogonHours = objUser.Get("logonHours")

For i = 1 To LenB(arrLogonHours)
    arrLogonHoursBytes(i-1) = AscB(MidB(arrLogonHours, i, 1))
    WScript.Echo "MidB returns: " & MidB(arrLogonHours, i, 1)
    WScript.Echo "arrLogonHoursBytes: " & arrLogonHoursBytes(i-1)
    wscript.echo vbcrlf
Next

intCounter = 0
intLoopCounter = 0
WScript.echo "Day  Byte 1   Byte 2   Byte 3"
For Each LogonHourByte In arrLogonHoursBytes
    arrLogonHourBits = GetLogonHourBits(LogonHourByte)

    If intCounter = 0 Then
        WScript.STDOUT.Write arrDayOfWeek(intLoopCounter) & Space(2)
        intLoopCounter = intLoopCounter + 1
    End If

    For Each LogonHourBit In arrLogonHourBits
        WScript.STDOUT.Write LogonHourBit
        intCounter = 1 + intCounter

        If intCounter = 8 or intCounter = 16 Then
            Wscript.STDOUT.Write Space(1)
        End If

        If intCounter = 24 Then
            WScript.echo vbCr
            intCounter = 0
        End If
    Next
Next

Function GetLogonHourBits(x)
    Dim arrBits(7)
    For i = 7 to 0 Step -1
        If x And 2^i Then
            arrBits(i) = 1
        Else
            arrBits(i) = 0
        End If
    Next
    GetLogonHourBits = arrBits
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Audit Permissions for a User Account

Description
Returns audit permissions for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_SACL_PROTECTED = &H2000
Const ADS_SECURITY_INFO_OWNER = &H1
Const ADS_SECURITY_INFO_GROUP = &H2
Const ADS_OPTION_SECURITY_MASK =&H3
Const ADS_SECURITY_INFO_DACL = &H4
Const ADS_SECURITY_INFO_SACL = &H8

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.SetOption ADS_OPTION_SECURITY_MASK, ADS_SECURITY_INFO_OWNER _
    Or ADS_SECURITY_INFO_GROUP Or ADS_SECURITY_INFO_DACL _
        Or ADS_SECURITY_INFO_SACL

Set objNtSecurityDescriptor = objUser.Get("ntSecurityDescriptor")

intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Auditing Tab"
strMessage = "Allow inheritable auditing entries from" & _
    "the parent to propogate to this object and all child objects "
If (intNtSecurityDescriptorControl And SE_SACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objSacl = objNtSecurityDescriptor.SystemAcl
DisplayAceInformation objSacl, "SACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_SYSTEM_AUDIT = &H2
    Const ADS_ACETYPE_SYSTEM_AUDIT_OBJECT = &H7

    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            WScript.Echo "ACETYPE IS: " & intAceType
            If (intAceType = ADS_ACETYPE_SYSTEM_AUDIT or _
                intAceType = ADS_ACETYPE_SYSTEM_AUDIT_OBJECT) Then
                WScript.Echo "Type: Success or Failure Audit"
            Else
                WScript.Echo "Audit Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
        WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
        WScript.Echo "-None"
    Else
        If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
            WScript.Echo vbTab & "-Extended access rights."
            If (AccessMask And ADS_RIGHT_DS_SELF) Then
                WScript.Echo vbTab & "-Active Directory must validate " & _
                    "a property "
                WScript.Echo vbTab & " write operation beyond the " & _
                    "schema definition "
                WScript.Echo vbTab & " for the attribute."
        End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List COM+ Information for a User Account

Description
Returns COM+ information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "COM User Partition Set Link: " & _
    objUser.msCOM-UserPartitionSetLink

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Object Page Information for a User Account

Description
Returns information about the MyerKen user account object in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("GC://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

strWhenCreated = objUser.Get("whenCreated")
strWhenChanged = objUser.Get("whenChanged")

Set objUSNChanged = objUser.Get("uSNChanged")
dblUSNChanged = _
    Abs(objUSNChanged.HighPart * 2^32 + objUSNChanged.LowPart)

Set objUSNCreated = objUser.Get("uSNCreated")
dblUSNCreated = _
    Abs(objUSNCreated.HighPart * 2^32 + objUSNCreated.LowPart)

objUser.GetInfoEx Array("canonicalName"), 0
arrCanonicalName = objUser.GetEx("canonicalName")

WScript.echo "Canonical Name of object:"
For Each strValue in arrCanonicalName
    WScript.Echo vbTab & strValue
Next
WScript.Echo

WScript.Echo "Object class: " & objUser.Class
WScript.echo "When Created: " & strWhenCreated & " (Created - GMT)"
WScript.echo "When Changed: " & strWhenChanged & " (Modified - GMT)"
WScript.Echo
WScript.Echo "USN Changed: " & dblUSNChanged & " (USN Current)"
WScript.Echo "USN Created: " & dblUSNCreated & " (USN Original)"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Organization Information for a User Account

Description
Retrieves user account attributes found on the Organization page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

WScript.Echo "Title: " & objUser.title
WScript.Echo "Department: " & objUser.department
WScript.Echo "Company: " & objUser.company
WScript.Echo "Manager: " & objUser.manager

For Each strValue in objUser.directReports
    WScript.Echo "Direct Reports: " & strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Published Certificates for a User Account

Description
Retrieves a list of all the published certificates assigned to the MyerKen user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D
Const ForWriting = 2
Const WshRunning = 0

Set objUser = GetObject _
    ("GC://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objUser.GetInfoEx Array("userCertificate"), 0
arrUserCertificates = objUser.GetEx("userCertificate")

If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "No assigned certificates"
    WScript.Quit
Else
    Set objShell = CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strPath = "."
    intFileCounter = 0

    For Each arrUserCertificate in arrUserCertificates
        strFileName = "file" & intFileCounter
        strFullName = objFSO.BuildPath(strPath, strFileName)
        Set objFile = objFSO.OpenTextFile(strFullName, ForWriting, True)

        For i = 1 To LenB(arrUserCertificate)
            ReDim Preserve arrUserCertificatesChar(i - 1)
            arrUserCertificatesChar(i-1) = _
                Hex(AscB(MidB(arrUserCertificate, i, 3)))
        Next

        intCounter=0
        For Each HexVal in arrUserCertificatesChar
            intCounter=intCounter + 1
            If Len(HexVal) = 1 Then
                objFile.Write(0 & HexVal & " ")
            Else
                objFile.Write(HexVal & " ")
            End If
        Next
        objFile.Close
        Set objFile = Nothing

        Set objExecCmd1 = objShell.Exec _
            ("certutil -decodeHex " & strFileName & " " & strFileName & ".cer")
        Do While objExecCmd1.Status = WshRunning
            WScript.Sleep 100
        Loop
        Set objExecCmd1 = Nothing

        Set objExecCmd2 = objShell.Exec("certutil " & strFileName & ".cer")
        Set objStdOut = objExecCmd2.StdOut
        Set objExecCmd2 = Nothing

        WScript.Echo VbCrLf & "Certificate " & intFileCounter + 1
        While Not objStdOut.AtEndOfStream
            strLine = objStdOut.ReadLine
            If InStr(strLine, "Issuer:") Then
                WScript.Echo Trim(strLine)
                WScript.Echo vbTab & Trim(objStdOut.ReadLine)
            End If
            If InStr(strLine, "Subject:") Then
                Wscript.Echo Trim(strLine)
                WScript.Echo vbTab & Trim(objStdOut.ReadLine)
            End If
            If InStr(strLine, "NotAfter:") Then
                strLine = Trim(strLine)
                WScript.Echo "Expires:"
                Wscript.Echo vbTab & Mid(strLine, 11)
            End If
        Wend

        objFSO.DeleteFile(strFullName)
        objFSO.DeleteFile(strPath & "\" & strFileName & ".cer")

        intFileCounter = intFileCounter + 1
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Security Permissions for a User Account

Description
Returns security permissions for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SE_DACL_PROTECTED = &H1000

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objUser.Get("ntSecurityDescriptor")
intNtSecurityDescriptorControl = objNtSecurityDescriptor.Control

WScript.Echo "Permissions Tab"
strMessage = "Allow inheritable permissions from the parent to " & _
    "propogate to this object and all child objects "
If (intNtSecurityDescriptorControl And SE_DACL_PROTECTED) Then
    Wscript.Echo strMessage & "is disabled."
Else
    WScript.Echo strMessage & "is enabled."
End If
WScript.Echo

Set objDiscretionaryAcl = objNtSecurityDescriptor.DiscretionaryAcl
DisplayAceInformation objDiscretionaryAcl, "DACL"

Sub DisplayAceInformation(SecurityStructure, strType)
    Const ADS_ACETYPE_ACCESS_ALLOWED = &H0
    Const ADS_ACETYPE_ACCESS_DENIED = &H1
    Const ADS_ACETYPE_ACCESS_ALLOWED_OBJECT = &H5
    Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
    intAceCount = 0
    For Each objAce In SecurityStructure
        strTrustee = Mid(objAce.Trustee,1,12)
        If StrComp(strTrustee, "NT AUTHORITY", 1) <> 0 Then
            intAceCount = intAceCount + 1
            WScript.Echo strType & " permission entry: " & intAceCount
            WScript.Echo "Name: " & objAce.Trustee

            intAceType = objAce.AceType
            If (intAceType = ADS_ACETYPE_ACCESS_ALLOWED Or _
                intAceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT) Then
                WScript.Echo "Type: Allow Access"
            ElseIf (intAceType = ADS_ACETYPE_ACCESS_DENIED Or _
                intAceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) Then
                WScript.Echo "Type: Deny Acess"
            Else
                WScript.Echo "Acess Type Unknown."
            End If
            ReadBitsInAccessMask(objAce.AccessMask)
            WScript.Echo
        End If
    Next
End Sub

Sub ReadBitsInAccessMask(AccessMask)
    Const ADS_RIGHT_DELETE = &H10000
    Const ADS_RIGHT_READ_CONTROL = &H20000
    Const ADS_RIGHT_WRITE_DAC = &H40000
    Const ADS_RIGHT_WRITE_OWNER = &H80000
    Const ADS_RIGHT_DS_CREATE_CHILD = &H1
    Const ADS_RIGHT_DS_DELETE_CHILD = &H2
    Const ADS_RIGHT_ACTRL_DS_LIST = &H4
    Const ADS_RIGHT_DS_SELF = &H8
    Const ADS_RIGHT_DS_READ_PROP = &H10
    Const ADS_RIGHT_DS_WRITE_PROP = &H20
    Const ADS_RIGHT_DS_DELETE_TREE = &H40
    Const ADS_RIGHT_DS_LIST_OBJECT = &H80
    Const ADS_RIGHT_DS_CONTROL_ACCESS = &H100

    WScript.Echo VbCrLf & "Standard Access Rights"
    If (AccessMask And ADS_RIGHT_DELETE) Then _
        WScript.Echo vbTab & "-Delete an object."
    If (AccessMask And ADS_RIGHT_READ_CONTROL) Then _
        WScript.Echo vbTab & "-Read permissions."
    If (AccessMask And ADS_RIGHT_WRITE_DAC) Then _
        WScript.Echo vbTab & "-Write permissions."
    If (AccessMask And ADS_RIGHT_WRITE_OWNER) Then _
        WScript.Echo vbTab & "-Modify owner."

    WScript.Echo VbCrLf & "Directory Service Specific Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CREATE_CHILD) Then _
        WScript.Echo vbTab & "-Create child objects."
    If (AccessMask And ADS_RIGHT_DS_DELETE_CHILD) Then _
        WScript.Echo vbTab & "-Delete child objects."
    If (AccessMask And ADS_RIGHT_ACTRL_DS_LIST) Then _
        WScript.Echo vbTab & "-Enumerate an object."
    If (AccessMask And ADS_RIGHT_DS_READ_PROP) Then _
        WScript.Echo vbTab & "-Read the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_WRITE_PROP) Then _
        WScript.Echo vbTab & "-Write the properties of an object."
    If (AccessMask And ADS_RIGHT_DS_DELETE_TREE) Then _
        WScript.Echo vbTab & "-Delete a tree of objects"
    If (AccessMask And ADS_RIGHT_DS_LIST_OBJECT) Then _
        WScript.Echo vbTab & "-List a tree of objects."

    WScript.Echo VbCrLf & "Control Access Rights"
    If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) + _
        (AccessMask And ADS_RIGHT_DS_SELF) = 0 Then
            WScript.Echo "-None"
    Else
        If (AccessMask And ADS_RIGHT_DS_CONTROL_ACCESS) Then _
            WScript.Echo vbTab & "-Extended access rights."
        If (AccessMask And ADS_RIGHT_DS_SELF) Then
            WScript.Echo vbTab & "-Active Directory must validate a property "
            WScript.Echo vbTab & " write operation beyond the schema " & _
                "definition "
            WScript.Echo vbTab & " for the attribute."
        End If
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Dial-In Property Configuration Settings for a User Account

Description
Enumerates the Dial-In configuration settings for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND  = &h8000500D

Const FourthOctet = 1
Const ThirdOctet = 256
Const SecondOctet = 65536
Const FirstOctet = 16777216

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

blnMsNPAllowDialin = objUser.Get("msNPAllowDialin")
WScript.Echo "Remote Access Permission (Dial-in or VPN)"
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "Control access through Remote Access Policy"
    Err.Clear
Else
    If blnMsNPAllowDialin = True Then
        WScript.Echo "Allow access (msNPAllowDialin)"
    Else
        WScript.Echo "Deny access (msNPAllowDialin)"
    End If
End If
WScript.Echo

arrMsNPSavedCallingStationID = objUser.GetEx("msNPSavedCallingStationID")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "No Caller-ID specified."
    Err.Clear
Else
    WScript.Echo "Verify Caller ID (msNPSavedCallingStationID): "
    For Each strValue in arrMsNPSavedCallingStationID
        WScript.echo strValue
    Next

    objUser.GetEx "msNPCallingStationID"
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
        WScript.Echo "Calling station ID(s) specified but not assigned."
        Err.Clear
    Else
        WScript.echo "Calling station ID(s) assigned."
    End If

End If
WScript.Echo

intMsRADIUSServiceType = objUser.Get("msRADIUSServiceType")
WScript.Echo "Callback Options"
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "No Callback"
    Err.Clear
Else
    strMsRADIUSCallbackNumber = objUser.Get("msRADIUSCallbackNumber")
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
        WScript.Echo "Set by caller (Routing and Remote Access Service only)"
        Err.Clear

    strMsRASSavedCallbackNumber = objUser.Get("msRASSavedCallbackNumber")
    If Err.Number <> E_ADS_PROPERTY_NOT_FOUND Then
        WScript.Echo "Unused value of " & strMsRASSavedCallbackNumber & _
            " appears in the Always Callback to field."
    Else
        Err.Clear
    End If
Else
    WScript.Echo "Always Callback to: " & _
        strMsRADIUSCallbackNumber & " (msRADIUSCallbackNumber)"
    End If
End If
WScript.Echo

intMsRASSavedFramedIPAddress = objUser.Get("msRASSavedFramedIPAddress")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "No static IP address assigned."
    Err.Clear
Else
    If sgn(intMsRASSavedFramedIPAddress) = -1 Then
        intIP = intMsRASSavedFramedIPAddress
        WScript.StdOut.Write 256 + (int(intIP/FirstOctet)) & "."
        intFirstRemainder = intIP mod FirstOctet
        WScript.StdOut.Write 256 + (int(intFirstRemainder/SecondOctet)) & "."
        intSecondRemainder = intFirstRemainder mod SecondOctet
        WScript.StdOut.Write 256 + (int(intSecondRemainder/ThirdOctet)) & "."
        intThirdRemainder = intSecondRemainder mod ThirdOctet
        WScript.Echo 256 + (int(intThirdRemainder/FourthOctet))
    Else
        intIP = intMsRASSavedFramedIPAddress
        WScript.StdOut.Write  int(intIP/FirstOctet) & "."
        intFirstRemainder = intIP mod FirstOctet
        WScript.StdOut.Write  int(intFirstRemainder/SecondOctet) & "."
        intSecondRemainder = intFirstRemainder mod SecondOctet
        WScript.StdOut.Write  int(intSecondRemainder/ThirdOctet) & "."
        intThirdRemainder = intSecondRemainder mod ThirdOctet
        WScript.Echo int(intThirdRemainder/FourthOctet)
    End If

    objUser.Get "msRADIUSFramedIPAddress"
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
        WScript.Echo "Static IP address specified but not assigned."
        Err.Clear
    Else
        WScript.Echo "Static IP Address assigned."
    End If

End If
WScript.Echo

arrMsRASSavedFramedRoute = objUser.GetEx("msRASSavedFramedRoute")
If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
    WScript.Echo "No static Routes specified."
    Err.Clear
Else
    WScript.echo "Static Routes (msRASSavedFramedRoute):"
    WScript.Echo vbTab & "CIDR 0.0.0.0 Metric"
    For Each strValue in arrMsRASSavedFramedRoute
        WScript.echo vbTab & strValue
    Next

    objUser.GetEx "msRADIUSFramedRoute"
    If Err.Number = E_ADS_PROPERTY_NOT_FOUND Then
        WScript.Echo "Static Routes specified but not assigned."
        Err.Clear
    Else
        WScript.echo "Static Routes assigned."
    End If
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Account Account Page Properties

Description
Retrieves user account attributes found on the Account page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

WScript.Echo "User Principal Name: " & objUser.userPrincipalName
WScript.Echo "SAM Account Name: " & objUser.sAMAccountName
WScript.Echo "User Workstations: " & objUser.userWorkstations

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")
WScript.Echo "Domain controller: " & objDomain.dc

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Account Address Page Attributes

Description
Retrieves user account attributes found on the Address page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

WScript.Echo "Street Address: " & objUser.streetAddress
WScript.Echo "Post Office Box: " & objUser.postOfficeBox
WScript.Echo "Locality: " & objUser.l
WScript.Echo "Street: " & objUser.st
WScript.Echo "Postal Code: " & objUser.postalCode
WScript.Echo "Country: " & objUser.c

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Account General Page Properties

Description
Retrieves user account attributes found on the General Properties page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

WScript.Echo "First Name: " & objUser.givenName
WScript.Echo "Initials: " & objUser.initials
WScript.Echo "Last Name: " & objUser.sn
WScript.Echo "Display Name: " & objUser.displayName
WScript.Echo "Office: " & _
    objUser.physicalDeliveryOfficeName
WScript.Echo "Telephone Number: " & objUser.telephoneNumber
WScript.Echo "Email: " & objUser.mail
WScript.Echo "Home Page: " &

For Each strValue in objUser.description
    WScript.Echo "Description: " & strValue
Next

For Each strValue in objUser.otherTelephone
    WScript.Echo "Other Telephone: " & strValue
Next

For Each strValue in objUser.url
    WScript.Echo "URL: " & strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Profile Properties

Description
Retrieves user account attributes found on the Profile page of the user account object in Active Directory Users and Computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

Wscript.Echo "Profile Path: " & objUser.ProfilePath
Wscript.Echo "Script Path: " & objUser.ScriptPath
Wscript.Echo "Home Directory: " & objUser.HomeDirectory
Wscript.Echo "Home Drive: " & objUser.HomeDrive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List userAccountControl Values for an Active Directory User Account

Description
Reads values from the userAccountControl of the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objHash = CreateObject("Scripting.Dictionary")

objHash.Add "ADS_UF_SMARTCARD_REQUIRED", &h40000
objHash.Add "ADS_UF_TRUSTED_FOR_DELEGATION", &h80000
objHash.Add "ADS_UF_NOT_DELEGATED", &h100000
objHash.Add "ADS_UF_USE_DES_KEY_ONLY", &h200000
objHash.Add "ADS_UF_DONT_REQUIRE_PREAUTH", &h400000

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")

If objUser.IsAccountLocked = True Then
    Wscript.Echo "ADS_UF_LOCKOUT is enabled"
Else
    Wscript.Echo "ADS_UF_LOCKOUT is disabled"
End If
wscript.echo VBCRLF

For Each Key In objHash.Keys
    If objHash(Key) And intUAC Then
        Wscript.Echo Key & " is enabled"
    Else
        Wscript.Echo Key & " is disabled"
  End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a User Account in Active Directory

Description
Searches Active Directory to see if a user account with the name kenmyer already exists.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strUserName = "kenmyer"
dtStart = TimeValue(Now())
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
         "(samAccountName=" & strUserName & "));samAccountName;subtree"

Set objRecordSet = objCommand.Execute

If objRecordset.RecordCount = 0 Then
    WScript.Echo "sAMAccountName: " & strUserName & " does not exist."
Else
    WScript.Echo strUserName & " exists."
End If

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Published Certificate to a User Account

Description
Copies a published certificate from a template account (userTemplate) to the MyerKen Active Directory user account. This operation appends the new certificate without deleting any existing certificates.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_PROPERTY_APPEND = 3

Set objUserTemplate = _
    GetObject("LDAP://cn=userTemplate,OU=Management,dc=NA,dc=fabrikam,dc=com")
arrUserCertificates = objUserTemplate.GetEx("userCertificate")

Set objUser = _
    GetObject("LDAP://cn=MyerKen,OU=Management,dc=NA,dc=fabrikam,dc=com")
objUser.PutEx ADS_PROPERTY_APPEND, "userCertificate", arrUserCertificates
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy Allowed Logon Hours from One Account to Another

Description
Copies the allowed logon hours from a template account (userTemplate) and assigns them to the MyerKen Active Directory user account. The MyerKen account will thus have the same logon hour restrictions as those assigned to the userTemplate account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUserTemplate = _
    GetObject("LDAP://cn=userTemplate,OU=Management,dc=NA,dc=fabrikam,dc=com")
arrLogonHours = objUserTemplate.Get("logonHours")

Set objUser = _
    GetObject("LDAP://cn=MyerKen,OU=Management,dc=NA,dc=fabrikam,dc=com")
objUser.Put "logonHours", arrLogonHours
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create 1000 Sample User Accounts

Description
Demonstration script that creates 1,000 user accounts (named UserNo1, UserNo2, UserNo3, etc.) in the Users container in Active Directory. The script is useful for test scenarios that require multiple user accounts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objRootDSE = GetObject("LDAP://rootDSE")

Set objContainer = GetObject("LDAP://cn=Users," & _
    objRootDSE.Get("defaultNamingContext"))

For i = 1 To 1000
    Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
    objLeaf.Put "sAMAccountName", "UserNo" & i
    objLeaf.SetInfo
Next

WScript.Echo "1000 Users created."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Contact in Active Directory

Description
Creates a contact account named MyerKen in the Management organizational unit in a hypothetical domain named fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com")

Set objUser = objOU.Create("contact", "cn=MyerKen")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a User Account

Description
Creates a user account in Active Directory. This script only creates the account, it does not enable it.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://OU=management,dc=fabrikam,dc=com")

Set objUser = objOU.Create("User", "cn=MyerKen")
objUser.Put "sAMAccountName", "myerken"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a User Account and Add it to a Group and an OU

Description
Demonstration script that: 1) creates a new Active Directory organizational unit; 2) creates a new user account and new security group; and, 3) adds the new user as a member of that security group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("LDAP://dc=fabrikam,dc=com")
Set objOU = objDomain.Create("organizationalUnit", "ou=Management")
objOU.SetInfo

Set objOU = GetObject("LDAP://OU=Management,dc=fabrikam,dc=com")
Set objUser = objOU.Create("User", "cn= AckermanPilar")
objUser.Put "sAMAccountName", "AckermanPila"
objUser.SetInfo

Set objOU = GetObject("LDAP://OU=Management,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("Group", "cn=atl-users")
objGroup.Put "sAMAccountName", "atl-users"
objGroup.SetInfo

objGroup.Add objUser.ADSPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a User Account from Active Directory

Description
Deletes the user account MyerKen from the HR organizational unit in a domain named fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://ou=hr,dc=fabrikam,dc=com")

objOU.Delete "user", "cn=MyerKen"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Owner of a User Account

Description
Reports the owner of the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

Set objNtSecurityDescriptor = objUser.Get("ntSecurityDescriptor")
WScript.Echo "Owner Tab"
WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the UPN Suffixes Defined in the Forest

Description
Configures the upnSuffixes attribute of the Partitions container and displays the new values.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_PROPERTY_APPEND = 3

Set objPartitions = GetObject _
    ("LDAP://cn=Partitions,cn=Configuration,dc=fabrikam,dc=com")

objPartitions.PutEx ADS_PROPERTY_APPEND, _
    "upnSuffixes", Array("sa.fabrikam.com","corp.fabrikam.com")
objPartitions.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a User Account

Description
Moves a user account from one OU to another.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://ou=sales,dc=na,dc=fabrikam,dc=com")

objOU.MoveHere _
    "LDAP://cn=BarrAdam,OU=hr,dc=na,dc=fabrikam,dc=com", vbNullString

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a User Account to a New Domain

Description
Uses the MoveHere method to move a user account to another domain. Note that there are a number of restrictions associated with performing this type of move operation.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://ou=management,dc=na,dc=fabrikam,dc=com")

objOU.MoveHere _
    "LDAP://cn=AckermanPilar,OU=management,dc=fabrikam,dc=com", vbNullString

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Set a User Account So It Never Expires

Description
Configures the MyerKen Active Directory user account so that it never expires. This is done by setting the expiration date to January 1, 1970.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.AccountExpirationDate = "01/01/1970"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a User Account

Description
Disables a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_ACCOUNTDISABLE = 2

Set objUser = GetObject _
("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")

objUser.Put "userAccountControl", intUAC OR ADS_UF_ACCOUNTDISABLE
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a User Account

Description
Enables a user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

objUser.AccountDisabled = FALSE
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Disabled User Accounts in Active Directory

Description
Returns a list of all disabled user accounts in the fabrikam.com domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_ACCOUNTDISABLE = 2

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    ";(objectCategory=User)" & _
        ";userAccountControl,distinguishedName;subtree"
Set objRecordSet = objCommand.Execute

intCounter = 0
Do Until objRecordset.EOF
    intUAC=objRecordset.Fields("userAccountControl")
    If intUAC AND ADS_UF_ACCOUNTDISABLE Then
        WScript.echo objRecordset.Fields("distinguishedName") & " is disabled"
        intCounter = intCounter + 1
    End If
    objRecordset.MoveNext
Loop

WScript.Echo VbCrLf & "A total of " & intCounter & " accounts are disabled."

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Date That a User Account Expires

Description
Reports the date that the MyerKen Active Directory user account expires.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

dtmAccountExpiration = objUser.AccountExpirationDate

If Err.Number = -2147467259 Or dtmAccountExpiration = "1/1/1970" Then
    WScript.Echo "No account expiration date specified"
Else
    WScript.Echo "Account expiration date: " & objUser.AccountExpirationDate
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Status of a User

Description
Identifies whether a user account is enabled or disabled.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")

If objUser.AccountDisabled = FALSE Then
      WScript.Echo "The account is enabled."
Else
      WScript.Echo "The account is disabled."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Expiration Date for a User Account

Description
Configures the MyerKen Active Directory user account to expire on March 30, 2005.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.AccountExpirationDate = "03/30/2005"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unlock a User Account

Description
Unlocks the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.IsAccountLocked = False
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Activity Logging Options

Description
Lists logging options for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFaxLoggingOptions = objFaxServer.LoggingOptions
Set objFaxActivityLogging = objFaxLoggingOptions.ActivityLogging
Wscript.Echo "Database path: " & _
    objFaxActivityLogging.DatabasePath
Wscript.Echo "Log incoming: " & _
    objFaxActivityLogging.LogIncoming
Wscript.Echo "Log outgoing: " & _
    objFaxActivityLogging.LogOutgoing

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Device Information

Description
Lists device information for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set colDevices = objFaxServer.GetDevices()

For Each objFaxDevice in colDevices
    Wscript.Echo "ID: " & objFaxDevice.ID
    Wscript.Echo "CSID: " & objFaxDevice.CSID
    Wscript.Echo "Description: " & objFaxDevice.Description
    Wscript.Echo "Device name: " & objFaxDevice.DeviceName
    Wscript.Echo "Powered off: " & objFaxDevice.PoweredOff
    Wscript.Echo "Provider unique name: " & _
        objFaxDevice.ProviderUniqueName
    Wscript.Echo "Receive mode: " & objFaxDevice.ReceiveMode
    Wscript.Echo "Receiving now: " & objFaxDevice.ReceivingNow
    Wscript.Echo "Ringing now: " & objFaxDevice.RingingNow
    Wscript.Echo "Rings before answer: " & _
        objFaxDevice.RingsBeforeAnswer
    Wscript.Echo "Send enabled: " & objFaxDevice.SendEnabled
    Wscript.Echo "Sending now: " & objFaxDevice.SendingNow
    Wscript.Echo "TSID: " & objFaxDevice.TSID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Device Providers

Description
Lists all the device providers for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objDeviceProviders = objFaxServer.GetDeviceProviders

For Each objFaxDeviceProvider in objDeviceProviders
    Wscript.Echo "Debug: " & objFaxDeviceProvider.Debug
    Wscript.Echo "Friendly name: " & objFaxDeviceProvider.FriendlyName
    Wscript.Echo "Image name: " & objFaxDeviceProvider.ImageName
    Wscript.Echo "Initialization error code: " & _
        objFaxDeviceProvider.InitErrorCode
    Wscript.Echo "Major build: " & objFaxDeviceProvider.MajorBuild
    Wscript.Echo "Minor build: " & objFaxDeviceProvider.MinorBuild
    Wscript.Echo "Major version: " & objFaxDeviceProvider.MajorVersion
    Wscript.Echo "Minor version: " & objFaxDeviceProvider.MinorVersion
    Wscript.Echo "Status: " & objFaxDeviceProvider.Status
    Wscript.Echo "TAPI provider name: " & objFaxDeviceProvider.TAPIProviderName
    Wscript.Echo "Unique name: " & objFaxDeviceProvider.UniqueName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Event Logging Options

Description
Lists all the event logging options for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFaxLoggingOptions = objFaxServer.LoggingOptions

Set objFaxEventLogging = objFaxLoggingOptions.EventLogging
Wscript.Echo "General events level: " & _
    objFaxEventLogging.GeneralEventsLevel
Wscript.Echo "Inbound events level: " & _
    objFaxEventLogging.InboundEventsLevel
Wscript.Echo "Initialization events level: " & _
    objFaxEventLogging.InitEventsLevel
Wscript.Echo "Outbound events level: " & _
    objFaxEventLogging.OutboundEventsLevel

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Incoming Archive Information

Description
Lists all the incoming archive information for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFolder = objFaxServer.Folders

Set objIncomingArchive = objFolder.IncomingArchive
Wscript.Echo "Age limit: " & objIncomingArchive.AgeLimit
Wscript.Echo "Archive folder: " & objIncomingArchive.ArchiveFolder
Wscript.Echo "High quota watermark: " & objIncomingArchive.HighQuotaWatermark
Wscript.Echo "Low quota watermark: " & objIncomingArchive.LowQuotaWatermark
Wscript.Echo "Size low: " & objIncomingArchive.SizeLow
Wscript.Echo "Size high: " & objIncomingArchive.SizeHigh
Wscript.Echo "Size quota warning: " & objIncomingArchive.SizeQuotaWarning
Wscript.Echo "Use archive: " & objIncomingArchive.UseArchive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Incoming Queue Information

Description
Indicates whether the incoming queue is blocked on the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFolder = objFaxServer.Folders

Set objIncomingQueue = objFolder.IncomingQueue
Wscript.Echo "Blocked: " & objIncomingQueue.Blocked

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Information

Description
Returns information about the fax service installed in the computer atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Wscript.Echo "API version: " & objFaxServer.APIVersion
Wscript.Echo "Major build: " & objFaxServer.MajorBuild
Wscript.Echo "Minor build: " & objFaxServer.MinorBuild
Wscript.Echo "Major version: " & objFaxServer.MajorVersion
Wscript.Echo "Minor version: " & objFaxServer.MinorVersion
Wscript.Echo "Server name: " & objFaxServer.ServerName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Outgoing Archive Information

Description
Lists all the outgoing archive information for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFolder = objFaxServer.Folders
Set objOutgoingArchive = objFolder.OutgoingArchive

Wscript.Echo "Age limikt: " & objOutgoingArchive.AgeLimit
Wscript.Echo "Archive folder: " & objOutgoingArchive.ArchiveFolder
Wscript.Echo "High quota watermark: " & objOutgoingArchive.HighQuotaWatermark
Wscript.Echo "Low quota watermark: " & objOutgoingArchive.LowQuotaWatermark
Wscript.Echo "Size low: " & objOutgoingArchive.SizeLow
Wscript.Echo "Size high: " & objOutgoingArchive.SizeHigh
Wscript.Echo "Size quota warning: " & objOutgoingArchive.SizeQuotaWarning
Wscript.Echo "Use archive: " & objOutgoingArchive.UseArchive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Outgoing Queue Information

Description
Lists all the outgoing queue information for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objFolder = objFaxServer.Folders
Set objOutgoingQueue = objFolder.OutgoingQueue

Wscript.Echo "Age limit: " & objOutgoingQueue.AgeLimit
Wscript.Echo "Allow personal cover pages: " & _
    objOutgoingQueue.AllowPersonalCoverPages
Wscript.Echo "Blocked: " & objOutgoingQueue.Blocked
Wscript.Echo "Branding: " & objOutgoingQueue.Branding
Wscript.Echo "Discount rate end: " & objOutgoingQueue.DiscountRateEnd
Wscript.Echo "Discount rate start: " & objOutgoingQueue.DiscountRateStart
Wscript.Echo "Paused: " & objOutgoingQueue.Paused
Wscript.Echo "Retries: " & objOutgoingQueue.Retries
Wscript.Echo "Retry delay: " & objOutgoingQueue.RetryDelay
Wscript.Echo "Use Device TSID: " & objOutgoingQueue.UseDeviceTSID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Receipt Options

Description
Lists the receipt options for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objReceiptOptions = objFaxServer.ReceiptOptions

Wscript.Echo "Allowed receipts: " & _
    objReceiptOptions.AllowedReceipts
Wscript.Echo "Authentication type: " & _
    objReceiptOptions.AuthenticationType
Wscript.Echo "SMTP password: " & objReceiptOptions.SMTPPassword
Wscript.Echo "SMTP port: " & objReceiptOptions.SMTPPort
Wscript.Echo "SMTP sender: " & objReceiptOptions.SMTPSender
Wscript.Echo "SMTP server: " & objReceiptOptions.SMTPServer
Wscript.Echo "SMTP user: " & objReceiptOptions.SMTPUser
Wscript.Echo "Use for inbound routing: " & _
    objReceiptOptions.UseForInboundRouting

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Fax Server Security Information

Description
Lists security information and granted rights for the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objSecurity = objFaxServer.Security

Wscript.Echo "Security descriptor: " & objSecurity.Descriptor
Wscript.Echo "Granted rights: " & objSecurity.GrantedRights
Wscript.Echo "Information type: " & objSecurity.InformationType

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Fax Server Activity

Description
Returns information about current activity on the fax server atl-dc-02.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFaxServer = CreateObject("FaxComEx.FaxServer")
objFaxServer.Connect "atl-dc-02"

Set objfaxActivity = objFaxServer.Activity

Wscript.Echo "Incoming messages: " & objFaxActivity.IncomingMessages
Wscript.Echo "Outgoing messages: " & objFaxActivity.OutgoingMessages
Wscript.Echo "Queued messages: " & objFaxActivity.QueuedMessages
Wscript.Echo "Routing messages: " & objFaxActivity.RoutingMessages

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Configuring the Indexing Service to Autostart

Description
Configures the Indexing Service on the local computer to automatically start each time the computer starts. To configure the Indexing Service for manual start, set the parameter passed to the EnableCI method to False rather than True. Manual start is the default setting for the Indexing Service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.EnableCI(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Indexing Service Catalog

Description
Adds an Indexing Service catalog named Script Catalog (with a catalog location of C:\Scripts) to the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Stop()

Set objCatalog = objAdminIS.AddCatalog("Script Catalog","c:\scripts")
objAdminIS.Start()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Indexing Service Scope

Description
Adds a scope named Script Scope (with the path C:\Scripts) to an Indexing Service catalog named Script Catalog on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
Set objCatalog = objAdminIS.GetCatalogByName("Script Catalog")
Set objScope = objCatalog.AddScope("c:\scripts\Indexing Server", False)
objScope.Alias = "Script scope"
objScope.Path = "c:\scripts"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Indexing Service Catalog

Description
Removes an Indexing Service catalog named Script Catalog from the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Stop()
errResult = objAdminIS.RemoveCatalog("Script Catalog", True)
objAdminIS.Start()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Indexing Service Scope

Description
Removes the Indexing Service scope C:\Scripts from the Indexing Service catalog named Script Catalog.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
Set objCatalog = objAdminIS.GetCatalogByName("Script Catalog")
objCatalog.RemoveScope("c:\scripts")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Indexing Service Catalogs

Description
Returns information about all the Indexing Service catalogs available on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objCatalog = objAdminIS.FindFirstCatalog()
If (objCatalog) Then
    Set objCatAdm = objAdminIS.GetCatalog()
    Wscript.Echo "Catalog location: " & objCatAdm.CatalogLocation
    Wscript.Echo "Catalog name: " & objCatAdm.CatalogName
    If (objAdminIS.IsRunning) Then
        Wscript.Echo "Is stopped: " & objCatAdm.IsCatalogStopped
        Wscript.Echo "Is paused: " & objCatAdm.IsCatalogPaused
        Wscript.Echo "Is running: " & objCatAdm.IsCatalogRunning
        Wscript.Echo "Delayed filter count: " & objCatAdm.DelayedFilterCount
        Wscript.Echo "Documents to filter: " & objCatAdm.DocumentsToFilter
        Wscript.Echo "Filtered document count: " & _
            objCatAdm.FilteredDocumentCount
        Wscript.Echo "Fresh test count: " & objCatAdm.FreshTestCount
        Wscript.Echo "Index size: " & objCatAdm.IndexSize
        Wscript.Echo "Percent merge complete: " & objCatAdm.PctMergeComplete
        Wscript.Echo "Pending scan count: " & objCatAdm.PendingScanCount
        Wscript.Echo "Persistent index count: " & _
            objCatAdm.PersistentIndexCount
        Wscript.Echo "Query count: " & objCatAdm.QueryCount
        Wscript.Echo "State info: " & objCatAdm.StateInfo
        Wscript.Echo "Total document count: " & objCatAdm.TotalDocumentCount
        Wscript.Echo "Unique key count: " & objCatAdm.UniqueKeyCount
        Wscript.Echo "Word list count: " & objCatAdm.WordListCount
    End If
End If

Do
    objCatalog = objAdminIS.FindNextCatalog()
    If (objCatalog) Then
        Set objCatAdm = objAdminIS.GetCatalog()
        Wscript.Echo "Catalog location: " & objCatAdm.CatalogLocation
        Wscript.Echo "Catalog name: " & objCatAdm.CatalogName
    If (objAdminIS.IsRunning) Then
        Wscript.Echo "Is stopped: " & objCatAdm.IsCatalogStopped
        Wscript.Echo "Is paused: " & objCatAdm.IsCatalogPaused
        Wscript.Echo "Is running: " & objCatAdm.IsCatalogRunning
        Wscript.Echo "Delayed filter count: " & objCatAdm.DelayedFilterCount
        Wscript.Echo "Documents to filter: " & objCatAdm.DocumentsToFilter
        Wscript.Echo "Filtered document count: " & _
            objCatAdm.FilteredDocumentCount
        Wscript.Echo "Fresh test count: " & objCatAdm.FreshTestCount
        Wscript.Echo "Index size: " & objCatAdm.IndexSize
        Wscript.Echo "Percent merge complete: " & objCatAdm.PctMergeComplete
        Wscript.Echo "Pending scan count: " & objCatAdm.PendingScanCount
        Wscript.Echo "Persistent index count: " & _
            objCatAdm.PersistentIndexCount
        Wscript.Echo "Query count: " & objCatAdm.QueryCount
        Wscript.Echo "State info: " & objCatAdm.StateInfo
        Wscript.Echo "Total document count: " & objCatAdm.TotalDocumentCount
        Wscript.Echo "Unique key count: " & objCatAdm.UniqueKeyCount
        Wscript.Echo "Word list count: " & objCatAdm.WordListCount
        End If
    Else
        Exit Do
   End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Indexing Service Scopes

Description
Returns information about all the Indexing Service scopes found on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objCatalog = objAdminIS.FindFirstCatalog()
If (objCatalog) Then
    Set objCatAdm = objAdminIS.GetCatalog()
    Set objScopeAdm = objCatAdm.GetScope()
    Wscript.Echo "Alias: " & objScopeAdm.Alias
    Wscript.Echo "Exclude scope: " & objScopeAdm.ExcludeScope
    Wscript.Echo "Logon: " & objScopeAdm.Logon
    Wscript.Echo "Path: " & objScopeAdm.Path
    Wscript.Echo "Virtual scope: " & objScopeAdm.VirtualScope
End If

Do
    objCatalog = objAdminIS.FindNextCatalog()
    If (objCatalog) Then
        Set objCatAdm = objAdminIS.GetCatalog()
        Set objScopeAdm = objCatAdm.GetScope()
        Wscript.Echo "Alias: " & objScopeAdm.Alias
        Wscript.Echo "Exclude scope: " & objScopeAdm.ExcludeScope
        Wscript.Echo "Logon: " & objScopeAdm.Logon
        Wscript.Echo "Path: " & objScopeAdm.Path
        Wscript.Echo "Virtual scope: " & objScopeAdm.VirtualScope
    Else
        Exit Do
    End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Specific Files Included in the Indexing Service

Description
Returns a list of all the files included in the Indexing Service catalog named Script Catalog.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "provider=msidxs;"
objConnection.Properties("Data Source") = "Script Catalog"
objConnection.Open

Set objCommand = CreateObject("ADODB.Command")

strQuery = "Select Filename from Scope()"

Set objRecordSet = objConnection.Execute(strQuery)

Do While Not objRecordSet.EOF
    Wscript.Echo objRecordSet("Filename")
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the State of the Indexing Service

Description
Returns information about the current state of the Indexing Service on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
Wscript.Echo "Is running: " & objAdminIS.IsRunning
Wscript.Echo "Is paused: " & objAdminIS.IsPaused
Wscript.Echo "Computer name: " & objAdminIS.MachineName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Indexing Service Filter Performance

Description
Uses cooked performance counters to return information about Indexing Service filter performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, " & _
    "Win32_PerfFormattedData_ContentFilter_IndexingServiceFilter").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Binding Time in Milliseconds: " & _
            objItem.Bindingtimemsec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Indexing Speed, Megabytes Per Hour: " & _
            objItem.IndexingspeedMBPerhr
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Total Indexing Speed, Megabytes Per Hour: " & _
            objItem.TotalindexingspeedMBPerhr
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Indexing Service Performance

Description
Uses cooked performance counters to return information about Indexing Service content index performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService," & _
    "Win32_PerfFormattedData_ContentIndex_IndexingService").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Deferred for Indexing: " & objItem.Deferredforindexing
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Files to be Indexed: " & objItem.Filestobeindexed
        Wscript.Echo "Index Size in Megabytes: " & objItem.IndexsizeMB
        Wscript.Echo "Merge Progress: " & objItem.Mergeprogress
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Number of Documents Indexed: " & _
            objItem.Numberdocumentsindexed
        Wscript.Echo "Running Queries: " & objItem.Runningqueries
        Wscript.Echo "Saved Indexes: " & objItem.Savedindexes
        Wscript.Echo "Total Number of Documents: " & _
            objItem.TotalNumberdocuments
        Wscript.Echo "Total Number of Queries: " & objItem.TotalNumberofqueries
        Wscript.Echo "Unique Keys: " & objItem.Uniquekeys
        Wscript.Echo "Word Lists: " & objItem.Wordlists
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause the Indexing Service

Description
Pauses the Indexing Service on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Pause()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume the Indexing Service

Description
Resumes the Indexing Service on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Continue()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Files Using the Indexing Service

Description
Returns the file name and file size for all files (recorded in the Script Catalog Indexing Service catalog) that contain the term Win32_NetworkAdapterConfiguration.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "provider=msidxs;"
objConnection.Properties("Data Source") = "Script Catalog"
objConnection.Open

Set objCommand = CreateObject("ADODB.Command")

strQuery = "Select Filename, Size, Contents from Scope() Where " _
    & "Contains('Win32_NetworkAdapterConfiguration')"

Set objRecordSet = objConnection.Execute(strQuery)

Do While Not objRecordSet.EOF
    Wscript.Echo objRecordSet("Filename"), objRecordSet("Size")
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search Indexing Server Using a Predefined Query

Description
Uses the predefined query #AllProps to return the file name, file size, and author of all the files included in the Indexing Service catalog Script Catalog on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "provider=msidxs;"
objConnection.Properties("Data Source") = "Script Catalog"
objConnection.Open

Set objCommand = CreateObject("ADODB.Command")

strQuery = "Create View #AllProps as Select * from Scope()"

Set objRecordSet = objConnection.Execute("Select * from Extended_FileInfo")

Do While Not objRecordSet.EOF
    Wscript.Echo objRecordSet("Filename") & ", " & objRecordSet("Size") & _
        ", " & objRecordSet("DocAuthor")
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search the Indexing Service Using a Free Text Search

Description
Uses a free text search to return the file name and file size for all files in the Indexing Service catalog Script Catalog that include the term Win32_NetworkAdapterConfiguration.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = "provider=msidxs;"
objConnection.Properties("Data Source") = "Script Catalog"
objConnection.Open

Set objCommand = CreateObject("ADODB.Command")

strQuery = "Select Filename, Size, Contents from Scope() Where " _
    & "Freetext('Win32_NetworkAdapterConfiguration')"

Set objRecordSet = objConnection.Execute(strQuery)

Do While Not objRecordSet.EOF
    Wscript.Echo objRecordSet("Filename"), objRecordSet("Size")
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start the Indexing Service

Description
Starts the Indexing Service on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Start()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop the Indexing Service

Description
Stops the Indexing Service on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objAdminIS = CreateObject("Microsoft.ISAdm")
objAdminIS.Stop()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Software

Description
Uninstalls a hypothetical software program (Personnel database) installed using Windows Installer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Personnel database'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Software on a Remote Computer

Description
Installs a hypothetical software program (using a Windows Installer package) on a remote computer. Requires delegation for the computer and user accounts involved in the procedure.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const wbemImpersonationLevelDelegate = 4

Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objConnection = objwbemLocator.ConnectServer _
    ("WebServer", "root\cimv2", "fabrikam\administrator", _
         "password", , "kerberos:WebServer")
objConnection.Security_.ImpersonationLevel = wbemImpersonationLevelDelegate

Set objSoftware = objConnection.Get("Win32_Product")
errReturn = objSoftware.Install("\\atl-dc-02\scripts\1561_lab.msi",,True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Software on the Local Computer

Description
Installs a hypothetical software program (using a Windows Installer package) on a local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS = True

Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("c:\scripts\database.msi", , ALL_USERS)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Information About the Binary Files Used by an Application

Description
Returns the name and product code of binary information (such as bitmaps, icons, executable files, and so on) used by a Windows Installer application.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Binary")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Product Code: " & objItem.ProductCode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Installed or Advertised Components and Applications

Description
Returns a list of all Windows Installer components installed or advertised on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_ApplicationService")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Installed Software

Description
Returns a list of software that was installed on a computer using Windows Installer. This information is then written to a text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\scripts\software.tsv", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _
    "Description" & vbtab & "Identifying Number" & vbtab & _
    "Install Date" & vbtab & "Install Location" & vbtab & _
    "Install State" & vbtab & "Name" & vbtab & _
    "Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
        & "Version"

For Each objSoftware in colSoftware
    objTextFile.WriteLine objSoftware.Caption & vbtab & _
    objSoftware.Description & vbtab & _
    objSoftware.IdentifyingNumber & vbtab & _
    objSoftware.InstallDate2 & vbtab & _
    objSoftware.InstallLocation & vbtab & _
    objSoftware.InstallState & vbtab & _
    objSoftware.Name & vbtab & _
    objSoftware.PackageCache & vbtab & _
    objSoftware.SKUNumber & vbtab & _
    objSoftware.Vendor & vbtab & _
    objSoftware.Version
Next
objTextFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Installed Software Features

Description
Returns a list of features for all the software installed on a computer using Windows Installer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFeatures = objWMIService.ExecQuery _
    ("Select * from Win32_SoftwareFeature")

For Each objFeature in colfeatures
    Wscript.Echo "Accesses: " & objFeature.Accesses
    Wscript.Echo "Attributes: " & objFeature.Attributes
    Wscript.Echo "Caption: " & objFeature.Caption
    Wscript.Echo "Description: " & objFeature.Description
    Wscript.Echo "Identifying Number: " & objFeature.IdentifyingNumber
    Wscript.Echo "Install Date: " & objFeature.InstallDate
    Wscript.Echo "Install State: " & objFeature.InstallState
    Wscript.Echo "Last Use: " & objFeature.LastUse
    Wscript.Echo "Name: " & objFeature.Name
    Wscript.Echo "Product Name: " & objFeature.ProductName
    Wscript.Echo "Vendor: " & objFeature.Vendor
    Wscript.Echo "Version: " & objFeature.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Microsoft Product IDs

Description
Returns the Product IDs for Microsoft software products installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objMSInfo = CreateObject("MsPIDinfo.MsPID")
colMSApps = objMSInfo.GetPIDInfo()

For Each strApp in colMSApps
    Wscript.Echo strApp
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Codec Files on a Computer

Description
Uses WMI to return information about all the audio and video codec files installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_CodecFile")

For Each objItem in colItems
    Wscript.Echo "Access Mask: " & objItem.AccessMask
    Wscript.Echo "Archive: " & objItem.Archive
    Wscript.Echo "Caption: " & objItem.Caption
    strCreationDate = WMIDateStringToDate(objItem.CreationDate)
    Wscript.Echo "Creation Date: " & strCreationdate
    Wscript.Echo "Drive: " & objItem.Drive
    Wscript.Echo "Eight Dot Three File Name: " & _
        objItem.EightDotThreeFileName
    Wscript.Echo "Extension: " & objItem.Extension
    Wscript.Echo "File Name: " & objItem.FileName
    Wscript.Echo "File Size: " & objItem.FileSize
    Wscript.Echo "File Type: " & objItem.FileType
    Wscript.Echo "File System Name: " & objItem.FSName
    Wscript.Echo "Group: " & objItem.Group
    Wscript.Echo "Hidden: " & objItem.Hidden
    strInstallDate = WMIDateStringToDate(objItem.InstallDate)
    Wscript.Echo "Last Accessed: " & strLastAccessed
    strLastModified = WMIDateStringToDate(objItem.LastModified)
    Wscript.Echo "Last Modified: " & strLastModified
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Version: " & objItem.Version
Next

Function WMIDateStringToDate(dtmDate)
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
        Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
            & " " & Mid (dtmDate, 9, 2) & ":" & _
                Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate, _
                    13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Upgrade Software

Description
Upgrades a hypothetical software program installed using Windows Installer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32__Product Where Name = 'Personnel Database'")

For Each objSoftware in colSoftware
    errReturn = objSoftware.Upgrade("c:\scripts\database2.msi")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Local Computer Information

Description
Uses the Shell object to return basic configuration information for the local computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objComputer = CreateObject("Shell.LocalMachine")

Wscript.Echo "Computer name: " & objComputer.MachineName
Wscript.Echo "Shutdown allowed: " & objComputer.IsShutdownAllowed
Wscript.Echo "Friendly UI enabled: " & objComputer.IsFriendlyUIEnabled
Wscript.Echo "Guest access mode: " & objComputer.IsGuestAccessMode
Wscript.Echo "Guest account enabled: " & _
    objComputer.IsGuestEnabled(0)
Wscript.Echo "Multiple users enabled: " & _
    objComputer.IsMultipleUsersEnabled
Wscript.Echo "Offline files enabled: " & _
    objComputer.IsOfflineFilesEnabled
Wscript.Echo "Remote connections enabled: " & _
    objComputer.IsRemoteConnectionsEnabled
Wscript.Echo "Undock enabled: " & objComputer.IsUndockEnabled

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify That SQL Server is Installed on a Computer

Description
Indicates whether SQL Server is running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where Name = 'MSSQLServer'")

If colServices.Count > 0 Then
    For Each objService in colServices
        Wscript.Echo "SQL Server is " & objService.State & "."
    Next
Else
    Wscript.Echo "SQL Server is not installed on this computer."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Web Site to the Favorites Menu

Description
Adds a shortcut to msdn.microsoft.com to the Internet Favorites folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Const ADMINISTRATIVE_TOOLS = 6

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)
Set objFolderItem = objFolder.Self

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objFolderItem.Path
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\MSDN.url")
objURLShortcut.TargetPath = "http://msdn.microsoft.com"
objURLShortcut.Save

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Sites to an Internet Explorer Security Zone

Description
Adds the Web site Contoso.com to the Trusted sites zone and BenefitsWeb to the Local intranet zone on a computer running Internet Explorer Enhanced Security Configuration.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\ESCDomains\Contoso.com"
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strValueName = "http"
dwValue = 2
objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\ESCDomains\BenefitsWeb"
objReg.CreateKey HKEY_CURRENT_USER,strKeyPath
strValueName = "*"
dwValue = 1
objReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Site from an Internet Explorer Security Zone

Description
Deletes the site Contoso.com from an Internet Explorer security zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\ESCDomains\Contoso.com"
objReg.DeleteKey HKEY_CURRENT_USER, strKeyPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Allowed Protocol from an Internet Explorer Security Zone Site

Description
Deletes the http protocol from the Finance site in an Internet Explorer security zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\ESCDomains\Finance"
strDWORDValueName = "http"

objReg.DeleteValue HKEY_CURRENT_USER,strKeyPath,strDWORDValueName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Connection Summary Information

Description
Returns basic connection information (including whether HTTP 1.1 has been enabled) for Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_ConnectionSummary")

For Each strIESetting in colIESettings
    Wscript.Echo "Connection preference: " & _
        strIESetting.ConnectionPreference
    Wscript.Echo "HTTP 1.1. enabled: " & strIESetting.EnableHTTP11
    Wscript.Echo "Proxy HTTP 1.1. enabled: " & strIESetting.ProxyHTTP11
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Audited Internet Explorer Events from the Security Log

Description
Retrieves audited Internet Explorer events from the Security event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set dtmDate = CreateObject("WbemScripting.SWbemDateTime")
Set objWMIService = GetObject("winmgmts:" _
    & "{(Security)}!\\" & strComputer & "\root\cimv2")
Set colLoggedEvents = objWMIService.ExecQuery _
        ("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'Security' AND " _
            & "EventCode = '560'")

For Each objEvent in colLoggedEvents
    errResult = _
        InStr(objEvent.Message,"\REGISTRY\MACHINE\SOFTWARE\Microsoft\")
    If errResult <> 0 Then
        Select Case objEvent.EventType
            Case 4 strEventType = "Success"
            Case 5 strEventType = "Failure"
        End Select
        Wscript.Echo objEvent.User
        dtmDate.Value = objEvent.TimeWritten
        dtmTimeWritten = dtmDate.GetVarDate
        Wscript.Echo "Time written: " & dtmTimeWritten
        Wscript.Echo strEventType
        Wscript.Echo "Record number: " & objEvent.RecordNumber & VbCrLf
        Wscript.Echo objEvent.Message
        Wscript.Echo
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Cache Settings

Description
Returns configuration settings for the Internet Explorer cache.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Cache")

For Each strIESetting in colIESettings
    Wscript.Echo "Page refresh type: " & strIESetting.PageRefreshType
    Wscript.Echo "Temporary Internet files folder: " & _
        strIESetting.TempInternetFilesFolder
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer COM Object Settings

Description
Returns basic COM class information for Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Object")

For Each strIESetting in colIESettings
    Wscript.Echo "Code base: " & strIESetting.CodeBase
    Wscript.Echo "Program file: " & strIESetting.ProgramFile
    Wscript.Echo "Status: " & strIESetting.Status
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Connection Settings

Description
Returns information about Internet Explorer connection settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_ConnectionSettings")

For Each strIESetting in colIESettings
    Wscript.Echo "Allow Internet programs: " & _
        strIESetting.AllowInternetPrograms
    Wscript.Echo "Autoconfiguration URL: " & strIESetting.AutoConfigURL
    Wscript.Echo "Auto disconnect: " & strIESetting.AutoDisconnect
    Wscript.Echo "Autoconfiguration proxy detection mode: " & _
        strIESetting.AutoProxyDetectMode
    Wscript.Echo "Data encryption: " & strIESetting.DataEncryption
    Wscript.Echo "Default: " & strIESetting.Default
    Wscript.Echo "Default gateway: " & strIESetting.DefaultGateway
    Wscript.Echo "Dialup server: " & strIESetting.DialUpServer
    Wscript.Echo "Disconnect idle time: " & strIESetting.DisconnectIdleTime
    Wscript.Echo "Encrypted password: " & strIESetting.EncryptedPassword
    Wscript.Echo "IP address: " & strIESetting.IPAddress
    Wscript.Echo "IP header compression: " & _
        strIESetting.IPHeaderCompression
    Wscript.Echo "Modem: " & strIESetting.Modem
    Wscript.Echo "Name: " & strIESetting.Name
    Wscript.Echo "Network logon: " & strIESetting.NetworkLogon
    Wscript.Echo "Network protocols: " & strIESetting.NetworkProtocols
    Wscript.Echo "Primary DNS server: " & strIESetting.PrimaryDNS
    Wscript.Echo "Primary WINS server: " & strIESetting.PrimaryWINS
    Wscript.Echo "Proxy: " & strIESetting.Proxy
    Wscript.Echo "Proxy override: " & strIESetting.ProxyOverride
    Wscript.Echo "Proxy server: " & strIESetting.ProxyServer
    Wscript.Echo "Redial attempts: " & strIESetting.RedialAttempts
    Wscript.Echo "Redial wait: " & strIESetting.RedialWait
    Wscript.Echo "Script fileame: " & strIESetting.ScriptFileName
    Wscript.Echo "Secondary DNS server: " & strIESetting.SecondaryDNS
    Wscript.Echo "Secondary WINS server: " & strIESetting.SecondaryWINS
    Wscript.Echo "Server assigned IP address: " & _
        strIESetting.ServerAssignedIPAddress
    Wscript.Echo "Server assigned name server: " & _
        strIESetting.ServerAssignedNameServer
    Wscript.Echo "Software compression: " & strIESetting.SoftwareCompression
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer File Version Information

Description
Returns basic file version information for Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_FileVersion")

For Each strIESetting in colIESettings
    Wscript.Echo "Company: " & strIESetting.Company
    Wscript.Echo "Date: " & strIESetting.Date
    Wscript.Echo "File name: " & strIESetting.File
    Wscript.Echo "Path: " & strIESetting.Path
    Wscript.Echo "File size: " & strIESetting.Size
    Wscript.Echo "Version: " & strIESetting.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer LAN Settings

Description
Returns network information (including proxy server information) for Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_LANSettings")

For Each strIESetting in colIESettings
    Wscript.Echo "Autoconfiguration proxy: " & strIESetting.AutoConfigProxy
    Wscript.Echo "Autoconfiguration URL: " & strIESetting.AutoConfigURL
    Wscript.Echo "Autoconfiguration Proxy detection mode: " & _
        strIESetting.AutoProxyDetectMode
    Wscript.Echo "Proxy: " & strIESetting.Proxy
    Wscript.Echo "Proxy override: " & strIESetting.ProxyOverride
    Wscript.Echo "Proxy server: " & strIESetting.ProxyServer
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Security Setting Values

Description
Demonstration script that indicates whether scripting is enabled in the Internet Explorer Local Intranet zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
strEntry = "1400"

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "Zones\1"
objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strEntry, dwValue

Select Case dwValue
    Case 0 strSetting = "Enabled"
    Case 1 strSetting = "Prompt"
    case 3 strSetting = "Disabled"
End Select

Wscript.Echo "Allow scripting: " & strSetting

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Security Zone Settings

Description
Retrieves the current setting level for each Internet Explorer security zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Security")

For Each strIESetting in colIESettings
    Wscript.Echo "Zone name: " & strIESetting.Zone
    Wscript.Echo "Security level: " & strIESetting.Level
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Internet Explorer Summary Settings

Description
Returns basic information (including version number and build number) for Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\cimv2\Applications\MicrosoftIE")

Set colIESettings = objWMIService.ExecQuery _
    ("Select * from MicrosoftIE_Summary")

For Each strIESetting in colIESettings
    Wscript.Echo "Active printer: " & strIESetting.ActivePrinter
    Wscript.Echo "Build: " & strIESetting.Build
    Wscript.Echo "Cipher strength: " & strIESetting.CipherStrength
    Wscript.Echo "Content advisor: " & strIESetting.ContentAdvisor
    Wscript.Echo "IE Administration Kit installed: " & _
        strIESetting.IEAKInstall
    Wscript.Echo "Language: " & strIESetting.Language
    Wscript.Echo "Name: " & strIESetting.Name
    Wscript.Echo "Path: " & strIESetting.Path
    Wscript.Echo "Product ID: " & strIESetting.ProductID
    Wscript.Echo "Version: " & strIESetting.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Sites in Internet Explorer Security Zones

Description
Lists all the sites in the Internet Explorer security zones on a computer running IE Enhanced Security Configuration.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "ZoneMap\ESCDomains"
objReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
    strNewPath = strKeyPath & "\" & subkey
    ShowSubkeys
Next

Sub ShowSubkeys
    arrPath = Split(strNewPath, "\")
    intSiteName = Ubound(arrPath)
    strSiteName = arrPath(intSiteName)
    objReg.EnumValues HKEY_CURRENT_USER, strNewPath, arrEntries, arrValueTypes

    If Not IsArray(arrEntries) Then
        arrPath = Split(strNewPath, "\")
        intSiteName = Ubound(arrPath)
        strSiteName = arrPath(intSiteName)
        Wscript.Echo strsitename
            objReg.EnumKey HKEY_CURRENT_USER, strNewPath, arrSubKeys2

        For Each subkey In arrSubKeys2
            strNewPath2 = strNewPath & "\" & subkey
            arrPath = Split(strNewPath2, "\")
            intSiteName = Ubound(arrPath)
            strSiteName = arrPath(intSiteName)
            objReg.EnumValues HKEY_CURRENT_USER, strNewPath2, arrEntries2,_
                arrValueTypes

            For i = 0 to Ubound(arrEntries2)
                objReg.GetDWORDValue HKEY_CURRENT_USER, strNewPath2, _
                    arrEntries2(i),dwValue
            Next

            Select Case dwValue
                Case 0 strZone = "My Computer"
                Case 1 strZone = "Local Intranet zone"
                Case 2 strZone = "Trusted Sites Zone"
                Case 3 strZone = "Internet Zone"
                Case 4 strZone = "Restricted Sites Zone"
            End Select

            Wscript.Echo vbtab & strSiteName & " -- " & strZone
       Next
    End If

    For i = 0 to Ubound(arrEntries)
        objReg.GetDWORDValue HKEY_CURRENT_USER, strNewPath, _
            arrEntries(i),dwValue
    Next

    Select Case dwValue
        Case 0 strZone = "My Computer"
        Case 1 strZone = "Local Intranet zone"
        Case 2 strZone = "Trusted Sites Zone"
        Case 3 strZone = "Internet Zone"
        Case 4 strZone = "Restricted Sites Zone"
    End Select

    Wscript.Echo strSiteName & " -- " & strZone

End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Advanced Internet Explorer Settings

Description
Demonstration script that disables the Download Complete message box that typically appears after downloading a file using Internet Explorer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
strValue = "no"

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Internet Explorer\Main"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, _
    "NotifyDownloadComplete",strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Internet Explorer Advanced Settings

Description
Demonstration script that indicates whether the Internet Explorer Enhanced Security Configuration dialog box is displayed each time IE starts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
strEntry = "DisplayTrustAlertDlg"

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Internet Explorer\Main"
objReg.GetDWORDValue HKEY_CURRENT_USER, strKeyPath, strEntry ,dwValue

If dwValue = 1 Then
    Wscript.Echo "Enhanced security dialog box is displayed."
Else
    Wscript.Echo "Enhanced security dialog box is not displayed."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Internet Explorer Security Settings

Description
Demonstration script that enables scripting for sites in the Internet Explorer Local Intranet zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\" _
    & "Zones\1"
strEntryName = "1400"
dwvalue = 0
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strEntryName,dwValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Internet Explorer Security Changes

Description
Issues an alert any time an audited Internet Explorer setting is changed and recorded in the Security event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{"{impersonationLevel=impersonate,(Security)}!\\" & strComputer & _
        "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA " _
        & "'Win32_NTLogEvent' AND TargetInstance.EventCode = '560' AND " _
            & "TargetInstance.Logfile = 'Security' GROUP WITHIN 2")
Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
        strAlertToSend = "Internet Explorer security settings have been " & _
            "changed."
        Wscript.Echo strAlertToSend
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Internet Explorer Enhanced Security Configuration Status

Description
Reports the status of Internet Explorer Enhanced Security Configuration on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Active Setup\Installed Components\" _
    & "{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
strValueName = "IsInstalled"
objReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intAdmin

strKeyPath = "SOFTWARE\Microsoft\Active Setup\Installed Components\" _
    & "{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
strValueName = "IsInstalled"
objReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,intUsers

strConfiguration = intAdmin & intUsers
Select Case strConfiguration
    Case "00"
        Wscript.Echo "The use of Internet Explorer is not restricted on " _
            & "this server."
    Case "01"
        Wscript.Echo "The use of Internet Explorer is restricted for the " _
           & "administrators group on this server. The use of Internet " _
           & "Explorer is not restricted for any other user group."
    Case "10"
        Wscript.Echo "The use of Internet Explorer is not restricted for the" _
            & " administrators group on this server. The use of Internet " _
            & "Explorer is restricted for any other user group."
    Case "11"
        Wscript.Echo "The use of Internet Explorer is restricted for all " _
            & "user groups on this server."
End Select

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Whether Internet Explorer Enhanced Security is Enabled for the Logged-on User

Description
Indicates whether Internet Explorer Enhanced Security (IE hardening) is enabled for the current user of a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."
Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet " _
    & "Settings\ZoneMap"
strValueName = "IEHarden"
objReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,intHarden

If intHarden = 1 Then
    Wscript.Echo "IE hardening is turned on for the current user."
Else
    Wscript.Echo "IE hardening is not turned on for the current user."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Logon Session Information

Description
Returns information about logon sessions associated with the user currently logged on to a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_LogonSession")

For Each objItem in colItems
    Wscript.Echo "Authentication Package: " & objItem.AuthenticationPackage
    Wscript.Echo "Logon ID: " & objItem.LogonId
    Wscript.Echo "Logon Type: " & objItem.LogonType
    Wscript.Echo "Start Time: " & objItem.StartTime
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the User Logged on to a Remote Computer

Description
Returns the user name of the user currently logged on to a remote computer. To use this script, replace atl-ws-01 with the name of the remote computer you want to check. Although this script will run on Windows NT 4.0, Windows 98, and Windows 2000, it will not always return information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-o1"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
    Wscript.Echo "Logged-on user: " & objComputer.UserName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Passport Information

Description
Returns information about the .NET passport for the user currently logged-on to a computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = CreateObject("UserAccounts.PassportManager")
Wscript.Echo "Current Passport: " & objUser.CurrentPassport
Wscript.Echo "Member services URL: " & objUser.MemberServicesURL

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Administrative Tools Folder

Description
Reports the path to the Administrative Tools folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADMINISTRATIVE_TOOLS = &H2f&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the All Users Application Data Folder

Description
Reports the path to the All Users Application Data folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS_APPLICATION_DATA = &H23&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the All Users Desktop Folder

Description
Reports the path to the All Users Desktop folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS_DESKTOP = &H19&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_DESKTOP)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the All Users Programs Folder

Description
Reports the path to the All Users Programs folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS_PROGRAMS = &H17&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_PROGRAMS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the All Users Start Menu Folder

Description
Reports the path to the All Users Start Menu folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS_START_MENU = &H16&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_START_MENU)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the All Users Startup Folder

Description
Reports the path to the All Users Startup folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ALL_USERS_STARTUP = &H18&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ALL_USERS_STARTUP)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Application Data Folder

Description
Reports the path to the Application Data folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const APPLICATION_DATA = &H1a&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(APPLICATION_DATA)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Common Files Folder

Description
Reports the path to the Common Files folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const COMMON_FILES = &H2b&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(COMMON_FILES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Control Panel Folder

Description
Reports the path to the Windows Control Panel, and then lists the individual applications installed. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const CONTROL_PANEL = &H3&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(CONTROL_PANEL)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Desktop Folder

Description
Reports the path to the Desktop folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const DESKTOP = &H10&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESKTOP)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Fonts Folder

Description
Reports the path to the Fonts folder, and then lists any fonts found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FONTS = &H14&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FONTS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Internet Cookies Folder

Description
Reports the path to the Internet Cookies folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const COOKIES = &H21&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(COOKIES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Internet Favorites Folder

Description
Reports the path to the Internet Favorites folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FAVORITES = &H6&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FAVORITES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Local Application Data Folder

Description
Reports the path to the Local Application Data folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const LOCAL_APPLICATION_DATA = &H1c&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(LOCAL_APPLICATION_DATA)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the My Computer Folder

Description
Reports the path to My Computer, and then lists any items found there. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_COMPUTER = &H11&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the My Documents Folder

Description
Reports the path to the My Documents folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_DOCUMENTS = &H5&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_DOCUMENTS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the My Music Folder

Description
Reports the path to the My Music folder, and then lists any items found in that folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MY_MUSIC = &Hd&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_MUSIC)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the My Network Places Folder

Description
Reports the path to the My network Places folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_NETWORK_PLACES = &H12&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_NETWORK_PLACES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the My Videos Folder

Description
Reports the path to the My Videos folder, and then lists any items found in that folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MY_VIDEOS = &He&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_VIDEOS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Network Connections Folder

Description
Reports the path to the Network Connections folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const NETWORK_CONNECTIONS = &H31&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETWORK_CONNECTIONS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Print Neighborhood Folder

Description
Reports the path to the Print Neighborhood folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const PRINTHOOD = &H1b&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(PRINTHOOD)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Printers and Faxes Folder

Description
Reports the path to the Printers and Faxes folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const PRINTERS_AND_FAXES = &H4&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(PRINTERS_AND_FAXES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Program Files Folder

Description
Reports the path to the Program Files folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const PROGRAM_FILES = &H26&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(PROGRAM_FILES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Programs Folder

Description
Reports the path to the Recycle Bin, and then lists any items found there. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const PROGRAMS = &H2&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(PROGRAMS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Recycle Bin Folder

Description
Reports the path to the Recycle Bin, and then lists any items found there. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const RECYCLE_BIN = &Ha&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the SendTo Folder

Description
Reports the path to the SendTo folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SENDTO = &H9&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(SENDTO)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Start Menu Folder

Description
Reports the path to the Start Menu folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const START_MENU = &Hb&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(START_MENU)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Startup Folder

Description
Reports the path to the Startup folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const STARTUP = &H7&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(STARTUP)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the System32 Folder

Description
Reports the path to the System32 folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const SYSTEM32 = &H25&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(SYSTEM32)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Templates Folder

Description
Reports the path to the Templates folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const TEMPLATES = &H15&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TEMPLATES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Temporary Internet Files Folder

Description
Reports the path to the Temporary Internet Files folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const TEMPORARY_INTERNET_FILES = &H20&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TEMPORARY_INTERNET_FILES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the User Profile Folder

Description
Reports the path to the logged-on user's User Profiles folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const USER_PROFILE = &H28&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(USER_PROFILE)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Items in the Windows Folder

Description
Reports the path to the Windows folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const WINDOWS = &H24&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(WINDOWS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Items in the Internet Explorer History Folder

Description
Reports the path to the Internet Explorer History folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const LOCAL_SETTINGS_HISTORY = &H22&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(LOCAL_SETTINGS_HISTORY)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Items in the My Pictures Folder

Description
Reports the path to the My Pictures folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_PICTURES = &H27&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_PICTURES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Items in the My Recent Documents Folder

Description
Reports the path to the My Recent Documents folder, and then lists any items found in that folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_RECENT_DOCUMENTS = &H8&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_RECENT_DOCUMENTS)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Items in the Network Neighborhood Folder

Description
Reports the path to the Network Neighborhood, and then lists any items found there. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const NETHOOD = &H13&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(NETHOOD)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

Set colItems = objFolder.Items
For Each objItem in colItems
    Wscript.Echo objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Path to the Internet Explorer Folder

Description
Reports the path to the Internet Explorer special folder. For Windows NT 4.0 and Windows 98, this script requires Windows Script Host 5.1 and Internet Explorer 4.0 or later.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const INTERNET_EXPLORER = &H1&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(INTERNET_EXPLORER)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Path

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Startup Commands

Description
Enumerates all startup commands on a computer, including those found in the Startup folder and those found in the Registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colStartupCommands = objWMIService.ExecQuery _
    ("Select * from Win32_StartupCommand")

For Each objStartupCommand in colStartupCommands
    Wscript.Echo "Command: " & objStartupCommand.Command
    Wscript.Echo "Description: " & objStartupCommand.Description
    Wscript.Echo "Location: " & objStartupCommand.Location
    Wscript.Echo "Name: " & objStartupCommand.Name
    Wscript.Echo "Setting ID: " & objStartupCommand.SettingID
    Wscript.Echo "User: " & objStartupCommand.User
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Startup Options

Description
Returns a list of startup options for a computer, including the startup delay time and other information found in Boot.ini.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colStartupCommands = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objStartupCommand in colStartupCommands
    Wscript.Echo "Reset Boot Enabled: " & _
        objStartupCommand.AutomaticResetBootOption
    Wscript.Echo "Reset Boot Possible: " & _
        objStartupCommand.AutomaticResetCapability
    Wscript.Echo "Boot State: " & objStartupCommand.BootupState
    Wscript.Echo "Startup Delay: " & objStartupCommand.SystemStartupDelay
    For i = 0 to Ubound(objStartupCommand.SystemStartupOptions)
        Wscript.Echo "Startup Options: " & _
            objStartupCommand.SystemStartupOptions(i)
    Next
    Wscript.Echo "Startup Setting: " & _
        objStartupCommand.SystemStartupSetting
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Recovery Configuration Options

Description
Returns a list of settings that indicate the action to be taken by a computer should a stop event (blue screen) occur.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRecoveryOptions = objWMIService.ExecQuery _
    ("Select * from Win32_OSRecoveryConfiguration")

For Each objOption in colRecoveryOptions
    Wscript.Echo "Auto reboot: " & objOption.AutoReboot
    Wscript.Echo "Debug File Path: " & objOption.DebugFilePath
    Wscript.Echo "Debug Info Type: " & objOption.DebugInfoType
    Wscript.Echo "Kernel Dump Only: " & objOption.KernelDumpOnly
    Wscript.Echo "Name: " & objOption.Name
    Wscript.Echo "Overwrite Existing Debug File: " & _
        objOption.OverwriteExistingDebugFile
    Wscript.Echo "Send Administrative Alert: " & objOption.SendAdminAlert
    Wscript.Echo "Write Debug Information: " & objOption.WriteDebugInfo
    Wscript.Echo "Write to System Log: " & objOption.WriteToSystemLog
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Boot Configuration Properties of a Computer

Description
Returns boot configuration information for a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BootConfiguration")

For Each objItem in colItems
    Wscript.Echo "Boot Directory: " & objItem.BootDirectory
    Wscript.Echo "Configuration Path: " & objItem.ConfigurationPath
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Last Drive: " & objItem.LastDrive
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Scratch Directory: " & objItem.ScratchDirectory
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Temp Directory: " & objItem.TempDirectory
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Recovery Configuration Options

Description
Configures a computer to do a complete memory dump to the file C:\Scripts\memory.dmp should a stop event (blue screen) occur.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const COMPLETE_MEMORY_DUMP = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRecoveryOptions = objWMIService.ExecQuery _
    ("Select * from Win32_OSRecoveryConfiguration")

For Each objOption in colRecoveryOptions
    objOption.DebugInfoType = COMPLETE_MEMORY_DUMP
    objOption.DebugFilePath = "c:\scripts\memory.dmp"
    objOption.OverWriteExistingDebugFile = False
    objOption.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify System Startup Delay

Description
Configures a computer to wait 10 seconds (instead of the default 30 seconds) before automatically loading the default operating system upon startup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colStartupCommands = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objStartupCommand in colStartupCommands
    objStartupCommand.SystemStartupDelay = 10
    objStartupCommand.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restart a Computer

Description
Restarts a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-dc-01"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
        strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Shut Down a Computer

Description
Shuts down a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject_
    ("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & _
        strComputer & "\root\cimv2")

Set colOperating Systems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Win32Shutdown(1)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Conduct a System Restore

Description
Performs a system restore on a computer using system restore point No. 20. To perform a system restore using a different system restore point, simply change the value of the constant RESTORE_POINT.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const RESTORE_POINT = 20

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.Restore(RESTORE_POINT)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a System Restore Point

Description
Creates a new system restore point on a computer, specifying that the restore point was created prior to installing a new device driver.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

CONST DEVICE_DRIVER_INSTALL = 10
CONST BEGIN_SYSTEM_CHANGE = 100

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.CreateRestorePoint _
    ("Scripted restore", DEVICE_DRIVER_INSTALL, BEGIN_SYSTEM_CHANGE)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable Full System Restore

Description
Disables system restore on a computer. This is equivalent to selecting the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.Disable("")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Full System Restore

Description
Enables system restore on a computer. This is equivalent to clearing the checkbox Turn off System Restore (found by right-clicking My Computer, clicking Properties, and then clicking on the System Restore tab in the resulting dialog box).

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.Enable("")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Existing Restore Points

Description
Returns a list of all system restore points stored on a computer, as well as detailed information about each of those restore points.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set colItems = objWMIService.ExecQuery("Select * from SystemRestore")
If colItems.Count = 0 Then
    WScript.Echo "No restore point in system."
Else
    For Each objItem in colItems
        Wscript.Echo "Name: " & objItem.Description
        Wscript.Echo "Number: " & objItem.SequenceNumber
        Select Case objItem.RestorePointType
      Case 0 strRestoreType = "Application installation"
            Case 1 strRestoreType = "Application uninstall"
            Case 6 strRestoreType = "Restore"
            Case 7 strRestoreType = "Checkpoint"
            Case 10 strRestoreType = "Device drive installation"
            Case 11 strRestoreType = "First run"
            Case 12 strRestoreType = "Modify settings"
            Case 13 strRestoreType = "Cancelled operation"
            Case 14 strRestoreType = "Backup recovery"
            Case Else strRestoreType = "Unknown"
        End Select
        Wscript.Echo "Restore Point Type: " & strRestoreType

        dtmConvertedDate.Value = objItem.CreationTime
        dtmCreationTime = dtmConvertedDate.GetVarDate
        Wscript.Echo "Time: " & dtmCreationTime
     Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List System Restore Configuration Values

Description
Displays the current system restore configuration settings on a computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set colItems = objWMIService.ExecQuery("Select * from SystemRestoreConfig")

For Each objItem in colItems
    Wscript.Echo "Disk Percent: " & objItem.DiskPercent
    Wscript.Echo "Global Interval (in seconds): " & objItem.RPGlobalInterval
    Wscript.Echo "Life Interval (in seconds): " & objItem.RPLifeInterval
    If objItem.RPSessionInterval = 0 Then
        Wscript.Echo "Session Interval: Feature not enabled."
    Else
        Wscript.Echo "Session Interval (in seconds): " & _
            objItem.RPSessionInterval
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Results of the Last System Restore

Description
Returns the results (failed, succeeded, interrupted) of the last system restore performed on a computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestore")
errResults = objItem.GetLastRestoreStatus()

Select Case errResults
    Case 0 strRestoreStatus = "The last restore failed."
    Case 1 strRestoreStatus = "The last restore was successful."
    Case 2 strRestoreStatus = "The last restore was interrupted."
End Select

Wscript.Echo strRestoreStatus

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify System Restore Configuration Values

Description
Modifies the system restore configuration values on a computer, setting the global interval to 100,000 seconds; the life interval to 8,000,000 seconds; and the session interval to 500,000 seconds.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const GLOBAL_INTERVAL_IN_SECONDS = 100000
Const LIFE_INTERVAL_IN_SECONDS = 8000000
Const SESSION_INTERVAL_IN_SECONDS = 500000

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objItem = objWMIService.Get("SystemRestoreConfig='SR'")
objItem.DiskPercent = 10
objItem.RPGlobalInterval = GLOBAL_INTERVAL_IN_SECONDS
objItem.RPLifeInterval = LIFE_INTERVAL_IN_SECONDS
objItem.RPSessionInterval = SESSION_INTERVAL_IN_SECONDS
objItem.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Activate Windows Offline

Description
Uses the offline method to activate Windows. Requires a valid activation number.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWindowsProducts = objWMIService.ExecQuery _
    ("Select * from Win32_WindowsProductActivation")

For Each objWindowsProduct in colWindowsProducts
    objWindowsProduct.ActivateOffline("1234-1234")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Activate Windows Online

Description
Uses the online method to activate Windows. Requires an active Internet connection.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWindowsProducts = objWMIService.ExecQuery _
    ("Select * from Win32_WindowsProductActivation")

For Each objWindowsProduct in colWindowsProducts
    objWindowsProduct.ActivateOnline()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Windows Product Activation Status

Description
Returns product activation information for a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWPA = objWMIService.ExecQuery _
    ("Select * from Win32_WindowsProductActivation")

For Each objWPA in colWPA
    Wscript.Echo "Activation Required: " & objWPA.ActivationRequired
    Wscript.Echo "Description: " & objWPA.Description
    Wscript.Echo "Product ID: " & objWPA.ProductID
    Wscript.Echo "Remaining Evaluation Period: " & _
        objWPA.RemainingEvaluationPeriod
    Wscript.Echo "Remaining Grace Period: " & objWPA.RemainingGracePeriod
    Wscript.Echo "Server Name: " & objWPA.ServerName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Suppress Windows Activation Notices

Description
Suppresses the Windows Activation reminder notices on a computer. This does not preclude the need to activate the computer; it simply prevents users from seeing the periodic reminders.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWPASettings = objWMIService.ExecQuery _
    ("Select * from Win32_WindowsProductActivation")

For Each objWPASetting in colWPASettings
    objWPASetting.SetNotification(0)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add “Command Prompt Here” to Windows Explorer

Description
Adds a Command Prompt Here command to the Windows Explorer system menu. If a user selects Command Prompt Here from the system menu, a command window will be displayed, open to the same folder as the current Windows Explorer folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objShell = CreateObject("WScript.Shell")

objShell.RegWrite "HKCR\Folder\Shell\MenuText\Command\", _
    "cmd.exe /k cd " & chr(34) & "%1" & chr(34)
objShell.RegWrite "HKCR\Folder\Shell\MenuText\", "Command Prompt Here"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Template to the Windows Explorer New Menu

Description
Demonstrates how to add VBScript Script File to the New context menu in Windows Explorer. Requires a script template named Template.vbs to be in the \Windows\System32\ShellExt folder (on Windows XP and Windows Server 2003), or in the \Winnt\ShellNew folder (Windows 2000).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.RegWrite "HKCR\.VBS\ShellNew\FileName","template.vbs"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Desktop Settings

Description
Lists the current desktop settings on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Desktop")

For Each objItem in colItems
    Wscript.Echo "Border Width: " & objItem.BorderWidth
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Cool Switch: " & objItem.CoolSwitch
    Wscript.Echo "Cursor Blink Rate: " & objItem.CursorBlinkRate
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Drag Full Windows: " & objItem.DragFullWindows
    Wscript.Echo "Grid Granularity: " & objItem.GridGranularity
    Wscript.Echo "Icon Spacing: " & objItem.IconSpacing
    Wscript.Echo "Icon Title Face Name: " & objItem.IconTitleFaceName
    Wscript.Echo "Icon Title Size: " & objItem.IconTitleSize
    Wscript.Echo "Icon Title Wrap: " & objItem.IconTitleWrap
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Pattern: " & objItem.Pattern
    Wscript.Echo "Screen Saver Active: " & objItem.ScreenSaverActive
    Wscript.Echo "Screen Saver Executable: " & _
        objItem.ScreenSaverExecutable
    Wscript.Echo "Screen Saver Secure: " & objItem.ScreenSaverSecure
    Wscript.Echo "Screen Saver Timeout: " & objItem.ScreenSaverTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Wallpaper: " & objItem.Wallpaper
    Wscript.Echo "Wallpaper Stretched: " & objItem.WallpaperStretched
    Wscript.Echo "Wallpaper Tiled: " & objItem.WallpaperTiled
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Environment Variables on a Computer

Description
Uses WMI to return information about all the environment variables on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "System Variable: " & objItem.SystemVariable
    Wscript.Echo "User Name: " & objItem.UserName
    Wscript.Echo "Variable Value: " & objItem.VariableValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Installed Administrative Tools

Description
Uses the Shell object to enumerate all the Administrative Tools installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ADMINISTRATIVE_TOOLS = &H2f&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(ADMINISTRATIVE_TOOLS)
Set objTools = objFolder.Items

For i = 0 to objTools.Count - 1
    Wscript.Echo objTools.Item(i)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Path to the My Pictures Folders

Description
Uses the Shell object to return the path to the My Pictures folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const MY_PICTURES = &H27&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_PICTURES)
Set objFolderItem = objFolder.Self
Wscript.Echo objFolderItem.Name & ": " & objFolderItem.Path

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Shortcuts on a Computer

Description
Uses WMI to return a list of all the shortcuts on a computer, as well as such properties as the file name, creation date, and target for each shortcut.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShortcutFile")

For Each objItem in colItems
    strCreationDate = WMIDateStringToDate(objItem.CreationDate)
    Wscript.Echo "Creation Date: " & strCreationDate
    Wscript.Echo "Drive: " & objItem.Drive
    Wscript.Echo "Eight Dot Three File Name: " & _
        objItem.EightDotThreeFileName
    Wscript.Echo "Extension: " & objItem.Extension
    Wscript.Echo "File Name: " & objItem.FileName
    Wscript.Echo "File Size: " & objItem.FileSize
    Wscript.Echo "File Type: " & objItem.FileType
    Wscript.Echo "File System Name: " & objItem.FSName
    Wscript.Echo "Hidden: " & objItem.Hidden
    strLastAccessed = WMIDateStringToDate(objItem.LastAccessed)
    Wscript.Echo "Last Accessed: " & strLastAccessed
    strLastModified = WMIDateStringToDate(objItem.LastModified)
    Wscript.Echo "Last Modified: " & strLastModified
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Target: " & objItem.Target
Next

Function WMIDateStringToDate(dtmDate)
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
        Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
            & " " & Mid (dtmDate, 9, 2) & ":" & _
                Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate, _
                    13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Start Menu Items

Description
Returns a list of all the Start menu items found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalProgramGroupItem")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Start Menu Program Groups

Description
Retrieves information about all the Start menu program groups currently in use on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ProgramGroup")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Group Name: " & objItem.GroupName
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "User Name: " & objItem.UserName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename the My Computer Icon on the Local Computer

Description
Renames the My Computer icon on the local computer, giving it the same name as the computer itself.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MY_COMPUTER = &H11&

Set objNetwork = CreateObject("Wscript.Network")
objComputerName = objNetwork.ComputerName
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
objFolderItem.Name = objComputerName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy Scopes of Management

Description
Returns information about the Scope of Management (SOM) used in applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_SOM")

For Each objItem in colItems
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Blocked: " & objItem.Blocked
    Wscript.Echo "Blocking: " & objItem.Blocking
    Wscript.Echo "Reason: " & objItem.Reason
    Wscript.Echo "SOM Order: " & objItem.SOMOrder
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy Security Event Log Settings -- Boolean

Description
Returns information about access to event logs assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_SecurityEventLogSettingBoolean")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Setting: " & objItem.Setting
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy Security Event Log Settings -- Numeric

Description
Returns information about event log settings (such as maximum log size) assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_SecurityEventLogSettingNumeric")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Setting: " & objItem.Setting
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy Security Settings -- Boolean

Description
Returns information about account policy settings (such as password policy settings and account lockout policy settings) assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_SecuritySettingBoolean")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Setting: " & objItem.Setting
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy Security Settings -- Numeric

Description
Returns information about account policy settings assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_SecuritySettingNumeric")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Setting: " & objItem.Setting
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Resultant Set of Policy System Services

Description
Returns information about the service settings (including startup mode and access permissions) assigned to a computer by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_SystemService")

For Each objItem in colItems
    Wscript.Echo "Service: " & objItem.Service
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "SDDL String: " & objItem.SDDLString
    Wscript.Echo "Startup Mode: " & objItem.StartupMode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy Administrative Template Files

Description
Returns information about the administrative template files (.ADM files) used in applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_AdministrativeTemplateFile")

For Each objItem in colItems
    Wscript.Echo "GPO ID: " & objItem.GPOID
    dtmConvertedDate.Value = objItem.LastWriteTime
    dtmCreationTime = dtmConvertedDate.GetVarDate
    Wscript.Echo "Last Write Time: " & dtmCreationTime
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy Audit Policies

Description
Returns information about auditing privileges assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_AuditPolicy")

For Each objItem in colItems
    Wscript.Echo "Category: " & objItem.Category
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Failure: " & objItem.Failure
    Wscript.Echo "Success: " & objItem.Success
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy GPOs

Description
Returns information about Group Policy Objects used in applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_GPO")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "GUID Name: " & objItem.GUIDName
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Access Denied: " & objItem.AccessDenied
    Wscript.Echo "Enabled: " & objItem.Enabled
    Wscript.Echo "File System path: " & objItem.FileSystemPath
    Wscript.Echo "Filter Allowed: " & objItem.FilterAllowed
    Wscript.Echo "Filter ID: " & objItem.FilterId
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy Group Policy Extension Status

Description
Returns information about client-side processing of Group Policy extensions. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_ExtensionStatus")

For Each objItem in colItems
    Wscript.Echo "Display name: " & objItem.DisplayName
    dtmConvertedDate.Value = objItem.BeginTime
    dtmTime = dtmConvertedDate.GetVarDate
    Wscript.Echo "Begin time: " & dtmTime
    dtmConvertedDate.Value = objItem.EndTime
    dtmTime = dtmConvertedDate.GetVarDate
    Wscript.Echo "End time: " & dtmTime
    Wscript.Echo "Error: " & objItem.Error
    Wscript.Echo "Extension GUID: " & objItem.ExtensionGuid
    Wscript.Echo "Logging Status: " & objItem.LoggingStatus
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy Group Policy Links

Description
Returns information about Group Policy links used in applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_GPLink")

For Each objItem in colItems
    Wscript.Echo "GPO: " & objItem.GPO
    Wscript.Echo "Applied Order: " & objItem.AppliedOrder
    Wscript.Echo "Enabled: " & objItem.Enabled
    Wscript.Echo "Link Order: " & objItem.LinkOrder
    Wscript.Echo "No Overrride: " & objItem.NoOverride
    Wscript.Echo "SOM Order: " & objItem.SOMOrder
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy Policy Settings

Description
Returns information about policy object settings used in applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_PolicySetting")

For Each objItem in colItems
    Wscript.Echo "GPO ID: " & objItem.GPOID
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "SOM ID: " & objItem.SOMID
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Resultant Set of Policy User Privilege Rights

Description
Returns information about user privileges assigned by using Group Policy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_UserPrivilegeRight")

For Each objItem in colItems
    For Each strAccountList in objItem.AccountList
        Wscript.Echo "Account list: " & strAccountList
    Next
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "User Right: " & objItem.UserRight
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List RSOP Application Management Policy Settings

Description
Returns information about application management extension policies assigned to a computer by using Group Policy. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery _
    ("Select * from RSOP_ApplicationManagementPolicySetting")

For Each objItem in colItems
    Wscript.Echo "Allow X86 on IA64: " & objItem.AllowX86OnIA64
    Wscript.Echo "Application ID: " & objItem.ApplicationId
    Wscript.Echo "Apply Cause: " & objItem.ApplyCause
    Wscript.Echo "Assignment Type: " & objItem.AssignmentType
    Wscript.Echo "Categories: " & objItem.Categories
    Wscript.Echo "Demand Installable: " & objItem.DemandInstallable
    Wscript.Echo "Deployment Last Modify Time: " & _
        objItem.DeploymentLastModifyTime
    Wscript.Echo "Deployment Type: " & objItem.DeploymentType
    Wscript.Echo "Display in Add/Remove Programs: " & objItem.DisplayInARP
    Wscript.Echo "Eligibility: " & objItem.Eligibility
    Wscript.Echo "Entry Type: " & objItem.EntryType
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Ignore Language: " & objItem.IgnoreLanguage
    Wscript.Echo "Installation UI: " & objItem.InstallationUI
    Wscript.Echo "Language ID: " & objItem.LanguageId
    Wscript.Echo "Language Match: " & objItem.LanguageMatch
    Wscript.Echo "Loss of Scope Action: " & objItem.LossOfScopeAction
    For Each strArchitecture in objItem.MachineArchitectures
        Wscript.Echo "Machine Architecture: " & strArchitecture
    Next
    Wscript.Echo "On-demand CLSID: " & objItem.OnDemandClsid
    Wscript.Echo "On-demand File Extension: " & objItem.OnDemandFileExtension
    Wscript.Echo "On-demand ProgID: " & objItem.OnDemandProgId
    Wscript.Echo "Package Location: " & objItem.PackageLocation
    Wscript.Echo "Package Type: " & objItem.PackageType
    Wscript.Echo "Precedence: " & objItem.Precedence
    Wscript.Echo "Precedence Reason: " & objItem.PrecedenceReason
    Wscript.Echo "Product ID: " & objItem.ProductId
    Wscript.Echo "Publisher: " & objItem.Publisher
    Wscript.Echo "Redeploy Count: " & objItem.RedeployCount
    Wscript.Echo "Removal Cause: " & objItem.RemovalCause
    Wscript.Echo "Removal Type: " & objItem.RemovalType
    Wscript.Echo "Removing Application: " & objItem.RemovingApplication
    Wscript.Echo "Replaceable Applications: " & objItem.ReplaceableApplications
    Wscript.Echo "Script File: " & objItem.ScriptFile
    Wscript.Echo "Support URL: " & objItem.SupportURL
    Wscript.Echo "Transforms: " & objItem.Transforms
    Wscript.Echo "Uninstall Unmanaged: " & objItem.UninstallUnmanaged
    Wscript.Echo "Upgradeable Applications: " & objItem.UpgradeableApplications
    Wscript.Echo "Upgrade Settings Mandatory: " & _
        objItem.UpgradeSettingsMandatory
    Wscript.Echo "Version Number (High): " & objItem.VersionNumberHi
    Wscript.Echo "Version Number (Low): " & objItem.VersionNumberLo
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List RSOP Sessions

Description
Returns information about the resultant set of policy session used when applying Group Policy to a computer. To return information about Group Policy applied to the logged-on user, change the WMI class from root\rsop\computer to root\rsop\user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\rsop\computer")

Set colItems = objWMIService.ExecQuery("Select * from RSOP_Session")

For Each objItem in colItems
    Wscript.Echo "ID: " & objItem.ID
    dtmConvertedDate.Value = objItem.CreationTime
    dtmTime = dtmConvertedDate.GetVarDate
    Wscript.Echo "Creation Time: " & dtmTime
    Wscript.Echo "Flags: " & objItem.Flags
    For Each strSecurityGroup in objItem.SecurityGroups
        Wscript.Echo "Security group: " & strSecurityGroup
    Next
    Wscript.Echo "Site: " & objItem.Site
    Wscript.Echo "Slow Link: " & objItem.SlowLink
    Wscript.Echo "SOM: " & objItem.SOM
    Wscript.Echo "Target Name: " & objItem.TargetName
    Wscript.Echo "TTL (Minutes): " & objItem.TTLMinutes
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating IRQ Settings

Description
Returns information about the IRQ settings on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_IRQResource")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Hardware: " & objItem.Hardware
    Wscript.Echo "IRQ Number: " & objItem.IRQNumber
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Trigger Level: " & objItem.TriggerLevel
    Wscript.Echo "Trigger Type: " & objItem.TriggerType
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Onboard Devices

Description
Returns information about devices built into the motherboard installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_OnBoardDevice")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device Type: " & objItem.DeviceType
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Tag: " & objItem.Tag
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating Processor Information

Description
Returns information about the processors installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem in colItems
    Wscript.Echo "Address Width: " & objItem.AddressWidth
    Wscript.Echo "Architecture: " & objItem.Architecture
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "CPU Status: " & objItem.CpuStatus
    Wscript.Echo "Current Clock Speed: " & objItem.CurrentClockSpeed
    Wscript.Echo "Data Width: " & objItem.DataWidth
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "External Clock: " & objItem.ExtClock
    Wscript.Echo "Family: " & objItem.Family
    Wscript.Echo "L2 Cache Size: " & objItem.L2CacheSize
    Wscript.Echo "L2 Cache Speed: " & objItem.L2CacheSpeed
    Wscript.Echo "Level: " & objItem.Level
    Wscript.Echo "Load Percentage: " & objItem.LoadPercentage
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Clock Speed: " & objItem.MaxClockSpeed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Processor ID: " & objItem.ProcessorId
    Wscript.Echo "Processor Type: " & objItem.ProcessorType
    Wscript.Echo "Revision: " & objItem.Revision
    Wscript.Echo "Role: " & objItem.Role
    Wscript.Echo "Socket Designation: " & objItem.SocketDesignation
    Wscript.Echo "Status Information: " & objItem.StatusInfo
    Wscript.Echo "Stepping: " & objItem.Stepping
    Wscript.Echo "Unique Id: " & objItem.UniqueId
    Wscript.Echo "Upgrade Method: " & objItem.UpgradeMethod
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Voltage Caps: " & objItem.VoltageCaps
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Identifying Computer Chassis Type

Description
Retrieves an integer value indicating the chassis type for a computer (mini-tower, laptop, etc.). The script does not include a description of each value that can be returned.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colChassis = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")

For Each objChassis in colChassis
    For i = Lbound(objChassis.ChassisTypes) to Ubound(objChassis.ChassisTypes)
        Wscript.Echo objChassis.ChassisTypes(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Identifying Processor Type

Description
Determines the processor architecture (such as x86 or ia64) for a specified computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessors = objWMIService.ExecQuery _
    ("Select * From Win32_Processor")

For Each objProcessor in colProcessors
    If objProcessor.Architecture = 0 Then
        Wscript.Echo "This is an x86 computer."
    ElseIf objProcessor.Architecture = 1 Then
        Wscript.Echo "This is a MIPS computer."
    ElseIf objProcessor.Architecture = 2 Then
        Wscript.Echo "This is an Alpha computer."
    ElseIf objProcessor.Architecture = 3 Then
        Wscript.Echo "This is a PowerPC computer."
    ElseIf objProcessor.Architecture = 6 Then
        Wscript.Echo "This is an ia64 computer."
    Else
        Wcript.Echo "The computer type could not be determined."
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Baseboard Properties

Description
Returns information about the computer baseboard.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard")

For Each objItem in colItems
    For Each strOption in objItem.ConfigOptions
        Wscript.Echo "Configuration Option: " & strOption
    Next
    Wscript.Echo "Depth: " & objItem.Depth
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Height: " & objItem.Height
    Wscript.Echo "Hosting Board: " & objItem.HostingBoard
    Wscript.Echo "Hot Swappable: " & objItem.HotSwappable
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Other Identifying Information: " & _
        objItem.OtherIdentifyingInfo
    Wscript.Echo "Part Number: " & objItem.PartNumber
    Wscript.Echo "Powered-On: " & objItem.PoweredOn
    Wscript.Echo "Product: " & objItem.Product
    Wscript.Echo "Removable: " & objItem.Removable
    Wscript.Echo "Replaceable: " & objItem.Replaceable
    Wscript.Echo "Requirements Description: " & objItem.RequirementsDescription
    Wscript.Echo "Requires Daughterboard: " & objItem.RequiresDaughterBoard
    Wscript.Echo "Serial Number: " & objItem.SerialNumber
    Wscript.Echo "SKU: " & objItem.SKU
    Wscript.Echo "Slot Layout: " & objItem.SlotLayout
    Wscript.Echo "Special Requirements: " & objItem.SpecialRequirements
    Wscript.Echo "Tag: " & objItem.Tag
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Weight: " & objItem.Weight
    Wscript.Echo "Width: " & objItem.Width
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Bus Properties

Description
Returns information about the computer bus.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Bus")

For Each objItem in colItems
    Wscript.Echo "Bus Number: " & objItem.BusNum
    Wscript.Echo "Bus Type: " & objItem.BusType
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Motherboard Device Information

Description
Retrieves information about the motherboard device installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_MotherboardDevice")

For Each objItem in colItems
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Primary Bus Type: " & objItem.PrimaryBusType
    Wscript.Echo "Secondary Bus Type: " & objItem.SecondaryBusType
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMBIOS Information

Description
Retrieves part number, serial number, and asset tag number from SMBIOS-compliant computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSMBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_SystemEnclosure")

For Each objSMBIOS in colSMBIOS
    Wscript.Echo "Part Number: " & objSMBIOS.PartNumber
    Wscript.Echo "Serial Number: " & objSMBIOS.SerialNumber
    Wscript.Echo "Asset Tag: " & objSMBIOS.SMBIOSAssetTag
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Retrieving BIOS Information

Description
Retrieves BIOS information for a computer, including BIOS version number and release date.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")

For each objBIOS in colBIOS
    Wscript.Echo "Build Number: " & objBIOS.BuildNumber
    Wscript.Echo "Current Language: " & objBIOS.CurrentLanguage
    Wscript.Echo "Installable Languages: " & objBIOS.InstallableLanguages
    Wscript.Echo "Manufacturer: " & objBIOS.Manufacturer
    Wscript.Echo "Name: " & objBIOS.Name
    Wscript.Echo "Primary BIOS: " & objBIOS.PrimaryBIOS
    Wscript.Echo "Release Date: " & objBIOS.ReleaseDate
    Wscript.Echo "Serial Number: " & objBIOS.SerialNumber
    Wscript.Echo "SMBIOS Version: " & objBIOS.SMBIOSBIOSVersion
    Wscript.Echo "SMBIOS Major Version: " & objBIOS.SMBIOSMajorVersion
    Wscript.Echo "SMBIOS Minor Version: " & objBIOS.SMBIOSMinorVersion
    Wscript.Echo "SMBIOS Present: " & objBIOS.SMBIOSPresent
    Wscript.Echo "Status: " & objBIOS.Status
    Wscript.Echo "Version: " & objBIOS.Version
    For i = 0 to Ubound(objBIOS.BiosCharacteristics)
        Wscript.Echo "BIOS Characteristics: " & _
            objBIOS.BiosCharacteristics(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Retrieving Computer Fan Information

Description
Retrieves information about the cooling fans installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Fan")

For Each objItem in colItems
    Wscript.Echo "Active Cooling: " & objItem.ActiveCooling
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Status Information: " & objItem.StatusInfo
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Battery Information

Description
Returns information about all batteries connected to a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Battery")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Battery Status: " & objItem.BatteryStatus
    Wscript.Echo "Chemistry: " & objItem.Chemistry
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Design Voltage: " & objItem.DesignVoltage
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Estimated Run Time: " & objItem.EstimatedRunTime
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Power Management Capabilities: "
    For Each objElement In objItem.PowerManagementCapabilities
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Power Management Supported: " & _
        objItem.PowerManagementSupported
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Portable Battery Information

Description
Returns information about any portable battery (such as the batteries used to power laptop computers) in use on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PortableBattery")

For Each objItem in colItems
    Wscript.Echo "Capacity Multiplier: " & objItem.CapacityMultiplier
    Wscript.Echo "Chemistry: " & objItem.Chemistry
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Design Capacity: " & objItem.DesignCapacity
    Wscript.Echo "Design Voltage: " & objItem.DesignVoltage
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Location: " & objItem.Location
    dtmWMIDate = objItem.ManufactureDate
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Manufacture Date: " & strReturn
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Battery Error: " & objItem.MaxBatteryError
    Wscript.Echo "Smart Battery Version: " & objItem.SmartBatteryVersion
    Wscript.Echo
Next

Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
        WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
            Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
                & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                    Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate,13, 2))
    End If
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Cache Memory Information

Description
Returns information about both the internal and external cache memory on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_CacheMemory")

For Each objItem in colItems
    Wscript.Echo "Access: " & objItem.Access
    Wscript.Echo "Additional Error Data: "
    For Each objElement In objItem.AdditionalErrorData
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Associativity: " & objItem.Associativity
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Block Size: " & objItem.BlockSize
    Wscript.Echo "Cache Speed: " & objItem.CacheSpeed
    Wscript.Echo "Cache Type: " & objItem.CacheType
    Wscript.Echo "Current SRAM: "
    For Each objElement In objItem.CurrentSRAM
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Error Correct Type: " & objItem.ErrorCorrectType
    Wscript.Echo "Installed Size: " & objItem.InstalledSize
    Wscript.Echo "Level: " & objItem.Level
    Wscript.Echo "Location: " & objItem.Location
    Wscript.Echo "Maximum Cache Size: " & objItem.MaxCacheSize
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number Of Blocks: " & objItem.NumberOfBlocks
    Wscript.Echo "Status Information: " & objItem.StatusInfo
    Wscript.Echo "Supported SRAM: "
    For Each objElement In objItem.SupportedSRAM
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Write Policy: " & objItem.WritePolicy
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Device Memory Addresses

Description
Returns starting and ending memory addresses for all devices installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_DeviceMemoryAddress")

For Each objItem in colItems
    Wscript.Echo "Ending Address: " & objItem.EndingAddress
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Starting Address: " & objItem.StartingAddress
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DMA Channel Information

Description
Returns information about the configuration of DMA channels on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_DMAChannel")

For Each objItem in colItems
    Wscript.Echo "Address Size: " & objItem.AddressSize
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Byte Mode: " & objItem.ByteMode
    Wscript.Echo "Channel Timing: " & objItem.ChannelTiming
    Wscript.Echo "DMA Channel: " & objItem.DMAChannel
    Wscript.Echo "Maximum Transfer Size: " & objItem.MaxTransferSize
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Type C Timing: " & objItem.TypeCTiming
    Wscript.Echo "Word Mode: " & objItem.WordMode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Memory Array Information

Description
Returns starting and ending addresses for all memory arrays installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_MemoryArray")

For Each objItem in colItems
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Ending Address: " & objItem.EndingAddress
    Wscript.Echo "Starting Address: " & objItem.StartingAddress
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Memory Devices

Description
Returns starting and ending addresses for all memory devices installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_MemoryDevice")

For Each objItem in colItems
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Ending Address: " & objItem.EndingAddress
    Wscript.Echo "Starting Address: " & objItem.StartingAddress
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Physical Memory Properties

Description
Returns information about the physical memory installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_PhysicalMemoryArray")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Maximum Capacity: " & objItem.MaxCapacity
    Wscript.Echo "Memory Devices: " & objItem.MemoryDevices
    Wscript.Echo "Memory Error Correction: " & objItem.MemoryErrorCorrection
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Physical Memory Configuration

Description
Returns information about the way physical memory is configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory")

For Each objItem in colItems
    Wscript.Echo "Bank Label: " & objItem.BankLabel
    Wscript.Echo "Capacity: " & objItem.Capacity
    Wscript.Echo "Data Width: " & objItem.DataWidth
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device Locator: " & objItem.DeviceLocator
    Wscript.Echo "Form Factor: " & objItem.FormFactor
    Wscript.Echo "Hot Swappable: " & objItem.HotSwappable
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Memory Type: " & objItem.MemoryType
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Part Number: " & objItem.PartNumber
    Wscript.Echo "Position In Row: " & objItem.PositionInRow
    Wscript.Echo "Speed: " & objItem.Speed
    Wscript.Echo "Tag: " & objItem.Tag
    Wscript.Echo "Type Detail: " & objItem.TypeDetail
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Available Memory

Description
Uses cooked performance counters to issue an alert if available memory on a computer falls below 4 megabytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set objMemory = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").objectSet
objRefresher.Refresh

Do
    For Each intAvailableBytes in objMemory
        If intAvailableBytes.AvailableMBytes < 4 Then
            Wscript.Echo "Available memory has fallen below 4 megabytes."
        End If
    Next
    objRefresher.Refresh
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Cache Performance

Description
Uses cooked performance counters to monitor the file system cache, an area of physical memory that stores recently used data as long as possible to permit access to the data without having to read from the disk.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Cache").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Asynchronous Copy Reads Per Second: " & _
            objItem.AsyncCopyReadsPersec
        Wscript.Echo "Asynchronous Data Maps Per Second: " & _
            objItem.AsyncDataMapsPersec
        Wscript.Echo "Asynchronous Fast Reads Per Second: " & _
            objItem.AsyncFastReadsPersec
        Wscript.Echo "Asynchronous MDL Reads Per Second: " & _
            objItem.AsyncMDLReadsPersec
        Wscript.Echo "Asynchronous Pin Reads Per Second: " & _
            objItem.AsyncPinReadsPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Copy Read Hits Percent: " & objItem.CopyReadHitsPercent
        Wscript.Echo "Copy Reads Per Second: " & objItem.CopyReadsPersec
        Wscript.Echo "Data Flushes Per Second: " & objItem.DataFlushesPersec
        Wscript.Echo "Data Flush Pages Per Second: " & _
            objItem.DataFlushPagesPersec
        Wscript.Echo "Data Map Hits Percent: " & objItem.DataMapHitsPercent
        Wscript.Echo "Data Map Pins Per Second: " & objItem.DataMapPinsPersec
        Wscript.Echo "Data Maps Per Second: " & objItem.DataMapsPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Fast Read Not Possibles Per Second: " & _
            objItem.FastReadNotPossiblesPersec
        Wscript.Echo "Fast Read Resource Misses Per Second: " & _
            objItem.FastReadResourceMissesPersec
        Wscript.Echo "Fast Reads Per Second: " & objItem.FastReadsPersec
        Wscript.Echo "Lazy Write Flushes Per Second: " & _
            objItem.LazyWriteFlushesPersec
        Wscript.Echo "Lazy Write Pages Per Second: " & _
            objItem.LazyWritePagesPersec
        Wscript.Echo "MDL Read Hits Percent: " & objItem.MDLReadHitsPercent
        Wscript.Echo "MDL Reads Per Second: " & objItem.MDLReadsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Pin Read Hits Percent: " & objItem.PinReadHitsPercent
        Wscript.Echo "Pin Reads Per Second: " & objItem.PinReadsPersec
        Wscript.Echo "Read Aheads Per Second: " & objItem.ReadAheadsPersec
        Wscript.Echo "Synchronous Copy Reads Per Second: " & _
            objItem.SyncCopyReadsPersec
        Wscript.Echo "Synchronous Data Maps Per Second: " & _
            objItem.SyncDataMapsPersec
        Wscript.Echo "Synchronous Fast Reads Per Second: " & _
            objItem.SyncFastReadsPersec
        Wscript.Echo "Synchronous MDL Reads Per Second: " & _
            objItem.SyncMDLReadsPersec
        Wscript.Echo "Synchronous Pin Reads Per Second: " & _
            objItem.SyncPinReadsPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Changes in Computer Power Status

Description
Issues an alert if a computer changes power state (for example, enters or leaves suspend mode).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("Select * from Win32_PowerManagementEvent")

Do
    Set strLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo strLatestEvent.EventType
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Memory Performance

Description
Uses cooked performance counters to monitor physical and virtual memory on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Available Bytes: " & objItem.AvailableBytes
        Wscript.Echo "Available Kilobytes: " & objItem.AvailableKBytes
        Wscript.Echo "Available Megabytes: " & objItem.AvailableMBytes
        Wscript.Echo "Cache Bytes: " & objItem.CacheBytes
        Wscript.Echo "Cache Bytes Peak: " & objItem.CacheBytesPeak
        Wscript.Echo "Cache Faults Per Second: " & objItem.CacheFaultsPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Commit Limit: " & objItem.CommitLimit
        Wscript.Echo "Committed Bytes: " & objItem.CommittedBytes
        Wscript.Echo "Demand Zero Faults Per Second: " & _
            objItem.DemandZeroFaultsPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Free System Page Table Entries: " & _
            objItem.FreeSystemPageTableEntries
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Page Faults Per Second: " & objItem.PageFaultsPersec
        Wscript.Echo "Page Reads Per Second: " & objItem.PageReadsPersec
        Wscript.Echo "Pages Input Per Second: " & objItem.PagesInputPersec
        Wscript.Echo "Pages Output Per Second: " & objItem.PagesOutputPersec
        Wscript.Echo "Pages Per Second: " & objItem.PagesPersec
        Wscript.Echo "Page Writes Per Second: " & objItem.PageWritesPersec
        Wscript.Echo "Percent Committed Bytes In Use: " & _
            objItem.PercentCommittedBytesInUse
        Wscript.Echo "Pool Nonpaged Allocations: " & objItem.PoolNonpagedAllocs
        Wscript.Echo "Pool Nonpaged Bytes: " & objItem.PoolNonpagedBytes
        Wscript.Echo "Pool Paged Allocations: " & objItem.PoolPagedAllocs
        Wscript.Echo "Pool Paged Bytes: " & objItem.PoolPagedBytes
        Wscript.Echo "Pool Paged Resident Bytes: " & _
            objItem.PoolPagedResidentBytes
        Wscript.Echo "System Cache Resident Bytes: " & _
            objItem.SystemCacheResidentBytes
        Wscript.Echo "System Code Resident Bytes: " & _
            objItem.SystemCodeResidentBytes
        Wscript.Echo "System Code Total Bytes: " & objItem.SystemCodeTotalBytes
        Wscript.Echo "System Driver Resident Bytes: " & _
            objItem.SystemDriverResidentBytes
        Wscript.Echo "System Driver Total Bytes: " & _
            objItem.SystemDriverTotalBytes
        Wscript.Echo "Transition Faults Per Second: " & _
            objItem.TransitionFaultsPersec
        Wscript.Echo "Write Copies Per Second: " & objItem.WriteCopiesPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Processor Performance

Description
Uses cooked performance counters to monitor processor activity.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Processor").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "C1 Transitions Per Second: " & _
            objItem.C1TransitionsPersec
        Wscript.Echo "C2 Transitions Per Second: " & _
            objItem.C2TransitionsPersec
        Wscript.Echo "C3 Transitions Per Second: " & _
            objItem.C3TransitionsPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "DPC Rate: " & objItem.DPCRate
        Wscript.Echo "DPCs Queued Per Second: " & objItem.DPCsQueuedPersec
        Wscript.Echo "Interrupts Per Second: " & objItem.InterruptsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent C1 Time: " & objItem.PercentC1Time
        Wscript.Echo "Percent C2 Time: " & objItem.PercentC2Time
        Wscript.Echo "Percent C3 Time: " & objItem.PercentC3Time
        Wscript.Echo "Percent DPC Time: " & objItem.PercentDPCTime
        Wscript.Echo "Percent Idle Time: " & objItem.PercentIdleTime
        Wscript.Echo "Percent Interrupt Time: " & objItem.PercentInterruptTime
        Wscript.Echo "Percent Privileged Time: " & _
            objItem.PercentPrivilegedTime
        Wscript.Echo "Percent Processor Time: " & objItem.PercentProcessorTime
        Wscript.Echo "Percent User Time: " & objItem.PercentUserTime
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Processor Use

Description
Uses cooked performance counters to monitor processor use on a computer. Triggers an alert if processor use exceeds 90 percent on 10 successive measurements (measured at 6-second intervals).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.Swbemrefresher")
Set objProcessor = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Processor").objectSet
intThresholdViolations = 0
objRefresher.Refresh

Do
    For Each intProcessorUse in objProcessor
        If intProcessorUse.PercentProcessorTime > 90 Then
            intThresholdViolations = intThresholdViolations + 1
                If intThresholdViolations = 10 Then
                    intThresholdViolations = 0
                    Wscript.Echo "Processor usage threshold exceeded."
                End If
        Else
            intThresholdViolations = 0
        End If
    Next
    Wscript.Sleep 6000
    objRefresher.Refresh
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Computer Availability

Description
Uses the Win32_PingStatus class to verify that a computer is accessible over the network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPingedComputers = objWMIService.ExecQuery _
    ("Select * from Win32_PingStatus Where Address = '192.168.1.37'")

For Each objComputer in colPingedComputers
    If objComputer.StatusCode = 0 Then
        Wscript.Echo "Remote computer responded."
    Else
        Wscript.Echo "Remote computer did not respond."
   End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify System Uptime

Description
Calculates system uptime; that is, the number of hours a computer has been running since its last restart.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOS in colOperatingSystems
    dtmBootup = objOS.LastBootUpTime
    dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
    dtmSystemUptime = DateDiff("h", dtmLastBootUpTime, Now)
    Wscript.Echo dtmSystemUptime
Next

Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
        Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
            & " " & Mid (dtmBootup, 9, 2) & ":" & _
                Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Keyboard Properties

Description
Returns information about the keyboard connected to a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Keyboard")
For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Is Locked: " & objItem.IsLocked
    Wscript.Echo "Layout: " & objItem.Layout
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number of Function Keys: " & objItem.NumberOfFunctionKeys
    Wscript.Echo "Password: " & objItem.Password
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Modem Information

Description
Retrieves information about all the modems installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_POTSModem")

For Each objItem in colItems
    Wscript.Echo "Attached To: " & objItem.AttachedTo
    Wscript.Echo "Blind Off: " & objItem.BlindOff
    Wscript.Echo "Blind On: " & objItem.BlindOn
    Wscript.Echo "Compression Off: " & objItem.CompressionOff
    Wscript.Echo "Compression On: " & objItem.CompressionOn
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Configuration Dialog: " & objItem.ConfigurationDialog
    Wscript.Echo "Country Selected: " & objItem.CountrySelected
    Wscript.Echo "DCB: "
    For Each objElement In objItem.DCB
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Default: "
    For Each objElement In objItem.Default
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Type: " & objItem.DeviceType
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Error Control Forced: " & objItem.ErrorControlForced
    Wscript.Echo "Error Control Off: " & objItem.ErrorControlOff
    Wscript.Echo "Error Control On: " & objItem.ErrorControlOn
    Wscript.Echo "Flow Control Hard: " & objItem.FlowControlHard
    Wscript.Echo "Flow Control Off: " & objItem.FlowControlOff
    Wscript.Echo "Flow Control Soft: " & objItem.FlowControlSoft
    Wscript.Echo "Inactivity Scale: " & objItem.InactivityScale
    Wscript.Echo "Inactivity Timeout: " & objItem.InactivityTimeout
    Wscript.Echo "Index: " & objItem.Index
    Wscript.Echo "Maximum Baud Rate To SerialPort: " & _
        objItem.MaxBaudRateToSerialPort
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Modem INF Path: " & objItem.ModemInfPath
    Wscript.Echo "Modem INF Section: " & objItem.ModemInfSection
    Wscript.Echo "Modulation Bell: " & objItem.ModulationBell
    Wscript.Echo "Modulation CCITT: " & objItem.ModulationCCITT
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Port SubClass: " & objItem.PortSubClass
    Wscript.Echo "Prefix: " & objItem.Prefix
    Wscript.Echo "Properties: "
    For Each objElement In objItem.Properties
        WScript.Echo vbTab & objElement
    Next
    Wscript.Echo "Provider Name: " & objItem.ProviderName
    Wscript.Echo "Pulse: " & objItem.Pulse
    Wscript.Echo "Reset: " & objItem.Reset
    Wscript.Echo "Responses Key Name: " & objItem.ResponsesKeyName
    Wscript.Echo "Speaker Mode Dial: " & objItem.SpeakerModeDial
    Wscript.Echo "Speaker Mode Off: " & objItem.SpeakerModeOff
    Wscript.Echo "Speaker Mode On: " & objItem.SpeakerModeOn
    Wscript.Echo "Speaker Mode Setup: " & objItem.SpeakerModeSetup
    Wscript.Echo "Speaker Volume High: " & objItem.SpeakerVolumeHigh
    Wscript.Echo "Speaker Volume Info: " & objItem.SpeakerVolumeInfo
    Wscript.Echo "Speaker Volume Low: " & objItem.SpeakerVolumeLow
    Wscript.Echo "Speaker Volume Med: " & objItem.SpeakerVolumeMed
    Wscript.Echo "Status Info: " & objItem.StatusInfo
    Wscript.Echo "Terminator: " & objItem.Terminator
    Wscript.Echo "Tone: " & objItem.Tone
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Plug and Play Devices

Description
Returns a list of all the Plug and Play devices installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPEntity")

For Each objItem in colItems
    Wscript.Echo "Class GUID: " & objItem.ClassGuid
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Service: " & objItem.Service
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Plug and Play Signed Drivers

Description
Returns information about the signed plug and play drivers installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PnPSignedDriver")

For Each objItem in colItems
    Wscript.Echo "Class Guid: " & objItem.ClassGuid
    Wscript.Echo "Compatability ID: " & objItem.CompatID
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device Class: " & objItem.DeviceClass
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Name: " & objItem.DeviceName
    dtmWMIDate = objItem.DriverDate
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Driver Date: " & strReturn
    Wscript.Echo "Driver Provider Name: " & objItem.DriverProviderName
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "Hardware ID: " & objItem.HardWareID
    Wscript.Echo "INF Name: " & objItem.InfName
    Wscript.Echo "Is Signed: " & objItem.IsSigned
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "PDO: " & objItem.PDO
    Wscript.Echo "Signer: " & objItem.Signer
    Wscript.Echo
Next

Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate,13, 2))
    End If
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Pointing Device Properties

Description
Returns information about all the pointing devices (including mice and trackballs) installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PointingDevice")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Interface: " & objItem.DeviceInterface
    Wscript.Echo "Double Speed Threshold: " & objItem.DoubleSpeedThreshold
    Wscript.Echo "Handedness: " & objItem.Handedness
    Wscript.Echo "Hardware Type: " & objItem.HardwareType
    Wscript.Echo "INF File Name: " & objItem.InfFileName
    Wscript.Echo "INF Section: " & objItem.InfSection
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number Of Buttons: " & objItem.NumberOfButtons
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Pointing Type: " & objItem.PointingType
    Wscript.Echo "Quad Speed Threshold: " & objItem.QuadSpeedThreshold
    Wscript.Echo "Resolution: " & objItem.Resolution
    Wscript.Echo "Sample Rate: " & objItem.SampleRate
    Wscript.Echo "Synch: " & objItem.Synch
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Sound Card Properties

Description
Retrieves information about all the sound cards installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_SoundDevice")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "DMA Buffer Size: " & objItem.DMABufferSize
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "MPU 401 Address: " & objItem.MPU401Address
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Product Name: " & objItem.ProductName
    Wscript.Echo "Status Information: " & objItem.StatusInfo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Parallel Port Properties

Description
Returns information about the parallel ports installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ParallelPort")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    For Each strCapability in objItem.Capabilities
        Wscript.Echo "Capability: " & strCapability
    Next
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "OS Auto Discovered: " & objItem.OSAutoDiscovered
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List PCMCIA Controller Information

Description
Returns information about all PCMCIA controllers installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PCMCIAController")

For Each objItem in colItems
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Port Connector Properties

Description
Returns information about port connectors installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PortConnector")

For Each objItem in colItems
    Wscript.Echo "Connector Pinout: " & objItem.ConnectorPinout
    For Each strConnectorType in objItem.ConnectorType
        Wscript.Echo "Connector Type: " & strConnectorType
    Next
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "External Reference Designator: " & _
        objItem.ExternalReferenceDesignator
    Wscript.Echo "Internal Reference Designator: " & _
        objItem.InternalReferenceDesignator
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Port Type: " & objItem.PortType
    Wscript.Echo "Serial Number: " & objItem.SerialNumber
    Wscript.Echo "Tag: " & objItem.Tag
    Wscript.Echo "Version: " & objItem.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Port Resource Information

Description
Returns information about all the I/O ports found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_PortResource")

For Each objItem in colItems
    Wscript.Echo "Alias: " & objItem.Alias
    Wscript.Echo "Ending Address: " & objItem.EndingAddress
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Starting Address: " & objItem.StartingAddress
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Serial Port Configuration Properties

Description
Enumerates configuration values for all the serial ports installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_SerialPortConfiguration")

For Each objItem in colItems
    Wscript.Echo "Abort Read Write On Error: " & objItem.AbortReadWriteOnError
    Wscript.Echo "Baud Rate: " & objItem.BaudRate
    Wscript.Echo "Binary Mode Enabled: " & objItem.BinaryModeEnabled
    Wscript.Echo "Bits Per Byte: " & objItem.BitsPerByte
    Wscript.Echo "Continue XMit On XOff: " & objItem.ContinueXMitOnXOff
    Wscript.Echo "CTS Outflow Control: " & objItem.CTSOutflowControl
    Wscript.Echo "Discard NULL Bytes: " & objItem.DiscardNULLBytes
    Wscript.Echo "DSR Outflow Control: " & objItem.DSROutflowControl
    Wscript.Echo "DSR Sensitivity: " & objItem.DSRSensitivity
    Wscript.Echo "DTR Flow Control Type: " & objItem.DTRFlowControlType
    Wscript.Echo "EOF Character: " & objItem.EOFCharacter
    Wscript.Echo "Error Replace Character: " & objItem.ErrorReplaceCharacter
    Wscript.Echo "Error Replacement Enabled: " & _
        objItem.ErrorReplacementEnabled
    Wscript.Echo "Event Character: " & objItem.EventCharacter
    Wscript.Echo "Is Busy: " & objItem.IsBusy
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Parity: " & objItem.Parity
    Wscript.Echo "Parity Check Enabled: " & objItem.ParityCheckEnabled
    Wscript.Echo "RTS Flow Control Type: " & objItem.RTSFlowControlType
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Stop Bits: " & objItem.StopBits
    Wscript.Echo "XOff Character: " & objItem.XOffCharacter
    Wscript.Echo "XOff XMit Threshold: " & objItem.XOffXMitThreshold
    Wscript.Echo "XOn Character: " & objItem.XOnCharacter
    Wscript.Echo "XOn XMit Threshold: " & objItem.XOnXMitThreshold
    Wscript.Echo "XOn XOff InFlow Control: " & objItem.XOnXOffInFlowControl
    Wscript.Echo "XOn XOff OutFlow Control: " & objItem.XOnXOffOutFlowControl
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Serial Port Properties

Description
Returns information about the serial ports installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_SerialPort")

For Each objItem in colItems
    Wscript.Echo "Binary: " & objItem.Binary
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Maximum Baud Rate: " & objItem.MaxBaudRate
    Wscript.Echo "Maximum Input Buffer Size: " & objItem.MaximumInputBufferSize
    Wscript.Echo "Maximum Output Buffer Size: " & _
        objItem.MaximumOutputBufferSize
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "OS Auto Discovered: " & objItem.OSAutoDiscovered
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Provider Type: " & objItem.ProviderType
    Wscript.Echo "Settable Baud Rate: " & objItem.SettableBaudRate
    Wscript.Echo "Settable Data Bits: " & objItem.SettableDataBits
    Wscript.Echo "Settable Flow Control: " & objItem.SettableFlowControl
    Wscript.Echo "Settable Parity: " & objItem.SettableParity
    Wscript.Echo "Settable Parity Check: " & objItem.SettableParityCheck
    Wscript.Echo "Settable RLSD: " & objItem.SettableRLSD
    Wscript.Echo "Settable Stop Bits: " & objItem.SettableStopBits
    Wscript.Echo "Supports 16-Bit Mode: " & objItem.Supports16BitMode
    Wscript.Echo "Supports DTRDSR: " & objItem.SupportsDTRDSR
    Wscript.Echo "Supports Elapsed Timeouts: " & _
        objItem.SupportsElapsedTimeouts
    Wscript.Echo "Supports Int Timeouts: " & objItem.SupportsIntTimeouts
    Wscript.Echo "Supports Parity Check: " & objItem.SupportsParityCheck
    Wscript.Echo "Supports RLSD: " & objItem.SupportsRLSD
    Wscript.Echo "Supports RTSCTS: " & objItem.SupportsRTSCTS
    Wscript.Echo "Supports Special Characters: " & _
        objItem.SupportsSpecialCharacters
    Wscript.Echo "Supports XOn XOff: " & objItem.SupportsXOnXOff
    Wscript.Echo "Supports XOn XOff Setting: " & objItem.SupportsXOnXOffSet
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List System Slot Properties

Description
Returns information about the system slots installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_SystemSlot")

For Each objItem in colItems
    For Each strConnectorPinout in objItem.ConnectorPinout
        Wscript.Echo "Connector Pinout: " & strConnectorPinout
    Next
    Wscript.Echo "Connector Type: " & objItem.ConnectorType
    Wscript.Echo "Current Usage: " & objItem.CurrentUsage
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Height Allowed: " & objItem.HeightAllowed
    Wscript.Echo "Length Allowed: " & objItem.LengthAllowed
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Data Width: " & objItem.MaxDataWidth
    Wscript.Echo "Model: " & objItem.Model
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number: " & objItem.Number
    Wscript.Echo "PME Signal: " & objItem.PMESignal
    Wscript.Echo "Shared: " & objItem.Shared
    Wscript.Echo "Slot Designation: " & objItem.SlotDesignation
    Wscript.Echo "Supports Hot Plug: " & objItem.SupportsHotPlug
    Wscript.Echo "Tag: " & objItem.Tag
    Wscript.Echo "Thermal Rating: " & objItem.ThermalRating
    For Each strVccVoltageSupport in objItem.VccMixedVoltageSupport
        Wscript.Echo "VCC Mixed Voltage Support: " & strVccVoltageSupport
    Next
    Wscript.Echo "Version: " & objItem.Version
    For Each strVppVoltageSupport in objItem.VppMixedVoltageSupport
        Wscript.Echo "VPP Mixed Voltage Support: " & strVppVoltageSupport
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Possible Video Controller Resolutions

Description
Returns a list of all the possible video display resolutions that can be configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from CIM_VideoControllerResolution")

For Each objItem in colItems
    Wscript.Echo "Horizontal Resolution: " & objItem.HorizontalResolution
    Wscript.Echo "Number Of Colors: " & objItem.NumberOfColors
    Wscript.Echo "Refresh Rate: " & objItem.RefreshRate
    Wscript.Echo "Scan Mode: " & objItem.ScanMode
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Vertical Resolution: " & objItem.VerticalResolution
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Current Display Configuration Values

Description
Returns information about the current display settings on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_DisplayConfiguration")

For Each objItem in colItems
    Wscript.Echo "Bits Per Pel: " & objItem.BitsPerPel
    Wscript.Echo "Device Name: " & objItem.DeviceName
    Wscript.Echo "Display Flags: " & objItem.DisplayFlags
    Wscript.Echo "Display Frequency: " & objItem.DisplayFrequency
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "Log Pixels: " & objItem.LogPixels
    Wscript.Echo "Pels Height: " & objItem.PelsHeight
    Wscript.Echo "Pels Width: " & objItem.PelsWidth
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Specification Version: " & objItem.SpecificationVersion
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Desktop Monitor Properties

Description
Returns information about the desktop monitor connected to a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Bandwidth: " & objItem.Bandwidth
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Display Type: " & objItem.DisplayType
    Wscript.Echo "Is Locked: " & objItem.IsLocked
    Wscript.Echo "Monitor Manufacturer: " & objItem.MonitorManufacturer
    Wscript.Echo "Monitor Type: " & objItem.MonitorType
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Pixels Per X Logical Inch: " & objItem.PixelsPerXLogicalInch
    Wscript.Echo "Pixels Per Y Logical Inch: " & objItem.PixelsPerYLogicalInch
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Screen Height: " & objItem.ScreenHeight
    Wscript.Echo "Screen Width: " & objItem.ScreenWidth
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Video Adapter Information

Description
Returns information about the video adapters installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_DisplayControllerConfiguration")

For Each objItem in colItems
    Wscript.Echo "Bits Per Pixel: " & objItem.BitsPerPixel
    Wscript.Echo "Color Planes: " & objItem.ColorPlanes
    Wscript.Echo "Device Entries in a Color Table: " & _
        objItem.DeviceEntriesInAColorTable
    Wscript.Echo "Device Specific Pens: " & objItem.DeviceSpecificPens
    Wscript.Echo "Horizontal Resolution: " & objItem.HorizontalResolution
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Refresh Rate: " & objItem.RefreshRate
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Vertical Resolution: " & objItem.VerticalResolution
    Wscript.Echo "Video Mode: " & objItem.VideoMode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Video Controller Properties

Description
Retrieves information about the video controller installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_VideoController")

For Each objItem in colItems
    For Each strCapability in objItem.AcceleratorCapabilities
        Wscript.Echo "Accelerator Capability: " & strCapability
    Next
    Wscript.Echo "Adapter Compatibility: " & objItem.AdapterCompatibility
    Wscript.Echo "Adapter DAC Type: " & objItem.AdapterDACType
    Wscript.Echo "Adapter RAM: " & objItem.AdapterRAM
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Color Table Entries: " & objItem.ColorTableEntries
    Wscript.Echo "Current Bits Per Pixel: " & objItem.CurrentBitsPerPixel
    Wscript.Echo "Current Horizontal Resolution: " & _
        objItem.CurrentHorizontalResolution
    Wscript.Echo "Current Number of Colors: " & objItem.CurrentNumberOfColors
    Wscript.Echo "Current Number of Columns: " & objItem.CurrentNumberOfColumns
    Wscript.Echo "Current Number of Rows: " & objItem.CurrentNumberOfRows
    Wscript.Echo "Current Refresh Rate: " & objItem.CurrentRefreshRate
    Wscript.Echo "Current Scan Mode: " & objItem.CurrentScanMode
    Wscript.Echo "Current Vertical Resolution: " & _
        objItem.CurrentVerticalResolution
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Device Specific Pens: " & objItem.DeviceSpecificPens
    Wscript.Echo "Dither Type: " & objItem.DitherType
    Wscript.Echo "Driver Date: " & objItem.DriverDate
    Wscript.Echo "Driver Version: " & objItem.DriverVersion
    Wscript.Echo "ICM Intent: " & objItem.ICMIntent
    Wscript.Echo "ICM Method: " & objItem.ICMMethod
    Wscript.Echo "INF Filename: " & objItem.InfFilename
    Wscript.Echo "INF Section: " & objItem.InfSection
    Wscript.Echo "Installed Display Drivers: " & _
        objItem.InstalledDisplayDrivers
    Wscript.Echo "Maximum Memory Supported: " & objItem.MaxMemorySupported
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Refresh Rate: " & objItem.MaxRefreshRate
    Wscript.Echo "Minimum Refresh Rate: " & objItem.MinRefreshRate
    Wscript.Echo "Monochrome: " & objItem.Monochrome
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number of Color Planes: " & objItem.NumberOfColorPlanes
    Wscript.Echo "Number of Video Pages: " & objItem.NumberOfVideoPages
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Reserved System Palette Entries: " & _
        objItem.ReservedSystemPaletteEntries
    Wscript.Echo "Specification Version: " & objItem.SpecificationVersion
    Wscript.Echo "System Palette Entries: " & objItem.SystemPaletteEntries
    Wscript.Echo "Video Architecture: " & objItem.VideoArchitecture
    Wscript.Echo "Video Memory Type: " & objItem.VideoMemoryType
    Wscript.Echo "Video Mode: " & objItem.VideoMode
    Wscript.Echo "Video Mode Description: " & objItem.VideoModeDescription
    Wscript.Echo "Video Processor: " & objItem.VideoProcessor
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application in a Web Directory

Description
Creates a Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppCreate(False)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Out-of-Process Application in a Web Directory

Description
Creates an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

strComputer = objNetwork.ComputerName
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppCreate2 OUT_OF_PROCESS

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Web Directory Application

Description
Deletes the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppDelete

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Out-of-Process Web Application

Description
Deletes an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppDeleteRecursive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Web Directory Application

Description
Disables the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppDisable

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable an Out-of-Process Web Application

Description
Disables an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppDisableRecursive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a Web Directory Application

Description
Enables the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppEnable

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable an Out-of-Process Web Application

Description
Enables an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppEnableRecursive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Applications in an Application Pool

Description
Returns a list of all the applications in the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/AppPools/MSSharePointAppPool")
arrApps = objIIS.EnumAppsInPool

For i = 0 to Ubound(arrApps)
    Wscript.Echo arrApps(i)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Recycle an Application Pool

Description
Recycles the application pool MSSharePointAppPool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/AppPools/MSSharePointAppPool")

objIIS.Recycle

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restart a Web Directory Application

Description
Restarts the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.ASPAppRestart

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start an Application Pool

Description
Starts the application pool MSSharePointAppPool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/AppPools/MSSharePointAppPool")

objIIS.Start

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop an Application Pool

Description
Stops the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/AppPools/MSSharePointAppPool")

objIIS.Stop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unload an Application from a Web Directory

Description
Unloads the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppUnload

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unload an Out-of-Process Web Application

Description
Unloads an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")

objIIS.AppUnloadRecursive

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the Status of a Web Directory Application

Description
Retrieves the status of the Web application in the W3SVC/2142295254/root/aspnet_client_folder directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")
strStatus = objIIS.AppGetStatus2

If strStatus = 2 Then
    Wscript.Echo "The application is running."
ElseIf strStatus = 3 Then
    Wscript.Echo "The application is stopped."
Else
    Wscript.Echo "The status of this application could not be determined."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Back Up the Metabase

Description
Backs up the metabase to a file named ScriptedBackup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFF
Const MD_BACKUP_OVERWRITE = 1

strComputer = "LocalHost"
Set objComputer = GetObject("IIS://" & strComputer & "")
objComputer.Backup "ScriptedBackup", MD_BACKUP_HIGHEST_VERSION,_
     MD_BACKUP_OVERWRITE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Back Up the Metabase Using a Password

Description
Backs up the metabase to a file named ScriptedBackup, assigning the backup a password of ie456@k.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFE
Const MD_BACKUP_OVERWRITE = 1

strComputer = "LocalHost"
Set objComputer = GetObject("IIS://" & strComputer & "")
objComputer.BackupWithPassword "ScriptedBackup", _
    MD_BACKUP_HIGHEST_VERSION, MD_BACKUP_OVERWRITE, "ie456@k"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Backup

Description
Deletes version 0 of the backup file named ScriptedBackup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const BACKUP_VERSION = 0

strComputer = "LocalHost"
Set objComputer = GetObject("IIS://" & strComputer & "")
objComputer.DeleteBackup "ADSIBackup", BACKUP_VERSION

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate Backups

Description
Returns information about all the IIS backup files on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const MD_BACKUP_NO_MORE_BACKUPS = &H80070103

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "")
intIndex = 0

Do While True
    strName = ""
    objIIS.EnumBackups strName, intIndex, strVersion, _
        strLocation, strDateTime
    If (Err.Number <> 0) Then
        If (Err.Number = MD_BACKUP_NO_MORE_BACKUPS) Then
            Exit Do
        End If
    End If

    WScript.Echo "Name: " & strName
    Wscript.Echo "Version Number: " & strVersion
    Wscript.Echo "Backup Location: " & strLocation
    Wscript.Echo "Backup Date: " & strDateTime
    Wscript.Echo

    intIndex = intIndex + 1
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate Filter Load Order

Description
Enumerates the filter load order on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/Filters")

Wscript.Echo "Filter Load Order: " & objIIS.FilterLoadOrder

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate IIS Class Members

Description
Returns all instances of the Web service, FTP service, NNTP service, and POP3 service classes on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC")

For Each objItem in objIIS
    If objItem.class = "IIsWebServer" Then
        Wscript.Echo objItem.Name
    End If
Next

Wscript.Echo

Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC")
For Each objItem in objIIS
    If objItem.class = "IIsFtpServer" Then
        Wscript.Echo objItem.Name
    End If
Next

Wscript.Echo

Set objIIS = GetObject("IIS://" & strComputer & "/NNTPSVC")
For Each objItem in objIIS
    If objItem.class = "IIsNntpServer" Then
        Wscript.Echo objItem.Name
    End If
Next

Wscript.Echo

Set objIIS = GetObject("IIS://" & strComputer & "/SMTPSVC")
For Each objItem in objIIS
    If objItem.class = "IIsSmtpServer" Then
        Wscript.Echo objItem.Name
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate IIS Filters

Description
Returns information about all the IIS filters on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set colFilters = GetObject("IIS://" & strComputer & "/W3SVC/Filters")

For Each objFilter in colFilters
    Wscript.Echo "Name: " & objFilter.Name
    Wscript.Echo "Filter Description: " & objFilter.FilterDescription
    Wscript.Echo "Filter Path: " & objFilter.FilterPath
    Wscript.Echo "Filter Enabled: " & objFilter.FilterEnabled
    Wscript.Echo "Filter State: " & objFilter.FilterState
    Wscript.Echo "Filter Flags: " & objFilter.FilterFlags
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate Log Modules

Description
Returns a list of all log modules found on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set colLogs = GetObject("IIS://" & strComputer & "/Logging")

For Each objLog in colLogs
    Wscript.Echo "Name: " & objLog.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate MIME Maps

Description
Returns the MIME Maps on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MimeMap")
arrMaps = objIIS.GetEx("MimeMap")

For i = 0 to Ubound(arrMaps)
    Wscript.Echo "Extension: " & arrMaps(i).Extension
    Wscript.Echo "Type: " & arrMaps(i).MimeType
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Bandwidth Information

Description
Returns bandwidth information for an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "")

Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Bandwidth Blocked: " & objIIS.MaxBandwidthBlocked

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an IIS Filter Setting Metabase Property

Description
Demonstration script that modifies a filter setting property (FilterEnabled) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/Filters/Compression")\

objIIS.FilterEnabled = FALSE
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore a Metabase Backup

Description
Restores the metabase using a backup named Scripted Backup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFE

strComputer = "LocalHost"
Set objComputer = GetObject("IIS://" & strComputer & "")

objComputer.Restore "ScriptedBackup", MD_BACKUP_HIGHEST_VERSION, 0

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore a Metabase Using a Password

Description
Restore the metabase using a backup named ScriptedBackup and a password of ie456@k.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFE

strComputer = "LocalHost"
Set objComputer = GetObject("IIS://" & strComputer & "")

objComputer.RestoreWithPassword "ScriptedBackup", _
    MD_BACKUP_HIGHEST_VERSION, 0, " ie456@k"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a File Extension to the IIS Compression Scheme

Description
Adds the file extension hta to the GZip compression scheme in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ADS_PROPERTY_UPDATE = 2

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/Filters/Compression/gzip")
arrExtensions = objIIS.HcFileExtensions
i = Ubound(arrExtensions)
i = i + 1

Redim Preserve arrExtensions(i)
arrExtensions(i) = "hta"

objIIS.PutEx ADS_PROPERTY_UPDATE, "HcFileExtensions", arrExtensions
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Server Properties

Description
Lists the properties of an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "LocalHost"
Set objServer = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

Wscript.Echo "Access Flags" & objServer.AccessFlags
script.Echo "Connection Timeout: " & objServer.ConnectionTimeout
Wscript.Echo "Default Logon Domain: " & objServer.DefaultLogonDomain
Wscript.Echo "Allow Anonymous: " & objServer.AllowAnonymous
Wscript.Echo "Disable SOcket Pooling: " & _
    objServer.DisableSocketPooling
Wscript.Echo "Anonymous Only: " & objServer.AnonymousOnly
Wscript.Echo "Don't Log: " & objServer.DontLog
Wscript.Echo "Anonymous Password Synch: " & _
    objServer.AnonymousPasswordSync
Wscript.Echo "Exit Message: " & objServer.ExitMessage
Wscript.Echo "Anonymous User Name: " & objServer.AnonymousUserName
Wscript.Echo "FTP Directory Browse Show Long Date: " & _
    objServer.FtpDirBrowseShowLongDate
Wscript.Echo "Anonymous User Password: " & _
    objServer.AnonymousUserPass
For Each strMessage in objServer.GreetingMessage
    Wscript.Echo "Greeting Message: " & strMessage
Next
Wscript.Echo "Log Anonymous: " & objServer.LogAnonymous
Wscript.Echo "Log Ext File Flags: " & objServer.LogExtFileFlags
Wscript.Echo "Log File Directory: " & objServer.LogFileDirectory
Wscript.Echo "Log File Local Time Rollover: " & _
    objServer.LogFileLocaltimeRollover
Wscript.Echo "Log File Period: " & objServer.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & _
    objServer.LogFileTruncateSize
Wscript.Echo "Log Non-Anonymous: " & objServer.LogNonAnonymous
Wscript.Echo "Log ODBC Data Source: " & _
    objServer.LogOdbcDataSource
Wscript.Echo "Log ODBC Password: " & objServer.LogOdbcPassword
Wscript.Echo "Log ODBC Table Name: " & objServer.LogOdbcTableName
Wscript.Echo "Log ODNC User Name: " & objServer.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objServer.LogPluginClsid
Wscript.Echo "Log Type: " & objServer.LogType
Wscript.Echo "Maximum Client Message: " & _
    objServer.MaxClientsMessage
Wscript.Echo "Maximum Connections: " & objServer.MaxConnections
Wscript.Echo "Server Comment: " & objServer.ServerComment
Wscript.Echo "Maximum Endpoint Connections: " & _
    objServer.MaxEndpointConnections
Wscript.Echo "Server Listen backlog: " & _
    objServer.ServerListenBacklog
Wscript.Echo "MS-DOS Directory Output: " & _
    objServer.MSDOSDirOutput
Wscript.Echo "Server Listen Timeout: " & _
    objServer.ServerListenTimeout
Wscript.Echo "Realm: " & objServer.Realm
Wscript.Echo "Server Size: " & objServer.ServerSize
Wscript.Echo "Server Autostart: " & objServer.ServerAutoStart
Wscript.Echo "Server State: " & objServer.ServerState

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Compression Scheme Information

Description
Returns information about compression scheme configuration on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "LocalHost"
Set colSchemes = GetObject _
    ("IIS://" & strComputer & "/W3SVC/Filters/Compression")

For Each objItem in colSchemes
    If objItem.Name <> "Parameters" Then
        wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Compression DLL: " & objItem.HcCompressionDll
        Wscript.Echo "Create Flags: " & objItem.HcCreateFlags
        Wscript.Echo "Do Dynamic Compression: " &  _
            objItem.HcDoDynamicCompression
        Wscript.Echo "Do Static Compression: " &  _
            objItem.HcDoStaticCompression
        Wscript.Echo "Do On-Demand Compression: " &  _
            objItem.HcDoOnDemandCompression
        Wscript.Echo "Dynamic Compression Level: " &  _
            objItem.HcDynamicCompressionLevel
        For Each strExtension in objItem.HcFileExtensions
            Wscript.Echo "File Extensions: " & strExtension
        Next
        Wscript.Echo "On-Demand Compression Level: " &  _
            objItem.HcOnDemandCompLevel
        Wscript.Echo "Priority: " & objItem.HcPriority
        For Each strExtension in objItem.HcScriptFileExtensions
            Wscript.Echo "Script File Extensions: " & strExtension
        Next
        Wscript.Echo
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Compression Schemes Information

Description
Returns information about the compressions schemes on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/Filters/Compression/Parameters")

Wscript.Echo "Cache Control Header: " & objIIS.HcCacheControlHeader
Wscript.Echo "Compression Buffer Size: " & objIIS.HcCompressionBufferSize
Wscript.Echo "Compression Directory: " & objIIS.HcCompressionDirectory
Wscript.Echo "Do Disk Space Limiting: " & objIIS.HcDoDiskSpaceLimiting
Wscript.Echo "Do Dynamic Compression: " & objIIS.HcDoDynamicCompression
Wscript.Echo "Do On-Demand Compression: " & objIIS.HcDoOnDemandCompression
Wscript.Echo "Do Static Compression: " & objIIS.HcDoStaticCompression
Wscript.Echo "Expires Header: " & objIIS.HcExpiresHeader
Wscript.Echo "Files Deleted Per Disk Free: " &  _
    objIIS.HcFilesDeletedPerDiskFree
Wscript.Echo "I/O Buffer Size: " & objIIS.HcIoBufferSize
Wscript.Echo "Maximum Disk Space Usage: " & objIIS.HcMaxDiskSpaceUsage
Wscript.Echo "Maximum Queue Length: " & objIIS.HcMaxQueueLength
Wscript.Echo "Minimum File Size for Compression: " &  _
    objIIS.HcMinFileSizeForComp
Wscript.Echo "No Compression for HTTP 1.0: " &  _
    objIIS.HcNoCompressionForHttp10
Wscript.Echo "No Compression for Proxies: " &  _
    objIIS.HcNoCompressionForProxies
Wscript.Echo "No Compression for Range: " &  _
    objIIS.HcNoCompressionForRange
Wscript.Echo "Send Cache Headers: " & objIIS.HcSendCacheHeaders

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Compression Schemes Metabase Property

Description
Demonstration script that modifies a compression schemes property (HcSendCacheHeaders) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & _
    "/W3SVC/Filters/Compression/Parameters")

objIIS.HcSendCacheHeaders = TRUE
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Continue a Paused FTP Server

Description
Continues a paused FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

objIIS.Continue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Log Modules

Description
Returns a list of all the FTP log modules found on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/Info")

Wscript.Echo "Log Module List: " & objIIS.LogModuleList

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Service Properties

Description
Lists the properties of the FTP service as configured on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC")

Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Directory levels to Scan: " & objIIS.DirectoryLevelsToScan
Wscript.Echo "Disable Socket Pooling: " & objIIS.DisableSocketPooling
Wscript.Echo "Allow Anonymous: " & objIIS.AllowAnonymous
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Anonymous Only: " & objIIS.AnonymousOnly
Wscript.Echo "Exit Message: " & objIIS.ExitMessage
Wscript.Echo "Anonymous Password Sync: " & objIIS.AnonymousPasswordSync
Wscript.Echo "FTP Directory Browse Show Long Date: " & _
    objIIS.FtpDirBrowseShowLongDate
Wscript.Echo "Anonymous User Name: " & objIIS.AnonymousUserName
For Each strGreeting in objIIS.GreetingMessage
    Wscript.Echo "Greeting Message: " & strGreeting
Next
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log ODBC Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Anonymous: " & objIIS.LogAnonymous
Wscript.Echo "Log ODBC Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log ODBC Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log File Local Time Rollover: " & _
    objIIS.LogFileLocaltimeRollover
Wscript.Echo "Log ODBC User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Log Non-Anonymous Message: " & objIIS.LogNonAnonymous
Wscript.Echo "Maximum Clients Message: " & objIIS.MaxClientsMessage
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Maximum Endpoint Connections: " & objIIS.MaxEndpointConnections
Wscript.Echo "Server Listen Backlog: " & objIIS.ServerListenBacklog
Wscript.Echo "MS-DOS Directory Output: " & objIIS.MSDOSDirOutput
Wscript.Echo "Server Listen Timeout: " & objIIS.ServerListenTimeout
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "Server Size: " & objIIS.ServerSize
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Virtual Directory Properties

Description
Returns information about an FTP virtual directory named /MSFTPSVC/1012388136/root.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objDirectory = GetObject _
    ("IIS://" & strComputer & "/MSFTPSVC/1012388136/root")

Wscript.Echo "Access Flags: " & objDirectory.AccessFlags
Wscript.Echo "Don't Log: " & objDirectory.DontLog
Wscript.Echo "Path: " & objDirectory.Path
Wscript.Echo "UNC Password: " & objDirectory.UNCPassword
Wscript.Echo "FTP Directory Browse Show Long Date: " &  _
    objDirectory.FtpDirBrowseShowLongDate
Wscript.Echo "UNC User Name: " & objDirectory.UNCUserName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an FTP Server Metabase Property

Description
Demonstration script that modifies an FTP server property (DontLog) in the IIS metabase for an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

objIIS.DontLog = TRUE
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an FTP Service Metabase Property

Description
Demonstration script that modifies an FTP service property (AllowAnonymous) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC")

objIIS.AllowAnonymous = FALSE
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an FTP Virtual Directory Metabase Property

Description
Demonstration script that modifies an FTP virtual directory property (FtpDirBrowseShowLongDate) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objDirectory = GetObject("IIS://" & strComputer & _
    "/MSFTPSVC/1012388136/root")

objDirectory.FtpDirBrowseShowLongDate = TRUE
objDirectory.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause an FTP Server

Description
Pauses an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

objIIS.Pause

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start an FTP Server

Description
Starts an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

objIIS.Start

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop an FTP Server

Description
Stops the FTP server MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/MSFTPSVC/1")

objIIS.Stop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Continue a Paused a Web Server

Description
Continues a paused Web server named W3SVC/2142295254 on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/2142295254")

objIIS.Continue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Properties of a Virtual Directory

Description
Demonstration script that returns the properties of the W3SVC/1/ROOT/Printers virtual directory on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1/ROOT/Printers")

Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "ASP Errors to NT Log: " & objIIS.AspErrorsToNTLog
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "ASP Exception Catch Enabled: " & _
    objIIS.AspExceptionCatchEnable
Wscript.Echo "Anonymous Password Sync: " & objIIS.AnonymousPasswordSync
Wscript.Echo "ASP Log Error Requests: " & objIIS.AspLogErrorRequests
Wscript.Echo "Anonymous User name: " & objIIS.AnonymousUserName
Wscript.Echo "ASP Processor Thread MAximum: " & _
    objIIS.AspProcessorThreadMax
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "ASP Queue Connection Test Time: " & _
    objIIS.AspQueueConnectionTestTime
Wscript.Echo "Application Allow Client Debugging: " & _
    objIIS.AppAllowClientDebug
Wscript.Echo "ASP Queue Timeout: " & objIIS.AspQueueTimeout
Wscript.Echo "Application Allow Debugging: " & objIIS.AppAllowDebugging
Wscript.Echo "ASP Request Queue Maximum: " & objIIS.AspRequestQueueMax
Wscript.Echo "Application Friendly Name: " & objIIS.AppFriendlyName
Wscript.Echo "ASP Script Engine Cache Maximum: " & _
    objIIS.AspScriptEngineCacheMax
Wscript.Echo "Application Isolated: " & objIIS.AppIsolated
Wscript.Echo "ASP Script Error Message: " & objIIS.AspScriptErrorMessage
Wscript.Echo "Application OOP Recover Limit: " & _
    objIIS.AppOopRecoverLimit
Wscript.Echo "ASP Script Error Sent to Browser: " & _
    objIIS.AspScriptErrorSentToBrowser
Wscript.Echo "Application Package ID: " & objIIS.AppPackageID
Wscript.Echo "ASP Script File Cache Size: " & objIIS.AspScriptFileCacheSize
Wscript.Echo "Application Package Name: " & objIIS.AppPackageName
Wscript.Echo "ASP Script Language: " & objIIS.AspScriptLanguage
Wscript.Echo "Application Root: " & objIIS.AppRoot
Wscript.Echo "ASP Script Timeout: " & objIIS.AspScriptTimeout
Wscript.Echo "Application WAM Clsid: " & objIIS.AppWamClsid
Wscript.Echo "ASP Session Maximum: " & objIIS.AspSessionMax
Wscript.Echo "ASP Allow Out-of-Process Components: " & _
    objIIS.AspAllowOutOfProcComponents
Wscript.Echo "ASP Session Timeout: " & objIIS.AspSessionTimeout
Wscript.Echo "ASP Allow Session State: " & objIIS.AspAllowSessionState
Wscript.Echo "ASP Buffering On: " & objIIS.AspBufferingOn
Wscript.Echo "ASP Codepage: " & objIIS.AspCodepage
Wscript.Echo "ASP Enable Application Restart: " & _
    objIIS.AspEnableApplicationRestart
Wscript.Echo "ASP Enable ASP HTML Fallback: " & _
    objIIS.AspEnableAspHtmlFallback
Wscript.Echo "ASP Enable Chunked Encoding: " & objIIS.AspEnableChunkedEncoding
Wscript.Echo "ASP Enabled Parent Paths: " & objIIS.AspEnableParentPaths
Wscript.Echo "ASP Track Threading Model: " & objIIS.AspTrackThreadingModel
Wscript.Echo "ASP Enable Typelib Cache: " & objIIS.AspEnableTypelibCache
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
For Each strError in objIIS.HttpErrors
    Wscript.Echo "HTTP Error: " & strError
Next
Wscript.Echo "Authentication Persistence: " & objIIS.AuthPersistence
Wscript.Echo "HTTP Expires: " & objIIS.HttpExpires
Wscript.Echo "Cache Control Custom: " & objIIS.CacheControlCustom
For Each strPics in objIIS.HttpPics
    Wscript.Echo "HTTP Pic: " & strPics
Next
Wscript.Echo "Cache Control Maximum Age: " & objIIS.CacheControlMaxAge
Wscript.Echo "HTTP Redirect: " & objIIS.HttpRedirect
Wscript.Echo "Cache Control No Cache: " & objIIS.CacheControlNoCache
Wscript.Echo "Cache ISAPI: " & objIIS.CacheISAPI
Wscript.Echo "Logon Method: " & objIIS.LogonMethod
Wscript.Echo "Content Indexed: " & objIIS.ContentIndexed
For Each strMap in objIIS.MimeMap
    Wscript.Echo "MIME Map: " & strMao
Next
Wscript.Echo "Create CGI with New Console: " & _
    objIIS.CreateCGIWithNewConsole
Wscript.Echo "Path: " & objIIS.Path
Wscript.Echo "Create Process as User: " & objIIS.CreateProcessAsUser
Wscript.Echo "Pool IDC Timeout: " & objIIS.PoolIdcTimeout
Wscript.Echo "Default Document: " & objIIS.DefaultDoc
Wscript.Echo "Default Document Footer: " & objIIS.DefaultDocFooter
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
For Each strHeader in objIIS.RedirectHeaders
    Wscript.Echo "Redirect Header: " & strHeader
Next
Wscript.Echo "Directory Browse Flags: " & objIIS.DirBrowseFlags
For Each strScriptMap in objIIS.ScriptMaps
    Wscript.Echo "Script Map: " & strScriptMap
Next
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "SSI Exec Disable: " & objIIS.SSIExecDisable
Wscript.Echo "Enable Document Footer: " & objIIS.EnableDocFooter
Wscript.Echo "Enable Reverse DNS: " & objIIS.EnableReverseDns
Wscript.Echo "UNC Password: " & objIIS.UNCPassword
For Each strHeader in objIIS.HttpCustomHeaders
    Wscript.Echo "HTTP Custom Header: " & strHeader
Next
Wscript.Echo "UNC User Name: " & objIIS.UNCUserName
Wscript.Echo "Upload Read-Ahead Size: " & objIIS.UploadReadAheadSize

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Properties of a Web Directory

Description
Returns the property values for the Web directory W3SVC/1/ROOT/aspnet_client.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/1/ROOT/aspnet_client")

Wscript.Echo "Acces Flags: " & objIIS.AccessFlags
Wscript.Echo "ASP Errors to NT log: " & objIIS.AspErrorsToNTLog
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "ASP Exception catch Enabled: " & _
    objIIS.AspExceptionCatchEnable
Wscript.Echo "Anonymous Password Synch: " & objIIS.AnonymousPasswordSync
Wscript.Echo "ASP Log Error Requests: " & objIIS.AspLogErrorRequests
Wscript.Echo "Anonymous user Name: " & objIIS.AnonymousUserName
Wscript.Echo "ASP Processor Thread Maximum: " & _
    objIIS.AspProcessorThreadMax
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "ASP Queue Connection Test Time: " & _
    objIIS.AspQueueConnectionTestTime
Wscript.Echo "ASP Allow Client Debugging: " & objIIS.AppAllowClientDebug
Wscript.Echo "ASP Queue Timeout: " & objIIS.AspQueueTimeout
Wscript.Echo "Application Allow Debugging: " & objIIS.AppAllowDebugging
Wscript.Echo "ASP Request Queue Maximum: " & objIIS.AspRequestQueueMax
Wscript.Echo "Application Friendly Name: " & objIIS.AppFriendlyName
Wscript.Echo "ASP Script Engine cache Maximum: " & _
    objIIS.AspScriptEngineCacheMax
Wscript.Echo "Application Isolated: " & objIIS.AppIsolated
Wscript.Echo "ASP Script Error Message: " & objIIS.AspScriptErrorMessage
Wscript.Echo "Application OOP Recover Limit: " & objIIS.AppOopRecoverLimit
Wscript.Echo "ASP Script Error Sent to Browser: " & _
    objIIS.AspScriptErrorSentToBrowser
Wscript.Echo "Application Package ID: " & objIIS.AppPackageID
Wscript.Echo "ASP Script File Cache Size: " & objIIS.AspScriptFileCacheSize
Wscript.Echo "Application Package Name: " & objIIS.AppPackageName
Wscript.Echo "ASP Script Language: " & objIIS.AspScriptLanguage
Wscript.Echo "Application Root: " & objIIS.AppRoot
Wscript.Echo "ASP Script Timeout: " & objIIS.AspScriptTimeout
Wscript.Echo "Application WAM Clsid: " & objIIS.AppWamClsid
Wscript.Echo "ASP Session Maximum: " & objIIS.AspSessionMax
Wscript.Echo "ASP Allow Out-of-Process Components: " & _
    objIIS.AspAllowOutOfProcComponents
Wscript.Echo "ASP Session Timeout: " & objIIS.AspSessionTimeout
Wscript.Echo "ASP Allow Session State: " & objIIS.AspAllowSessionState
Wscript.Echo "ASP Buffering On: " & objIIS.AspBufferingOn
Wscript.Echo "ASP Codepage: " & objIIS.AspCodepage
Wscript.Echo "ASP Enable Application Restart: " & _
    objIIS.AspEnableApplicationRestart
Wscript.Echo "ASP Enable ASP HTML Fallback: " & _
    objIIS.AspEnableAspHtmlFallback
Wscript.Echo "ASP Enable Chunked Encoding: " & _
    objIIS.AspEnableChunkedEncoding
Wscript.Echo "ASP Enable Parent Paths: " & objIIS.AspEnableParentPaths
Wscript.Echo "ASP Track Threading Model: " & _
    objIIS.AspTrackThreadingModel
Wscript.Echo "ASP Enable Typelib Cache: " & _
    objIIS.AspEnableTypelibCache
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
For Each strHeader in objIIS.HttpCustomHeaders
    Wscript.Echo "HTTP Custom Header: " & strHeader
Next
Wscript.Echo "Authentication Persistence: " & objIIS.AuthPersistence
For Each strError in objIIS.HttpErrors
    Wscript.Echo "HTTP Error: " & strError
Next
Wscript.Echo "Cache Control Custom: " & objIIS.CacheControlCustom
Wscript.Echo "HTTP Expires: " & objIIS.HttpExpires
Wscript.Echo "Cache Control Maximum Age: " & _
    objIIS.CacheControlMaxAge
For Each strPics in objIIS.HttpPics
    Wscript.Echo "HTTP Pic: " & strPics
Next
Wscript.Echo "Cache Control No Cache: " & _
    objIIS.CacheControlNoCache
Wscript.Echo "HTTP Redirect: " & objIIS.HttpRedirect
Wscript.Echo "Cache ISAPI: " & objIIS.CacheISAPI
Wscript.Echo "Content Indexed: " & objIIS.ContentIndexed
Wscript.Echo "Logon Method: " & objIIS.LogonMethod
Wscript.Echo "Create CGI With New Console: " & _
    objIIS.CreateCGIWithNewConsole
For Each strMap in objIIS.MimeMap
    Wscript.Echo "MIME Map: " & strMap
Next
Wscript.Echo "Create Process as User: " & objIIS.CreateProcessAsUser
Wscript.Echo "Pool IDC Timeout: " & objIIS.PoolIdcTimeout
Wscript.Echo "Default Document: " & objIIS.DefaultDoc
Wscript.Echo "Default Document Footer: " & objIIS.DefaultDocFooter
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
For Each strHeader in objIIS.RedirectHeaders
    Wscript.Echo "Redirect Header: " & strHeader
Next
Wscript.Echo "Directory Browse Flags: " & objIIS.DirBrowseFlags
For Each strMap in objIIS.ScriptMaps
    Wscript.Echo "Script Map: " & strMap
Next
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "SSI Exec Disable: " & objIIS.SSIExecDisable
Wscript.Echo "Enable Document Footer: " & objIIS.EnableDocFooter
Wscript.Echo "Enable Reverse DNS: " & objIIS.EnableReverseDns
Wscript.Echo "Upload Read-Ahead Size: " & objIIS.UploadReadAheadSize

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web File Property Values

Description
Returns the property values of a Web file named W3SVC/2142295254/root/iisstart.htm. If the file is not already in the IIS metabase, the script “creates” it, a process that adds the file to the metabase, allowing its properties to be modified.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "LocalHost"
Set objX = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/iisstart.htm")

If Err.Number <> 0 Then
    Set objIIS = GetObject _
        ("IIS://" & strComputer & "/W3SVC/2142295254/root")
    Set objFile = objIIS.Create("IIsWebFile", "iisstart.htm")
    objFile.SetInfo
    objIIS.SetInfo
End If

Set objFile = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/iisstart.htm")

Wscript.Echo "Access Execute: " & objFile.AccessExecute
Wscript.Echo "Access Flags: " & objFile.AccessFlags
Wscript.Echo "Access No Physical Directory : " & _
    objFile.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objFile.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objFile.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objFile.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & objFile.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objFile.AccessRead
Wscript.Echo "Access Script: " & objFile.AccessScript
Wscript.Echo "Access Source: " & objFile.AccessSource
Wscript.Echo "Access SSL: " & objFile.AccessSSL
Wscript.Echo "Access SSL 128: " & objFile.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objFile.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & _
    objFile.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objFile.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objFile.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objFile.AccessWrite
For Each strACL in objFile.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Anonymous Password Sync: " & _
    objFile.AnonymousPasswordSync
Wscript.Echo "Anonymous User Name: " & objFile.AnonymousUserName
Wscript.Echo "Anonymous User Password: " & objFile.AnonymousUserPass
Wscript.Echo "Authentication Anonymous: " & objFile.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objFile.AuthBasic
Wscript.Echo "Authentication Flags: " & objFile.AuthFlags
Wscript.Echo "Authentication MD5: " & objFile.AuthMD5
Wscript.Echo "Authentication NTLM: " & objFile.AuthNTLM
Wscript.Echo "Authentication Passport: " & objFile.AuthPassport
Wscript.Echo "Authentication Persistence: " & objFile.AuthPersistence
Wscript.Echo "Authentication Persist Single Request: " & _
    objFile.AuthPersistSingleRequest
Wscript.Echo "Az Enable: " & objFile.AzEnable
Wscript.Echo "Az Impersonation Level: " & _
    objFile.AzImpersonationLevel
Wscript.Echo "Az Scope Name: " & objFile.AzScopeName
Wscript.Echo "Az Store Name: " & objFile.AzStoreName
Wscript.Echo "Cache Control Custom: " & objFile.CacheControlCustom
Wscript.Echo "Cache Control Maximum Age: " & _
    objFile.CacheControlMaxAge
Wscript.Echo "Cache Control No Cache: " & objFile.CacheControlNoCache
Wscript.Echo "CGI Timeout: " & objFile.CGITimeout
Wscript.Echo "Create CGI With New Console: " & _
    objFile.CreateCGIWithNewConsole
Wscript.Echo "Create Process As User: " & objFile.CreateProcessAsUser
Wscript.Echo "Default Doc Footer: " & objFile.DefaultDocFooter
Wscript.Echo "Default Logon Domain: " & objFile.DefaultLogonDomain
Wscript.Echo "Disable Static File Cache: " & _
    objFile.DisableStaticFileCache
Wscript.Echo "Do Dynamic Compression: " & _
    objFile.DoDynamicCompression
Wscript.Echo "Don't Log: " & objFile.DontLog
Wscript.Echo "Do Static Compression: " & objFile.DoStaticCompression
Wscript.Echo "Enable Doc Footer: " & objFile.EnableDocFooter
Wscript.Echo "Enable Reverse Dns: " & objFile.EnableReverseDns
For Each strHeader in objFile.HttpCustomHeaders
    Wscript.Echo "Http Custom Header: " & strHeader
Next
For Each strError in objFile.HttpErrors
    Wscript.Echo "Http Error: " & strError
Next
Wscript.Echo "Http Expires: " & objFile.HttpExpires
For Each strPic in objFile.HttpPics
    Wscript.Echo "Http Pic: " & strPic
Next
Wscript.Echo "Http Redirect: " & objFile.HttpRedirect
Wscript.Echo "Logon Method: " & objFile.LogonMethod
Wscript.Echo "Maximum Request Entity Allowed: " & _
    objFile.MaxRequestEntityAllowed
For Each strMap in objFile.MimeMap
    Wscript.Echo "Mime Map: " & strMap
Next
Wscript.Echo "Name: " & objFile.Name
Wscript.Echo "NT Authentication Providers: " & _
    objFile.NTAuthenticationProviders
Wscript.Echo "Passport Requires AD Mapping: " & _
    objFile.PassportRequireADMapping
Wscript.Echo "Pool IDC Timeout: " & objFile.PoolIdcTimeout
Wscript.Echo "Realm: " & objFile.Realm
For Each strHeader in objFile.RedirectHeaders
     Wscript.Echo "Redirect Header: " & strHeader
Next
For Each strMap in objFile.ScriptMaps
    Wscript.Echo "Script Map: " & strMap
Next
Wscript.Echo "SSI Exec Disable: " & objFile.SSIExecDisable
Wscript.Echo "Upload Read Ahead Size: " & objFile._
    UploadReadAheadSize
Wscript.Echo "Use Digest SSP: " & objFile.UseDigestSSP

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server Configuration Information

Description
Returns basic configuration information (including log module list and custom error descriptions) for a Web server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/INFO")
Wscript.Echo "Admin Server: " & objIIS.AdminServer
Wscript.Echo "Log Module List: " & objIIS.LogModuleList
For Each strDescription in objIIS.CustomErrorDescriptions
    Wscript.Echo "Custom Error Description: " & strDescription
Next
Wscript.Echo "Server Configuration Flags: " & objIIS.ServerConfigFlags

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server Information

Description
Returns information about a Web server named W3SVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")

Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "ASP Enable Parent Paths: " & objIIS.AspEnableParentPaths
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "ASP Enable Typelib Cache: " & objIIS.AspEnableTypelibCache
Wscript.Echo "ASP Errors to NT Log: " & objIIS.AspErrorsToNTLog
Wscript.Echo "Allow Keep Alive: " & objIIS.AllowKeepAlive
Wscript.Echo "ASP Exception Catch Enabled: " & _
    objIIS.AspExceptionCatchEnable
Wscript.Echo "Allow Path for Script Mappings: " & _
    objIIS.AllowPathInfoForScriptMappings
Wscript.Echo "ASP Log Error Requests: " & objIIS.AspLogErrorRequests
Wscript.Echo "Anonymous Passwoprd Sync: " & objIIS.AnonymousPasswordSync
Wscript.Echo "ASP Processor Thread Maximum: " & _
    objIIS.AspProcessorThreadMax
Wscript.Echo "Anonymous User Name: " & objIIS.AnonymousUserName
Wscript.Echo "ASP Queue Connection Test Time: " & _
    objIIS.AspQueueConnectionTestTime
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "ASP Queue Timeout: " & objIIS.AspQueueTimeout
Wscript.Echo "Application Allow Client Debugging: " & _
    objIIS.AppAllowClientDebug
Wscript.Echo "ASP Request Queue Maximum: " & objIIS.AspRequestQueueMax
Wscript.Echo "Application Allow Debugging: " & objIIS.AppAllowDebugging
Wscript.Echo "ASP Script Engine Cache maximum: " & _
    objIIS.AspScriptEngineCacheMax
Wscript.Echo "Application Friendly Name: " & objIIS.AppFriendlyName
Wscript.Echo "ASP Script Error Sent to Browser: " & _
    objIIS.AspScriptErrorSentToBrowser
Wscript.Echo "Application Isolated: " & objIIS.AppIsolated
Wscript.Echo "ASP Script File Cache Size: " & _
    objIIS.AspScriptFileCacheSize
Wscript.Echo "Application OOP Recover Limit: " & _
    objIIS.AppOopRecoverLimit
Wscript.Echo "ASP Script Language: " & objIIS.AspScriptLanguage
Wscript.Echo "Application pPackage ID: " & objIIS.AppPackageID
Wscript.Echo "ASP Session Maximum: " & objIIS.AspSessionMax
Wscript.Echo "Application Package Name: " & objIIS.AppPackageName
Wscript.Echo "ASP Script Timeout: " & objIIS.AspScriptTimeout
Wscript.Echo "Application Root: " & objIIS.AppRoot
Wscript.Echo "ASP Session Timeout: " & objIIS.AspSessionTimeout
Wscript.Echo "Application WAM Clsid: " & objIIS.AppWamClsid
Wscript.Echo "ASP Allow Out-of-Process Components: " & _
    objIIS.AspAllowOutOfProcComponents
Wscript.Echo "ASP Allow Session State: " & objIIS.AspAllowSessionState
Wscript.Echo "ASP Buffering On: " & objIIS.AspBufferingOn
Wscript.Echo "ASP Codepage: " & objIIS.AspCodepage
Wscript.Echo "ASP Enable Application Restart: " & _
    objIIS.AspEnableApplicationRestart
Wscript.Echo "ASP Enable ASP HTML Fallback: " & _
    objIIS.AspEnableAspHtmlFallback
Wscript.Echo "ASP Track Threading Model: " & _
    objIIS.AspTrackThreadingModel
Wscript.Echo "ASP Enable Chunck Encoding: " & _
    objIIS.AspEnableChunkedEncoding
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Create Process as User: " & objIIS.CreateProcessAsUser
Wscript.Echo "Authentication Persistence: " & objIIS.AuthPersistence
Wscript.Echo "Default Document: " & objIIS.DefaultDoc
Wscript.Echo "Cache Control Custom: " & objIIS.CacheControlCustom
Wscript.Echo "Default Document Footer: " & objIIS.DefaultDocFooter
Wscript.Echo "Cache Control Maximum Age: " & objIIS.CacheControlMaxAge
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
Wscript.Echo "Cache Control No Cache: " & objIIS.CacheControlNoCache
Wscript.Echo "Directory Browse Flags: " & objIIS.DirBrowseFlags
Wscript.Echo "Cache ISAPI: " & objIIS.CacheISAPI
Wscript.Echo "Disable Socket Pooling: " & objIIS.DisableSocketPooling
Wscript.Echo "CGI Timeout: " & objIIS.CGITimeout
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Enable Document Footer: " & objIIS.EnableDocFooter
Wscript.Echo "Enable Reverse DNS: " & objIIS.EnableReverseDns
Wscript.Echo "FrontPage Web: " & objIIS.FrontPageWeb
For Each strHeader in objIIS.HttpCustomHeaders
    Wscript.Echo "HTTP Custom Header: " & strHeader
Next
For Each strError in objIIS.HttpErrors
    Wscript.Echo "HTTP Error: " & strError
Next
Wscript.Echo "HTTP Expires: " & objIIS.HttpExpires
For Each strPic in objIIS.HttpPics
    Wscript.Echo "HTTP Pics: " & strPic
Next
Wscript.Echo "Create CGI With new Console: " & _
    objIIS.CreateCGIWithNewConsole
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log ODBC Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log ODBC Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log File Local Time Rollover: " & _
    objIIS.LogFileLocaltimeRollover
Wscript.Echo "Log ODBC User name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Logon Method: " & objIIS.LogonMethod
Wscript.Echo "Log File Truncate Size: " & _
    objIIS.LogFileTruncateSize
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log ODBC Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
For Each strHeader in objIIS.RedirectHeaders
    Wscript.Echo "Redirect Header: " & strHeader
Next
Wscript.Echo "Maximum Bandwidth Blocked: " & _
    objIIS.MaxBandwidthBlocked
For Each strMap in objIIS.ScriptMaps
    Wscript.Echo "Script Map: " & strMap
Next
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
For Each strBinding in objIIS.SecureBindings
    Wscript.Echo "Secure Binding: " & strBinding
Next
Wscript.Echo "Maximum Endpoints: " & objIIS.MaxEndpointConnections
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
For Each strMap in objIIS.MimeMap
    Wscript.Echo "MIME Map: " & strMap
Next
For Each strBinding in objIIS.ServerBindings
    Wscript.Echo "Server Binding: " & strBinding
Next
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & objIIS.ServerListenBacklog
Wscript.Echo "NT Authentication Providers: " & o_
    bjIIS.NTAuthenticationProviders
Wscript.Echo "Server Listen Timeout: " & objIIS.ServerListenTimeout
Wscript.Echo "Password Cache TTL: " & objIIS.PasswordCacheTTL
Wscript.Echo "Server Size: " & objIIS.ServerSize
Wscript.Echo "Password Change Flags: " & objIIS.PasswordChangeFlags
Wscript.Echo "Server State: " & objIIS.ServerState
Wscript.Echo "Password Expire Pre-Notify Days: " & _
    objIIS.PasswordExpirePrenotifyDays
Wscript.Echo "SSI Exec Disable: " & objIIS.SSIExecDisable
Wscript.Echo "Pool IDC Timeout: " & objIIS.PoolIdcTimeout
Wscript.Echo "Process NTCR If Logged On: " & _
    objIIS.ProcessNTCRIfLoggedOn
Wscript.Echo "Upload Read-Ahead Size: " & _
    objIIS.UploadReadAheadSize
Wscript.Echo "Realm: " & objIIS.Realm

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Property Values

Description
Returns property values for the Web service on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC")

Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "ASP Enable Typelib Cache: " & _
    objIIS.AspEnableTypelibCache
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "ASP Errors to NT Log: " & objIIS.AspErrorsToNTLog
Wscript.Echo "ASP Exception Catch Enabled: " & _
    objIIS.AspExceptionCatchEnable
Wscript.Echo "Allow Path Information for Script Mappings: " & _
    objIIS.AllowPathInfoForScriptMappings
Wscript.Echo "ASP Log Error Requests: " & objIIS.AspLogErrorRequests
Wscript.Echo "Anonymous Password Synch: " & objIIS.AnonymousPasswordSync
Wscript.Echo "ASP Processor Thread Maximum: " & _
    objIIS.AspProcessorThreadMax
Wscript.Echo "Anonynmous User Name: " & objIIS.AnonymousUserName
Wscript.Echo "ASP Queue Connection Test Time: " & _
    objIIS.AspQueueConnectionTestTime
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "ASP Queue Timeout: " & objIIS.AspQueueTimeout
Wscript.Echo "Application Allow Client Debugging: " & _
    objIIS.AppAllowClientDebug
Wscript.Echo "ASP Request Queue Maximum: " & objIIS.AspRequestQueueMax
Wscript.Echo "Application Allow Debugging: " & objIIS.AppAllowDebugging
Wscript.Echo "ASP Script Engine Cache Maximum: " & _
    objIIS.AspScriptEngineCacheMax
Wscript.Echo "Application Friendly Name: " & objIIS.AppFriendlyName
Wscript.Echo "ASP Script Error Message: " & objIIS.AspScriptErrorMessage
Wscript.Echo "Application Isolated: " & objIIS.AppIsolated
Wscript.Echo "ASP Script Error Sent to Browser: " & _
    objIIS.AspScriptErrorSentToBrowser
Wscript.Echo "Application Package ID: " & objIIS.AppPackageID
Wscript.Echo "ASP Script File Cache Size: " & objIIS.AspScriptFileCacheSize
Wscript.Echo "Application Package Name: " & objIIS.AppPackageName
Wscript.Echo "ASP Script Language: " & objIIS.AspScriptLanguage
Wscript.Echo "Application Root: " & objIIS.AppRoot
Wscript.Echo "ASP Session Maximum: " & objIIS.AspSessionMax
Wscript.Echo "Application WAM Clsid: " & objIIS.AppWamClsid
Wscript.Echo "ASP Script Timeout: " & objIIS.AspScriptTimeout
Wscript.Echo "ASP Allow Out-of-Process Components: " & _
    objIIS.AspAllowOutOfProcComponents
Wscript.Echo "ASP Session Timeout: " & objIIS.AspSessionTimeout
Wscript.Echo "ASP Allow Session State: " & objIIS.AspAllowSessionState
Wscript.Echo "ASP Buffering On: " & objIIS.AspBufferingOn
Wscript.Echo "ASP Codepage: " & objIIS.AspCodepage
Wscript.Echo "ASP Enable Application Restart: " & _
    objIIS.AspEnableApplicationRestart
Wscript.Echo "ASP Enable ASP HTML Fallback: " & _
    objIIS.AspEnableAspHtmlFallback
Wscript.Echo "ASP Enabled Chunked Encoding: " & _
    objIIS.AspEnableChunkedEncoding
Wscript.Echo "ASP Enable parent Paths: " & objIIS.AspEnableParentPaths
Wscript.Echo "ASP Track Threading Model: " & objIIS.AspTrackThreadingModel
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Default Document: " & objIIS.DefaultDoc
Wscript.Echo "Authentication Persistence: " & objIIS.AuthPersistence
Wscript.Echo "Default Document Footer: " & objIIS.DefaultDocFooter
Wscript.Echo "Cache Control Custom: " & objIIS.CacheControlCustom
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
Wscript.Echo "Cache Control Maximum Age: " & objIIS.CacheControlMaxAge
Wscript.Echo "Directory Browse Flags: " & objIIS.DirBrowseFlags
Wscript.Echo "Cache Control No Cache: " & objIIS.CacheControlNoCache
Wscript.Echo "Directory Levels to Scan: " & objIIS.DirectoryLevelsToScan
Wscript.Echo "Cache ISAPI: " & objIIS.CacheISAPI
Wscript.Echo "Disable Socket Pooling: " & objIIS.DisableSocketPooling
Wscript.Echo "Content Indexed: " & objIIS.ContentIndexed
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Enable Document Footer: " & objIIS.EnableDocFooter
Wscript.Echo "Enable Reverse DNS: " & objIIS.EnableReverseDns
For Each strError in objIIS.HttpErrors
    Wscript.Echo "HTTP Error: " & strError
Next
Wscript.Echo "HTTP Expires: " & objIIS.HttpExpires
For Each strPic in objIIS.HttpPics
    Wscript.Echo "HTTP Pic: " & strPic.Name
Next
Wscript.Echo "Create CGI with New Console: " & _
    objIIS.CreateCGIWithNewConsole
Wscript.Echo "Create Process as User: " & objIIS.CreateProcessAsUser
For Each strApp in objIIS.InProcessIsapiApps
    Wscript.Echo "In-Process ISAPI Application: " & strApp
Next
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log ODBC Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log ODBC Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log File Local Time Rollover: " & _
    objIIS.LogFileLocaltimeRollover
Wscript.Echo "Log ODBC User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Logon Method: " & objIIS.LogonMethod
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log ODBC Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Type: " & objIIS.LogType
For Each strMap in objIIS.ScriptMaps
    Wscript.Echo "Script Map: " & strMap
Next
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
For Each strBinding in objIIS.ServerBindings
    Wscript.Echo "Server Binding: " & strBinding.Name
Next
Wscript.Echo "Server Comments: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & objIIS.ServerListenBacklog
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Server Listen Timeout: " & objIIS.ServerListenTimeout
Wscript.Echo "Password Cache Time-to-Live: " & _
    objIIS.PasswordCacheTTL
Wscript.Echo "Server Size: " & objIIS.ServerSize
Wscript.Echo "Password Change Flags: " & objIIS.PasswordChangeFlags
Wscript.Echo "SSI Exec Disable: " & objIIS.SSIExecDisable
Wscript.Echo "Password Expire Pre-Notify Days: " & _
    objIIS.PasswordExpirePrenotifyDays
Wscript.Echo "SSL Use DS Mapper: " & objIIS.SslUseDsMapper
Wscript.Echo "Pool IDC Timeout: " & objIIS.PoolIdcTimeout
Wscript.Echo "Process NTCR if Logged On: " & _
    objIIS.ProcessNTCRIfLoggedOn
Wscript.Echo "Upload Read-Ahead Size: " & _
    objIIS.UploadReadAheadSize
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "WAM User Name: " & objIIS.WAMUserName
For Each strHeader in objIIS.RedirectHeaders
    Wscript.Echo "Redirect Header: " & strHeader.Name
Next
Wscript.Echo "WAM User Password: " & objIIS.WAMUserPass

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web Directory Metabase Property

Description
Demonstration script that modifies a Web directory property (DefaultDocFooter) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/1/ROOT/aspnet_client")

objIIS.DefaultDocFooter = "footer.htm"
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web Server Metabase Property

Description
Demonstration script that modifies a Web server property (PasswordExpirePrenotifyDays) in the IIS metabase. This script modifies the metabase for a Web server named W3SVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/1")

objIIS.PasswordExpirePrenotifyDays = 10
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web Service Metabase Property

Description
Demonstration script that modifies a Web service property (ConnectionTimeout) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC")
objIIS.ConnectionTimeout = 60
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web Virtual Directory Metabase Property

Description
Demonstration script that modifies a Web virtual directory property (EnableReverseDNS) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/1/ROOT/Printers")

objIIS.EnableReverseDns = TRUE
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause a Web Server

Description
Pauses a Web server named W3SVC/2142295254 on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/2142295254")

objIIS.Pause

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start a Web Server

Description
Starts a Web server named W3SVC/2142295254 on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/2142295254")

objIIS.Start

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop a Web Server

Description
Stops a Web server named W3SVC/2142295254 on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/2142295254")

objIIS.Stop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


V erify Web Server Status

Description
Returns the status of the Web server W3SVC/2142295254.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/W3SVC/2142295254")
intStatus = objIIS.Status

Select Case intStatus
    Case 1 Wscript.Echo "The Web server is starting."
    Case 2 Wscript.Echo "The Web server is running."
    Case 3 Wscript.Echo "The Web server is stopping."
    Case 4 Wscript.Echo "The Web server is stopped."
    Case 5 Wscript.Echo "The Web server is pausing."
    Case 6 Wscript.Echo "The Web server is paused."
    Case 7 Wscript.Echo "The Web server is continuing."
End Select

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application as Part of an Application Pool

Description
Creates a new out-of-process application as part of the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppCreate3 OUT_OF_PROCESS,"MSSharePointAppPool", False
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application in a Virtual Directory

Description
Creates a new application in the virtual Web directoryW3SVC/1/ROOT/tsweb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppCreate(False)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application in a Virtual Directory as Part of an Application Pool

Description
Creates a new virtual directory application ad part of the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppCreate3 OUT_OF_PROCESS, "MSSharePointAppPool", _
       False
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application in a Web Directory

Description
Creates a new application in the Web directory W3SVC/2142295254/root/aspnet_client_folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppCreate(False)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Application in an Application Pool Using ADSI

Description
Creates an out-of-process Web application in the W3SVC/2142295254/root/aspnet_client_folder directory and adds it to the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

strComputer = "LocalHost"

Set objIIS = GetObject _
    ("IIS://" & strComputer & "/W3SVC/2142295254/root/aspnet_client_folder")
objIIS.AppCreate3 OUT_OF_PROCESS, "MSSharePointAppPool", False

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Out-of-Process Application in a Virtual Directory

Description
Creates an out-of-process application in virtual Web directory W3SVC/1/ROOT/tsweb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppCreate2(OUT_OF_PROCESS)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Out-of-Process Application in a Web Directory

Description
Creates an out-of-process application in the Web directory W3SVC/2142295254/root/aspnet_client_folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const OUT_OF_PROCESS = 1

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppCreate2(OUT_OF_PROCESS)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Web Directory Application

Description
Deletes the application found in the Web directory W3SVC/2142295254/root/aspnet_client_folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppDelete(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Web Service Application

Description
Deletes the Web service application named Remote Administration Tools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.RemoveApplication("Remote Administration Tools")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Application in a Virtual Directory

Description
Deletes the application found in the virtual Web directoryW3SVC/1/ROOT/tsweb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppDelete(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Web Directory Application

Description
Disables the application found in the Web directoryW3SVC/2142295254/root/aspnet_client_folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppDisable(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable an Application in a Virtual Directory

Description
Disables the application found in the virtual Web directory W3SVC/1/ROOT/tsweb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppDisable(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a Web Directory Application

Description
Enables the application found in the Web directoryW3SVC/2142295254/root/aspnet_client_folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppEnable(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a Web Service Application

Description
Enables the Web service application named Remote Administration Tools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.EnableApplication _
        ("Remote Administration Tools")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable an Application in a Virtual Directory

Description
Enables the application found in the virtual Web directory W3SVC/1/ROOT/tsweb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppEnable(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Configuration Cache Options

Description
Lists IIS application configuration cache options.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "ASP Disk Template Cache Directory: " & _
        objItem.AspDiskTemplateCacheDirectory
    Wscript.Echo "ASP Maximum Disk Template Cache Files: " & _
        objItem.AspMaxDiskTemplateCacheFiles
    Wscript.Echo "ASP Script Engine Cache Maximum: " & _
        objItem.AspScriptEngineCacheMax
    Wscript.Echo "ASP Script File Cache Size: " & _
        objItem.AspScriptFileCacheSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Configuration Debugging Options

Description
Lists IIS application configuration debugging options.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Application Allow Client Debug: " & _
        objItem.AppAllowClientDebug
    Wscript.Echo "Application Allow Debugging: " & _
        objItem.AppAllowDebugging
   Wscript.Echo "ASP Script Error Message: " & _
        objItem.AspScriptErrorMessage
    Wscript.Echo "ASP Script Error Sent To Browser: " & _
        objItem.AspScriptErrorSentToBrowser
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Configuration Mappings

Description
Lists IIS application configuration mappings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Cache ISAPI: " & objItem.CacheISAPI
    For i = 0 to Ubound(objItem.ScriptMaps)
        Wscript.Echo "Extension: " & objItem.ScriptMaps(i).Extensions
        Wscript.Echo "Included Verbs: " & _
            objItem.ScriptMaps(i).IncludedVerbs
        Wscript.Echo "Script Processor: " & _
            objItem.ScriptMaps(i).ScriptProcessor
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Configuration Options

Description
Lists IIS application configuration options.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "ASP Allow Session State: " & _
        objItem.AspAllowSessionState
    Wscript.Echo "ASP Buffering On: " & objItem.AspBufferingOn
    Wscript.Echo "ASP Enable Parent Paths: " & _
        objItem.AspEnableParentPaths
    Wscript.Echo "ASP Enable Sxs: " & objItem.AspEnableSxs
    Wscript.Echo "ASP Script Language: " & objItem.AspScriptLanguage
    Wscript.Echo "ASP Script Timeout: " & objItem.AspScriptTimeout
    Wscript.Echo "ASP Session Timeout: " & objItem.AspSessionTimeout
    Wscript.Echo "ASP Sxs Name: " & objItem.AspSxsName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Extension Mappings

Description
Lists IIS application extension mappings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.ScriptMaps)
        Wscript.Echo "Extension: " & objItem.ScriptMaps(i).Extensions
        Wscript.Echo "Included Verbs: " & _
            objItem.ScriptMaps(i).IncludedVerbs
        Wscript.Echo "Script Processor: " & _
            objItem.ScriptMaps(i).ScriptProcessor
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pool Setting Information

Description
Lists IIS application pool setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolSetting")

For Each objItem in colItems
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Application Pool AutoStart: " & _
        objItem.AppPoolAutoStart
    Wscript.Echo "Application Pool Command: " & objItem.AppPoolCommand
    Wscript.Echo "Application Pool Identity Type: " & _
        objItem.AppPoolIdentityType
    Wscript.Echo "Application Pool Queue Length: " & _
        objItem.AppPoolQueueLength
    Wscript.Echo "Application Pool Recycle Configuration Change: " & _
        objItem.AppPoolRecycleConfigChange
    Wscript.Echo "Application Pool Recycle ISAPI Unhealthy: " & _
        objItem.AppPoolRecycleIsapiUnhealthy
    Wscript.Echo "Application Pool Recycle Memory: " & _
        objItem.AppPoolRecycleMemory
    Wscript.Echo "Application Pool Recycle On-Demand: " & _
        objItem.AppPoolRecycleOnDemand
    Wscript.Echo "Application Pool Recycle Private Memory: " & _
        objItem.AppPoolRecyclePrivateMemory
    Wscript.Echo "Application Pool Recycle Requests: " & _
        objItem.AppPoolRecycleRequests
    Wscript.Echo "Application Pool Recycle Schedule: " & _
        objItem.AppPoolRecycleSchedule
    Wscript.Echo "Application Pool Recycle Time: " & _
        objItem.AppPoolRecycleTime
    Wscript.Echo "Application Pool State: " & objItem.AppPoolState
    Wscript.Echo "AutoShutdown Application Pool Exe: " & _
        objItem.AutoShutdownAppPoolExe
    Wscript.Echo "AutoShutdown Application Pool Parameters: " & _
        objItem.AutoShutdownAppPoolParams
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CPU Action: " & objItem.CPUAction
    Wscript.Echo "CPU Limit: " & objItem.CPULimit
    Wscript.Echo "CPU Reset Interval: " & objItem.CPUResetInterval
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disallow Overlapping Rotation: " & _
        objItem.DisallowOverlappingRotation
    Wscript.Echo "Disallow Rotation On Configuration Change: " & _
        objItem.DisallowRotationOnConfigChange
    Wscript.Echo "Idle Timeout: " & objItem.IdleTimeout
    Wscript.Echo "Load Balancer Capabilities: " & _
        objItem.LoadBalancerCapabilities
    Wscript.Echo "Log Event On Recycle: " & objItem.LogEventOnRecycle
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Maximum Processes: " & objItem.MaxProcesses
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Orphan Action Exe: " & objItem.OrphanActionExe
    Wscript.Echo "Orphan Action Parameters: " & objItem.OrphanActionParams
    Wscript.Echo "Orphan Worker Process: " & objItem.OrphanWorkerProcess
    Wscript.Echo "Periodic Restart Memory: " & objItem.PeriodicRestartMemory
    Wscript.Echo "Periodic Restart Private Memory: " & _
        objItem.PeriodicRestartPrivateMemory
    Wscript.Echo "Periodic Restart Requests: " & _
        objItem.PeriodicRestartRequests
    For Each strSchedule in objItem.PeriodicRestartSchedule
        Wscript.Echo "Periodic Restart Schedule: " & strSchedule
    Next
    Wscript.Echo "Periodic Restart Time: " & objItem.PeriodicRestartTime
    Wscript.Echo "Pinging Enabled: " & objItem.PingingEnabled
    Wscript.Echo "Ping Interval: " & objItem.PingInterval
    Wscript.Echo "Ping Response Time: " & objItem.PingResponseTime
    Wscript.Echo "Rapid Fail Protection: " & objItem.RapidFailProtection
    Wscript.Echo "Rapid Fail Protection Interval: " & _
        objItem.RapidFailProtectionInterval
    Wscript.Echo "Rapid Fail Protection Maximum Crashes: " & _
        objItem.RapidFailProtectionMaxCrashes
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SMP Affinitized: " & objItem.SMPAffinitized
    Wscript.Echo "SMP Processor Affinity Mask: " & _
        objItem.SMPProcessorAffinityMask
    Wscript.Echo "Startup Time Limit: " & objItem.StartupTimeLimit
    Wscript.Echo "WAM User Name: " & objItem.WAMUserName
    Wscript.Echo "WAM User Password: " & objItem.WAMUserPass
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pools Health Properties

Description
Lists IIS application pools health information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    Wscript.Echo "Pinging Enabled: " & objItem.PingingEnabled
    Wscript.Echo "Ping Interval: " & objItem.PingInterval
    Wscript.Echo "Rapid Fail Protection: " & _
        objItem.RapidFailProtection
    Wscript.Echo "Rapid Fail Protection Interval: " & _
        objItem.RapidFailProtectionInterval
    Wscript.Echo "Rapid Fail Protection Maximum Crashes: " & _
        objItem.RapidFailProtectionMaxCrashes
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "Startup Time Limit: " & objItem.StartupTimeLimit
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pools Identity Properties

Description
Lists identity properties for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    Wscript.Echo "WAM User Name: " & objItem.WAMUserName
    Wscript.Echo "WAM User Password: " & objItem.WAMUserPass
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pools Performance Properties

Description
Lists performance properties for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    Wscript.Echo "Application Pool Queue Length: " & _
        objItem.AppPoolQueueLength
    Wscript.Echo "CPU Action: " & objItem.CPUAction
    Wscript.Echo "CPU Limit: " & objItem.CPULimit
    Wscript.Echo "CPU Reset Interval: " & objItem.CPUResetInterval
    Wscript.Echo "Idle Timeout: " & objItem.IdleTimeout
    Wscript.Echo "Max Processes: " & objItem.MaxProcesses
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pools Recycling Properties

Description
Lists recycling properties for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    Wscript.Echo "Periodic Restart Memory: " & _
        objItem.PeriodicRestartMemory
    Wscript.Echo "Periodic Restart PrivateMemory: " & _
        objItem.PeriodicRestartPrivateMemory
    Wscript.Echo "Periodic Restart Requests: " & _
        objItem.PeriodicRestartRequests
    For Each strSchedule in objItem.PeriodicRestartSchedule
        Wscript.Echo "Periodic Restart Schedule: " & strSchedule
    Next
    Wscript.Echo "Periodic Restart Time: " & _
        objItem.PeriodicRestartTime
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Application Pools Setting Information

Description
Lists setting information for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Application Pool AutoStart: " & _
        objItem.AppPoolAutoStart
    Wscript.Echo "Application Pool Identity Type: " & _
        objItem.AppPoolIdentityType
    Wscript.Echo "Application Pool Queue Length: " & _
        objItem.AppPoolQueueLength
    Wscript.Echo "Application Pool Recycle Configuration Change: " & _
        objItem.AppPoolRecycleConfigChange
    Wscript.Echo "Application Pool Recycle ISAPI Unhealthy: " & _
        objItem.AppPoolRecycleIsapiUnhealthy
    Wscript.Echo "Application Pool Recycle Memory: " & _
        objItem.AppPoolRecycleMemory
    Wscript.Echo "Application Pool Recycle On-Demand: " & _
        objItem.AppPoolRecycleOnDemand
    Wscript.Echo "Application Pool Recycle Private Memory: " & _
        objItem.AppPoolRecyclePrivateMemory
    Wscript.Echo "Application Pool Recycle Requests: " & _
        objItem.AppPoolRecycleRequests
    Wscript.Echo "Application Pool Recycle Schedule: " & _
        objItem.AppPoolRecycleSchedule
    Wscript.Echo "Application Pool Recycle Time: " & _
        objItem.AppPoolRecycleTime
    Wscript.Echo "AutoShutdown Application Pool Exe: " & _
        objItem.AutoShutdownAppPoolExe
    Wscript.Echo "AutoShutdown Application Pool Parameters: " & _
        objItem.AutoShutdownAppPoolParams
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CPU Action: " & objItem.CPUAction
    Wscript.Echo "CPU Limit: " & objItem.CPULimit
    Wscript.Echo "CPU Reset Interval: " & objItem.CPUResetInterval
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disallow Overlapping Rotation: " & _
        objItem.DisallowOverlappingRotation
    Wscript.Echo "Disallow Rotation On Configuration Change: " & _
        objItem.DisallowRotationOnConfigChange
    Wscript.Echo "Idle Timeout: " & objItem.IdleTimeout
    Wscript.Echo "Load Balancer Capabilities: " & _
        objItem.LoadBalancerCapabilities
    Wscript.Echo "Log Event On Recycle: " & objItem.LogEventOnRecycle
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Maximum Processes: " & objItem.MaxProcesses
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Orphan Action Exe: " & objItem.OrphanActionExe
    Wscript.Echo "Orphan Action Parameters: " & _
        objItem.OrphanActionParams
    Wscript.Echo "Orphan Worker Process: " & _
        objItem.OrphanWorkerProcess
    Wscript.Echo "Periodic Restart Memory: " & _
        objItem.PeriodicRestartMemory
    Wscript.Echo "Periodic Restart PrivateMemory: " & _
        objItem.PeriodicRestartPrivateMemory
    Wscript.Echo "Periodic Restart Requests: " & _
        objItem.PeriodicRestartRequests
    For Each strSchedule in objItem.PeriodicRestartSchedule
        Wscript.Echo "Periodic Restart Schedule: " & strSchedule
    Next
    Wscript.Echo "Periodic Restart Time: " & objItem.PeriodicRestartTime
    Wscript.Echo "Pinging Enabled: " & objItem.PingingEnabled
    Wscript.Echo "Ping Interval: " & objItem.PingInterval
    Wscript.Echo "Ping Response Time: " & objItem.PingResponseTime
    Wscript.Echo "Rapid Fail Protection: " & objItem.RapidFailProtection
    Wscript.Echo "Rapid Fail Protection Interval: " & _
        objItem.RapidFailProtectionInterval
    Wscript.Echo "Rapid Fail Protection Maximum Crashes: " & _
        objItem.RapidFailProtectionMaxCrashes
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SMP Affinitized: " & objItem.SMPAffinitized
    Wscript.Echo "SMP Processor Affinity Mask: " & _
        objItem.SMPProcessorAffinityMask
    Wscript.Echo "Startup Time Limit: " & objItem.StartupTimeLimit
    Wscript.Echo "WAM User Name: " & objItem.WAMUserName
    Wscript.Echo "WAM User Password: " & objItem.WAMUserPass
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Applications in an Application Pool

Description
Lists all the applications in the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsApplicationPool Where Name = " & _
        "'W3SVC/AppPools/MSSharePointAppPool'")

For Each objItem in colItems
    objItem.EnumAppsInPool arrApplications
    For i = 0 to Ubound(arrApplications)
        Wscript.Echo arrApplications(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Applications That Depend on a Given Group ID

Description
Lists all the applications dependant on the ASP group ID.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * From IIsWebService")

For Each objItem in colItems
    objItem.QueryGroupIDStatus "ASP", arrGroups
    For i = 0 to Ubound(arrGroups)
        Wscript.Echo arrGroups(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Applications

Description
Lists IIS Web service applications.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.ListApplications arrApplications
    For i = 0 to Ubound(arrApplications)
        Wscript.Echo arrApplications(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an Application Pools Metabase Setting

Description
Demonstration script that modifies an application pools metabase setting (RapidFailProtection).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    objItem.RapidFailProtection = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Configuration Cache Options

Description
Demonstration script that modifies IIS application configuration cache options.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.AspDiskTemplateCacheDirectory = "C:\Cache"
    objItem.AspMaxDiskTemplateCacheFiles = 5000
    objItem.AspScriptEngineCacheMax = 250
    objItem.AspScriptFileCacheSize = 500
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Configuration Debugging Options

Description
Demonstration script that modifies IIS application configuration debugging options.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.AppAllowClientDebug = True
    objItem.AppAllowDebugging = True
    objItem.AspScriptErrorMessage = "Sorry, an error has occurred."
    objItem.AspScriptErrorSentToBrowser = True
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Pools Health Properties

Description
Demonstration script that modifies IIS application pools health properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    objItem.PingingEnabled = True
    objItem.PingInterval = 60
    objItem.RapidFailProtection = True
    objItem.RapidFailProtectionInterval = 10
    objItem.RapidFailProtectionMaxCrashes = 10
    objItem.ShutdownTimeLimit = 120
    objItem.StartupTimeLimit = 120
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Pools Identity Properties

Description
Demonstration script that modifies the user name and password for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    objItem.WAMUserName = "TestUser"
    objItem.WAMUserPass = "ur^354Hdf"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Pools Performance Properties

Description
Demonstration script that modifies performance settings for IIS application pools.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    objItem.AppPoolQueueLength = 5000
    objItem.CPUAction = 1
    objItem.CPULimit = 50000
    objItem.CPUResetInterval= 30
    objItem.IdleTimeout = 30
    objItem.MaxProcesses = 2
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Application Pools Recycling Properties

Description
Demonstration script that modifies IIS application pools recycling settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsApplicationPoolsSetting")

For Each objItem in colItems
    objItem.PeriodicRestartMemory = 1000000
    objItem.PeriodicRestartPrivateMemory = 1000000
    objItem.PeriodicRestartRequests = 5
    objItem.PeriodicRestartTime = 3480
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Recycle an Application Pool

Description
Demonstration script that recycles the MsSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsApplicationPool Where Name = " & _
        "'W3SVC/AppPools/MSSharePointAppPool'")

For Each objItem in colItems
    objItem.Recycle
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restart an Application in a Virtual Directory

Description
Demonstration script that restarts the application in the W3SVC/1/ROOT/tsweb virtual Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.ASPAppRestart
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restart an Application in a Web Directory

Description
Demonstration script that restarts the application in the W3SVC/2142295254/root/aspnet_client_folder Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.ASPAppRestart
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start an Application Pool

Description
Demonstration script that starts the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsApplicationPool Where Name = " & _
        "'W3SVC/AppPools/MSSharePointAppPool'")

For Each objItem in colItems
    objItem.Start
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop an Application Pool

Description
Demonstration script that stops the MSSharePointAppPool application pool.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsApplicationPool Where Name = " & _
        "'W3SVC/AppPools/MSSharePointAppPool'")

For Each objItem in colItems
    objItem.Stop
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unload an Application from a Web Directory

Description
Demonstration script that unloads the application in the W3SVC/2142295254/root/aspnet_client_folder Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
   objItem.AppUnload(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unload an Application in a Virtual Directory

Description
Demonstration script that unloads the application in the W3SVC/1/ROOT/tsweb virtual Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
   objItem.AppUnload(True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the Status of a Web Directory Application

Description
Returns the status of the application in the W3SVC/2142295254/root/aspnet_client_folder Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebDirectory Where Name = " & _
        "'W3SVC/2142295254/root/aspnet_client_folder'")

For Each objItem in colItems
    strStatus = objItem.AppGetStatus
    If strStatus = 2 Then
        Wscript.Echo "The application is running."
    ElseIf strStatus = 3 Then
        Wscript.Echo "The application is stopped."
    Else
        Wscript.Echo _
            "The status could not be determined."
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the Status of an Application in a Virtual Directory

Description
Returns the status of the application in the W3SVC/1/ROOT/tsweb virtual Web directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebVirtualDir Where Name = " & _
        "'W3SVC/1/ROOT/tsweb'")

For Each objItem in colItems
    strStatus = objItem.AppGetStatus
    If strStatus = 2 Then
        Wscript.Echo "The application is running."
    ElseIf strStatus = 3 Then
        Wscript.Echo "The application is stopped."
    Else
        Wscript.Echo _
            "The status could not be determined."
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Authentication Methods

Description
Lists IIS authentication methods.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Realm: " & objItem.Realm
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS IP Address and Domain Restrictions

Description
Lists IIS IP address and domain restrictions.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsIPSecuritySetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    For Each strDeny in objItem.DomainDeny
        Wscript.Echo "Domain Deny: " & strDeny
    Next
    For Each strGrant in objItem.DomainGrant
        Wscript.Echo "Domain Grant: " & strGrant
    Next
    Wscript.Echo "Grant By Default: " & objItem.GrantByDefault
    For Each strDeny in objItem.IPDeny
        Wscript.Echo "IP Deny: " & strDeny
    Next
    For Each strGrant in objItem.IPGrant
        Wscript.Echo "IP Grant: " & strGrant
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add an Extension File

Description
Adds the BITS_Update.dll extension file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.AddExtensionFile _
        "C:\WINDOWS\system32\bits_update.dll", False, _
            "BITSEXT", True, "BITS Update"
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Back Up the Metabase Using a Password

Description
Backs up the metabase on the local computer, using the password er$3qld9o.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFE
Const MD_BACKUP_OVERWRITE = 1

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

objComputer.BackupWithPassword "ScriptedBackup", _
    MD_BACKUP_HIGHEST_VERSION, MD_BACKUP_OVERWRITE, _
        "er$3qld9o"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Backup

Description
Deletes a metabase backup named ScriptedBackup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const BACKUP_VERSION = 0

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

objComputer.DeleteBackup "ScriptedBackup", BACKUP_VERSION

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Extension File Record

Description
Deletes the BITS_Update.dll extension file record.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.DeleteExtensionFileRecord _
        "C:\WINDOWS\system32\bits_update.dll"
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Web Service Extension

Description
Disables a Web service extension named WEBDAV.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * From IIsWebService")

For Each objItem in colItems
    objItem.DisableWebServiceExtension("WEBDAV")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable an Extension File

Description
Disables the BITSsrv.dll extension file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.DisableExtensionFile _
        ("C:\WINDOWS\system32\bitssrv.dll")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable a Web Service Extension

Description
Enables a Web service extension named WEBDAV.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.EnableWebServiceExtension("WEBDAV")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable an Extension File

Description
Enables the extension file named BITSsrv.dll.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.EnableExtensionFile _
        ("C:\WINDOWS\system32\bitssrv.dll")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating History Files

Description
Lists all the IIS history files found on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

intIndex = 0

Do While True
    strName = ""
    objComputer.EnumHistory strLocation, intMajorVersion, _
        intMinorVersion, strDateTime, intIndex
    If (Err.Number <> 0) Then
        Exit Do
    End If

    dtDate = DateSerial(Mid(strDateTime, 1, 4), _
        Mid(strDateTime, 5, 2), Mid(strDateTime, 7, 2))
    dtTime = TimeSerial(Mid(strDateTime, 9, 2), _
        Mid(strDateTime, 11, 2), Mid(strDateTime, 13, 2))
    strFmtDateTime = FormatDateTime(dtDate) & " " & _
        FormatDateTime(dtTime, vbLongTime)

    Wscript.Echo "Location: " & strLocation
    WScript.Echo "Major Version: " & intMajorVersion
    WScript.Echo "Minor Version: " & intMin0rVersion
    WScript.Echo "Date and Time: " & strFmtDateTime

    intIndex = intIndex + 1
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerating IIsObject Class Instances -- WMI

Description
Lists all the instances of the IIsObject class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsObject")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Export a Section of the Metabase

Description
Exports a section of the metabase using the password er$3qld9o.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const EXPORT_CHILDREN = 0

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsComputer")

For Each objItem in colItems
    objItem.Export "er$3qld9o", "C:\backups\export.xml", _
        "/lm/logging/custom logging", EXPORT_CHILDREN
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Import a Metabase Section

Description
Imports a section of the metabase using the password er$3qld9o.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const IMPORT_MERGE = 4

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsComputer")

For Each objItem in colItems
    objItem.Import "er$3qld9o", "C:\backups\export.xml", _
        "/lm/logging/custom logging", _
            "/lm/logging/custom logging", IMPORT_MERGE
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Access Control Entries

Description
Lists IIS access control entries.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsACE")

For Each objItem in colItems
    Wscript.Echo "Access Mask: " & objItem.AccessMask
    Wscript.Echo "Ace Flags: " & objItem.AceFlags
    Wscript.Echo "Ace Type: " & objItem.AceType
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Inherited Object Type: " & _
        objItem.InheritedObjectType
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Object Type: " & objItem.ObjectType
    Wscript.Echo "Trustee: " & objItem.Trustee
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Access Control Information

Description
Lists IIS access control information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsAdminACL")

For Each objItem in colItems
    Wscript.Echo "Group: " & objItem.Group
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Owner: " & objItem.Owner
    Wscript.Echo "Control Flags: " & objItem.ControlFlags
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Backup Files

Description
Lists all IIS backup files found on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const MD_BACKUP_NO_MORE_BACKUPS = &H80070103
strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

intIndex = 0

Do While True
    strName = ""
    objComputer.EnumBackups strName, intIndex, _
        strVersion, strDateTime
    If (Err.Number <> 0) Then
        If (Err.Number = MD_BACKUP_NO_MORE_BACKUPS) Then
            Exit Do
        End If
    End If

    dtDate = DateSerial(Mid(strDateTime, 1, 4), _
        Mid(strDateTime, 5, 2), Mid(strDateTime, 7, 2))
    dtTime = TimeSerial(Mid(strDateTime, 9, 2), _
        Mid(strDateTime, 11, 2), Mid(strDateTime, 13, 2))
    strFmtDateTime = FormatDateTime(dtDate) & " " & _
        FormatDateTime(dtTime, vbLongTime)

    WScript.Echo "Name: " & strName
    Wscript.Echo "Version Number: " & strVersion
    Wscript.Echo "Backup Date: " & strFmtDateTime

    intIndex = intIndex + 1
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Setting Information

Description
Lists IIS computer setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsComputerSetting")

For Each objItem in colItems
    Wscript.Echo "Enable Edit While Running: " & _
        objItem.EnableEditWhileRunning
    Wscript.Echo "Enable History: " & objItem.EnableHistory
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Bandwidth Blocked: " & _
        objItem.MaxBandwidthBlocked
    Wscript.Echo "Maximum Error Files: " & objItem.MaxErrorFiles
    Wscript.Echo "Maximum History Files: " & objItem.MaxHistoryFiles
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Extension Files

Description
Lists all IIS extension files.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.ListExtensionFiles arrFiles
    For i = 0 to Ubound(arrFiles)
        Wscript.Echo arrFiles(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsObjectSetting Class Instances

Description
Lists all instances of the IIsObjectSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsObjectSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IP Security Setting Information

Description
Lists IIS IP security setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsIPSecuritySetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    For Each strDeny in objItem.DomainDeny
        Wscript.Echo "Domain Deny: " & strDeny
    Next
    For Each strGrant in objItem.DomainGrant
        Wscript.Echo "Domain Grant: " & strGrant
    Next
    Wscript.Echo "Grant By Default: " & objItem.GrantByDefault
    For Each strDeny in objItem.IPDeny
        Wscript.Echo "IP Deny: " & strDeny
    Next
    For Each strGrant in objItem.IPGrant
        Wscript.Echo "IP Grant: " & strGrant
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List MIME Maps

Description
Lists IIS MIME maps.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsMimeMap")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List MIME Type Properties

Description
Lists IIS MIME map extensions and types.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.MimeMap)
        Wscript.Echo "Extension: " & objItem.MimeMap(i).Extension
        Wscript.Echo "MIME Type: " & objItem.MimeMap(i).MimeType
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Script Maps

Description
Lists IIS script maps and related property values.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.ScriptMaps)
        Wscript.Echo "Extension: " & _
            objItem.ScriptMaps(i).Extensions
        Wscript.Echo "Flags: " & _
            objItem.ScriptMaps(i).Flags
        Wscript.Echo "Included Verbs: " & _
            objItem.ScriptMaps(i).IncludedVerbs
        Wscript.Echo "Script Processor: " & _
            objItem.ScriptMaps(i).ScriptProcessor
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Secure Bindings

Description
Lists IIS secure binding information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.SecureBindings)
        Wscript.Echo "Port: " & _
            objItem.SecureBindings(i).Port
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Server Bindings

Description
Lists IIS server binding information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.ServerBindings)
        Wscript.Echo "Port: " & _
            objItem.ServerBindings(i).Port
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the IIS Computer Name

Description
Lists the name of the computer where IIS is running.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsComputer")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Web Service Extension Restriction List

Description
Lists all items on the Web service extension restriction list.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.WebSvcExtRestrictionList)
        Wscript.Echo "Server Extension: " & _
            objItem.WebSvcExtRestrictionList(i)._
                ServerExtension
        Wscript.Echo "Access: " & _
            objItem.WebSvcExtRestrictionList(i).Access
        Wscript.Echo "Deletable: " & _
            objItem.WebSvcExtRestrictionList(i).Deletable
        Wscript.Echo "Description: " & _
            objItem.WebSvcExtRestrictionList(i).Description
        Wscript.Echo "File Path: " & _
            objItem.WebSvcExtRestrictionList(i).FilePath
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server MIME Maps

Description
Lists all Web server MIME map extensions and types.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServerSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.MimeMap)
        Wscript.Echo "Extension: " & objItem.MimeMap(i).Extension
        Wscript.Echo "MIME Type: " & objItem.MimeMap(i).MimeType
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Extension Restrictions

Description
List information about Web service extension restrictions.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    For i = 0 to Ubound(objItem.WebSvcExtRestrictionList)
        Wscript.Echo "Access: " & _
            objItem.WebSvcExtRestrictionList(i).Access
        Wscript.Echo "File Path: " & _
            objItem.WebSvcExtRestrictionList(i).FilePath
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Extensions

Description
Lists all IIS Web service extensions.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    objItem.ListWebServiceExtensions arrExtensions
    For i = 0 to Ubound(arrExtensions)
        Wscript.Echo arrExtensions(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Local Computer Properties

Description
Demonstration script that modifies IIS local computer properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsComputerSetting")

For Each objItem in colItems
    objItem.EnableEditWhileRunning = 1
    objItem.EnableHistory = 1
    objItem.MaxHistoryFiles = 50
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore a History File

Description
Restore an IIS history file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MAJOR_VERSION = 257
Const MINOR_VERSION = 0

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

objComputer.RestoreHistory _
    "C:\WINDOWS\System32\Inetsrv\History\", _
        MAJOR_VERSION, MINOR_VERSION, 0

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore the Metabase Using a Password

Description
Restores an IIS metabase backup named ScriptedBackup using a password of er$3qld9o.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MD_BACKUP_HIGHEST_VERSION = &HFFFFFFFE

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

objComputer.RestoreWithPassword _
    "ScriptedBackup", MD_BACKUP_HIGHEST_VERSION, 0, _
         "er$3qld9o"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save a History File

Description
Saves an IIS history file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."

Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objComputer = _
    objWMIService.Get("IIsComputer.Name='LM'")

objComputer.SaveData

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Edit While Running Property Value

Description
Indicates whether IIS settings can be edited while the service is running.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsComputerSetting")

For Each objItem in colItems
    Wscript.Echo "Enable Edit While Running: " & _
        objItem.EnableEditWhileRunning
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify IIS Isolation Mode

Description
Verifies whether or not IIS is running in worker process isolation mode.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebService")

For Each objItem in colItems
    intMode = objItem.GetCurrentMode
    If intMode = 0 Then
        Wscript.Echo _
            "IIS is in IIS 5.0 isolation mode."
    ElseIf intMode = 1 Then
        Wscript.Echo _
            "IIS is in worker process isolation mode."
    Else
        Wscript.Echo _
            "The current mode cannot be determined."
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the IIS Server Version

Description
Returns the version of IIS running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebInfo")

For Each objItem in colItems
    Wscript.Echo "Major IIS Version Number: " & _
        objItem.MajorIIsVersionNumber
    Wscript.Echo "Minor IIS Version Number: " & _
        objItem.MinorIIsVersionNumber
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List BITS Server Extension Properties

Description
Displays BITS server extension properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "BITS Host ID: " & objItem.BITSHostId
    Wscript.Echo "BITS Host ID Fallback Timeout: " & _
        objItem.BITSHostIdFallbackTimeout
    Wscript.Echo "BITS Maximum Upload Size: " & _
        objItem.BITSMaximumUploadSize
    Wscript.Echo "BITS Server Notification Type: " & _
        objItem.BITSServerNotificationType
    Wscript.Echo "BITS Server Notification URL: " & _
        objItem.BITSServerNotificationURL
    Wscript.Echo "BITS Session Timeout: " & objItem.BITSSessionTimeout
    Wscript.Echo "BITS Upload Enabled: " & objItem.BITSUploadEnabled
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Instances of the IIsCertMapper Class

Description
Demonstration script that displays all instances of the IIsCertMapper class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsCertMapper")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Instances of the IIsCertMapperSetting Class

Description
Demonstration script that displays all instances of the IIsCertMapperSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCertMapperSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Compression Schemes Properties

Description
Returns information about compression schemes settings for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionSchemesSetting")

For Each objItem in colItems
    Wscript.Echo "Hc Compression Directory: " & _
        objItem.HcCompressionDirectory
    Wscript.Echo "Hc Do Dynamic Compression: " & _
        objItem.HcDoDynamicCompression
    Wscript.Echo "Hc Do Static Compression: " & _
        objItem.HcDoStaticCompression
    Wscript.Echo "Hc Maximum Disk Space Usage: " & _
        objItem.HcMaxDiskSpaceUsage
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Compression Scheme Setting Information

Description
Displays IIS compression scheme setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionSchemeSetting")

For Each objItem in colItems
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Hc Compression Dll: " & _
        objItem.HcCompressionDll
    Wscript.Echo "Hc Create Flags: " & objItem.HcCreateFlags
    Wscript.Echo "Hc Do Dynamic Compression: " & _
        objItem.HcDoDynamicCompression
    Wscript.Echo "Hc Do On-Demand Compression: " & _
        objItem.HcDoOnDemandCompression
    Wscript.Echo "Hc Do Static Compression: " & _
        objItem.HcDoStaticCompression
    Wscript.Echo "Hc Dynamic Compression Level: " & _
        objItem.HcDynamicCompressionLevel
    For Each strExtension in objItem.HcFileExtensions
        Wscript.Echo "Hc File Extensions: " & strExtension
    Next
    Wscript.Echo "Hc On-Demand Compression Level: " & _
        objItem.HcOnDemandCompLevel
    Wscript.Echo "Hc Priority: " & objItem.HcPriority
    For Each strExtension in objItem.HcScriptFileExtensions
        Wscript.Echo "Hc Script File Extensions: " & strExtension
    Next
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Compression Schemes Setting Information

Description
Displays setting information for IIS compression schemes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionSchemesSetting")

For Each objItem in colItems
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Hc Cache Control Header: " & _
        objItem.HcCacheControlHeader
    Wscript.Echo "Hc Compression Buffer Size: " & _
        objItem.HcCompressionBufferSize
    Wscript.Echo "Hc Compression Directory: " & _
        objItem.HcCompressionDirectory
    Wscript.Echo "Hc Do Disk Space Limiting: " & _
        objItem.HcDoDiskSpaceLimiting
    Wscript.Echo "Hc Do DynamicC ompression: " & _
        objItem.HcDoDynamicCompression
    Wscript.Echo "Hc Do On-Demand Compression: " & _
        objItem.HcDoOnDemandCompression
    Wscript.Echo "Hc Do Static Compression: " & _
        objItem.HcDoStaticCompression
    Wscript.Echo "Hc Expires Header: " & objItem.HcExpiresHeader
    Wscript.Echo "Hc Files Deleted Per Disk Free: " & _
        objItem.HcFilesDeletedPerDiskFree
    Wscript.Echo "Hc I/O Buffer Size: " & objItem.HcIoBufferSize
    Wscript.Echo "Hc Maximum Disk Space Usage: " & _
        objItem.HcMaxDiskSpaceUsage
    Wscript.Echo "Hc Maximum Queue Length: " & _
        objItem.HcMaxQueueLength
    Wscript.Echo "Hc Minimum File Size For Compression: " & _
        objItem.HcMinFileSizeForComp
    Wscript.Echo "Hc No Compression For Http 1.0: " & _
        objItem.HcNoCompressionForHttp10
    Wscript.Echo "Hc No Compression For Proxies: " & _
        objItem.HcNoCompressionForProxies
    Wscript.Echo "Hc No Compression For Range: " & _
        objItem.HcNoCompressionForRange
    Wscript.Echo "Hc Send Cache Headers: " & _
        objItem.HcSendCacheHeaders
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsCompressionScheme Instances

Description
Demonstration script that displays all instances of the IIsCompressionScheme class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionScheme")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsCompressionSchemes Instances

Description
Demonstration script that displays all instances of the IIsCompressionSchemes class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionSchemes")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Filter Setting Information

Description
Displays IIS filter setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFilterSetting")

For Each objItem in colItems
    Wscript.Echo "Filter Description: " & objItem.FilterDescription
    Wscript.Echo "Filter Enable Cache: " & objItem.FilterEnableCache
    Wscript.Echo "Filter Enabled: " & objItem.FilterEnabled
    Wscript.Echo "Filter Flags: " & objItem.FilterFlags
    Wscript.Echo "Filter Path: " & objItem.FilterPath
    Wscript.Echo "Filter State: " & objItem.FilterState
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Notify Access Denied: " &  _
        objItem.NotifyAccessDenied
    Wscript.Echo "Notify Authentication Complete: " &  _
        objItem.NotifyAuthComplete
    Wscript.Echo "Notify Authentication: " &  _
        objItem.NotifyAuthentication
    Wscript.Echo "Notify End Of Net Session: " &  _
        objItem.NotifyEndOfNetSession
    Wscript.Echo "Notify End Of Request: " &  _
        objItem.NotifyEndOfRequest
    Wscript.Echo "Notify Log: " & objItem.NotifyLog
    Wscript.Echo "Notify Non-Secure Port: " &  _
        objItem.NotifyNonSecurePort
    Wscript.Echo "Notify Order High: " & objItem.NotifyOrderHigh
    Wscript.Echo "Notify Order Low: " & objItem.NotifyOrderLow
    Wscript.Echo "Notify Order Medium: " & objItem.NotifyOrderMedium
    Wscript.Echo "Notify Pre-Proc Headers: " &  _
        objItem.NotifyPreProcHeaders
    Wscript.Echo "Notify Read Raw Data: " &  _
        objItem.NotifyReadRawData
    Wscript.Echo "Notify Secure Port: " & objItem.NotifySecurePort
    Wscript.Echo "Notify Send Raw Data: " &  _
        objItem.NotifySendRawData
    Wscript.Echo "Notify Send Response: " &  _
        objItem.NotifySendResponse
    Wscript.Echo "Notify Url Map: " & objItem.NotifyUrlMap
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIS Filters

Description
Displays a list of IIS filters.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsFilters")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Instances of the IIsFilter Class

Description
Demonstration script that displays all instances of the IIsFilter class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsFilter")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List ISAPI Filters

Description
Displays a list of ISAPI filters, their path, and their current state.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFilterSetting")

For Each objItem in colItems
    Wscript.Echo "Filter Path: " & objItem.FilterPath
    Wscript.Echo "Filter State: " & objItem.FilterState
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an IIS Filter Setting Metabase Property

Description
Demonstration script that modifies an IISFilterSetting property (FilterEnabled).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFilterSetting")

For Each objItem in colItems
    objItem.FilterEnabled = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Continue an FTP Server

Description
Resumes an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsFtpServer Where Name = " & _
        "'MSFTPSVC/1'")

For Each objItem in colItems
    objItem.Continue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a New FTP Site

Description
Creates a new FTP site named Test FTP site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objWebService = objWMIService.ExecQuery _
    ("Select * From IISFTPService")

arrBindings = Array(0)
Set arrBindings(0) = _
    objWMIService.Get("ServerBinding").SpawnInstance_()
arrBindings(0).IP = "192.168.1.1"
arrBindings(0).Port = "8383"
arrBindings(0).Hostname = "atl-ws-01"

For Each objItem in objWebService
    objItem.CreateNewSite "Test FTP Site", arrBindings, _
        "c:\inetpub\ftproot"
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Basic FTP Site Properties

Description
Displays basic default information for FTP sites on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Server Comment: " & objItem.ServerComment
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Server Setting Information

Description
Displays information about all the FTP sites on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & _
        objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "AD Connections Password: " & _
        objItem.ADConnectionsPassword
    Wscript.Echo "AD Connections User Name: " & _
        objItem.ADConnectionsUserName
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Anonymous Only: " & objItem.AnonymousOnly
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & _
        objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
    For Each objMessage in objItem.BannerMessage
        Wscript.Echo "Banner Message: " & objMessage
    Next
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Cluster Enabled: " & objItem.ClusterEnabled
    Wscript.Echo "Connection Timeout: " & _
        objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disable Socket Pooling: " & _
        objItem.DisableSocketPooling
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Exit Message: " & objItem.ExitMessage
    Wscript.Echo "FTP Directory Browse Show Long Date: " & _
        objItem.FtpDirBrowseShowLongDate
    Wscript.Echo "FTP Log in Utf8: " & objItem.FtpLogInUtf8
    For Each objMessage in objItem.GreetingMessage
        Wscript.Echo "Greeting Message: " & objMessage
    Next
    Wscript.Echo "Log Anonymous: " & objItem.LogAnonymous
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File Uri Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Local Time Rollover: " & _
        objItem.LogFileLocaltimeRollover
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Non-Anonymous: " & objItem.LogNonAnonymous
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Clients Message: " & _
        objItem.MaxClientsMessage
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "MS-DOS Directory Output: " & objItem.MSDOSDirOutput
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Realm: " & objItem.Realm
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Command: " & objItem.ServerCommand
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server ID: " & objItem.ServerID
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Server Size: " & objItem.ServerSize
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "User Isolation Mode: " & objItem.UserIsolationMode
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Server Version

Description
Returns the version number of the FTP service running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsFtpInfo")

For Each objItem in colItems
    Wscript.Echo "Major IIS Version Number: " & objItem.MajorIIsVersionNumber
    Wscript.Echo "Minor IIS Version Number: " & objItem.MinorIIsVersionNumber
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Service Setting Properties

Description
Returns default metabase values for the FTP service running on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "AD Connections Password: " & _
        objItem.ADConnectionsPassword
    Wscript.Echo "AD Connections User Name: " & _
        objItem.ADConnectionsUserName
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Anonymous Only: " & objItem.AnonymousOnly
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
    For Each objMessage in objItem.BannerMessage
        Wscript.Echo "Banner Message: " & objMessage
    Next
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Levels To Scan: " & _
        objItem.DirectoryLevelsToScan
    Wscript.Echo "Disable Socket Pooling: " & _
        objItem.DisableSocketPooling
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Downlevel Admin Instance: " & _
        objItem.DownlevelAdminInstance
    Wscript.Echo "Exit Message: " & objItem.ExitMessage
    Wscript.Echo "FTP Directory Browse Show Long Date: " & _
        objItem.FtpDirBrowseShowLongDate
    Wscript.Echo "FFTP Log in Utf8: " & objItem.FtpLogInUtf8
    For Each objMessage in objItem.GreetingMessage
        Wscript.Echo "Greeting Message: " & objMessage
    Next
    Wscript.Echo "Log Anonymous: " & objItem.LogAnonymous
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & _
        objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File ServerPort: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & _
        objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & _
        objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Local Time Rollover: " & _
        objItem.LogFileLocaltimeRollover
    Wscript.Echo "Log FileP eriod: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Non-Anonymous: " & objItem.LogNonAnonymous
    Wscript.Echo "Log Odbc Data Source: " & _
        objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Clients Message: " & _
        objItem.MaxClientsMessage
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "MS-DOS Directory Output: " & _
        objItem.MSDOSDirOutput
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Passive Port Range: " & objItem.PassivePortRange
    Wscript.Echo "Realm: " & objItem.Realm
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Command: " & objItem.ServerCommand
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Server Size: " & objItem.ServerSize
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "User Isolation Mode: " & _
        objItem.UserIsolationMode
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Site Home Directory Properties

Description
Lists default home directory properties for FTP sites on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "MS-DOS Directory Output: " & _
        objItem.MSDOSDirOutput
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Site Messages

Description
Displays default metabase FTP site messages for an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    For Each objMessage in objItem.BannerMessage
        Wscript.Echo "Banner Message: " & objMessage
    Next
    Wscript.Echo "Exit Message: " & objItem.ExitMessage
    For Each objMessage in objItem.GreetingMessage
        Wscript.Echo "Greeting Message: " & objMessage
    Next
    Wscript.Echo "Maximum Clients Message: " & _
        objItem.MaxClientsMessage
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Site Security Account Properties

Description
Displays default metabase FTP security account settings for an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Anonymous Only: " & objItem.AnonymousOnly
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Virtual Directories

Description
Lists the names of all the virtual FTP directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpVirtualDir")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List FTP Virtual Directory Properties

Description
Lists the properties of all the virtual FTP directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " &  _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "FTP Directory Browse Show Long Date: " & _
        objItem.FtpDirBrowseShowLongDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "UNC Password: " & objItem.UNCPassword
    Wscript.Echo "UNC User Name: " & objItem.UNCUserName
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Information About the FTP Service

Description
Lists configuration settings for the FTP server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsFtpService")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check Point: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo "Process Id: " & objItem.ProcessId
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Basic FTP Site Properties

Description
Demonstration script that modifies basic FTP site global metabase on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    objItem.ConnectionTimeout = 600
    objItem.DontLog = True
    objItem.MaxConnections = 50
    objItem.ServerComment = "This server is for IT use only."
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify FTP Site Home Directory Properties

Description
Demonstration script that modifies the global FTP home directory metabase settings on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    objItem.MSDOSDirOutput = False
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify FTP Site Security Account Properties

Description
Demonstration script that modifies global FTP security account metabase settings on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpServiceSetting")

For Each objItem in colItems
    objItem.AllowAnonymous = True
    objItem.AnonymousOnly = True
    objItem.AnonymousUserName = "TestUser"
    objItem.AnonymousUserPass = "password"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause an FTP Server

Description
Pauses an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsFtpServer Where Name = " & _
        "'MSFTPSVC/1'")

For Each objItem in colItems
    objItem.Pause
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start an FTP Server

Description
Starts an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsFtpServer Where Name = " & _
        "'MSFTPSVC/1'")

For Each objItem in colItems
    objItem.Start
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop an FTP Server

Description
Stops an FTP server named MSFTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsFtpServer Where Name = " & _
        "'MSFTPSVC/1'")

For Each objItem in colItems
    objItem.Stop
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Global Default Server Information Using WMI

Description
Returns global metabase property values for the IMAP service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsImapServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & _
        objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Authentication Anonymous: " & _
        objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "AuthenticationPassport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connection Timeout: " & _
        objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "IMAP Clear Text Provider: " & _
        objItem.ImapClearTextProvider
    Wscript.Echo "IMAP Default Domain: " & objItem.ImapDefaultDomain
    Wscript.Echo "IMAP Expire Delay: " & objItem.ImapExpireDelay
    Wscript.Echo "IMAP Expire Mail: " & objItem.ImapExpireMail
    Wscript.Echo "IMAP Expire Start: " & objItem.ImapExpireStart
    Wscript.Echo "IMAP Mail Expiration Time: " & _
        objItem.ImapMailExpirationTime
    Wscript.Echo "IMAP Routing Dll: " & objItem.ImapRoutingDll
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Server Information

Description
Returns information about all the IMAP servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsImapServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & _
        objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "IMAP Clear Text Provider: " & _
        objItem.ImapClearTextProvider
    Wscript.Echo "IMAP Default Domain: " & objItem.ImapDefaultDomain
    Wscript.Echo "IMAP Expire Delay: " & objItem.ImapExpireDelay
    Wscript.Echo "IMAP Expire Mail: " & objItem.ImapExpireMail
    Wscript.Echo "IMAP Expire Start: " & objItem.ImapExpireStart
    Wscript.Echo "IMAP Mail Expiration Time: " & _
        objItem.ImapMailExpirationTime
    Wscript.Echo "IMAP Routing Dll: " & objItem.ImapRoutingDll
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Server Information Using ADSI

Description
Enumerates the properties of an IMAP server named IMAP4SVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/IMAP4SVC/1")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & _
    objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & _
    objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & _
    objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
For Each strACL in objIIS.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Authentication Anonymous: " & _
    objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "Authentication Passport: " & _
    objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "Connection Timeout: " & _
    objIIS.ConnectionTimeout
Wscript.Echo "Default Logon Domain: " & _
    objIIS.DefaultLogonDomain
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "IMAP Clear Text Provider: " & _
    objIIS.ImapClearTextProvider
Wscript.Echo "IMAP Default Domain: " & objIIS.ImapDefaultDomain
Wscript.Echo "IMAP Expire Delay: " & objIIS.ImapExpireDelay
Wscript.Echo "IMAP Expire Mail: " & objIIS.ImapExpireMail
Wscript.Echo "IMAP Expire Start: " & objIIS.ImapExpireStart
Wscript.Echo "IMAP Mail Expiration Time: " & _
    objIIS.ImapMailExpirationTime
Wscript.Echo "IMAP Routing Dll: " & objIIS.ImapRoutingDll
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & _
    objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & _
    objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext File Win32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
For Each strBinding in objIIS.SecureBindings
    Wscript.Echo "Secure Bindings: " & strBinding
Next
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
For Each strBinding in objIIS.ServerBindings
    Wscript.Echo "Server Bindings: " & strBinding
Next
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & _
    objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & _
    objIIS.ServerListenTimeout
Wscript.Echo "Win32 Error: " & objIIS.Win32Error

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Server State

Description
Returns the state of the IMAP server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsImapServer")

For Each objItem in colItems
    Wscript.Echo "IMAP Service Version: " & objItem.ImapServiceVersion
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Server State: " & objItem.ServerState
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Service Configuration Information

Description
Returns information about the IMAP server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsImapService")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check Point: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    For Each strSource in objItem.ImapRoutingSources
        Wscript.Echo "IMAP Routing Sources: " & strSource
    Next
    Wscript.Echo "IMAP Service Version: " & objItem.ImapServiceVersion
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo "Process Id: " & objItem.ProcessId
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Service Information Using ADSI

Description
Returns information about the configuration of the IMAP service on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/IMAP4SVC")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & _
    objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & _
    objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
For Each strACL in objIIS.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Authentication Anonymous: " & objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "AuthenticationPassport: " & objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "IMAP Clear Text Provider: " & _
    objIIS.ImapClearTextProvider
Wscript.Echo "IMAP Default Domain: " & objIIS.ImapDefaultDomain
Wscript.Echo "IMAP Expire Delay: " & objIIS.ImapExpireDelay
Wscript.Echo "IMAP Expire Mail: " & objIIS.ImapExpireMail
Wscript.Echo "IMAP Expire Start: " & objIIS.ImapExpireStart
Wscript.Echo "IMAP Mail Expiration Time: " & _
    objIIS.ImapMailExpirationTime
Wscript.Echo "IMAP Routing Dll: " & objIIS.ImapRoutingDll
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & _
    objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & _
    objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext File Win32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Module List: " & objIIS.LogModuleList
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & objIIS.ServerListenTimeout

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Sessions

Description
Lists the names of all the IMAP sessions running on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsImapSessions")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IMAP Sessions Setting Instances

Description
Demonstration script that lists all the instances of the IIsImapSessionsSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsImapSessionsSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an IMAP Server Setting Metabase Property

Description
Demonstration script that changes the DefaultLogonDomain value for all the IMAP servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsIMAPServerSetting")

For Each objItem in colItems
    objItem.DefaultLogonDomain = "fabrikam"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an IMAP Service Setting Metabase Property

Description
Demonstration script that modifies the ServerAutoStart global IMAP metabase property on a computer IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery( _
    "Select * from IIsIMAPServiceSetting")

For Each objItem in colItems
    objItem.ServerAutoStart = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an IMAP Virtual Directory Metabase Property

Description
Demonstration script that changes the AccessSource global metabase property for IMAP virtual directories on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsIMAPVirtualDirSetting")

For Each objItem in colItems
    objItem.AccessSource = FALSE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All FTP Log Modules

Description
Returns the names of all the FTP log modules on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFtpInfoSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Custom Log Module Properties

Description
Returns information about all the custom log modules on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCustomLogModuleSetting")

For Each objItem in colItems
    Wscript.Echo "Log Custom Property Data Type: " & _
        objItem.LogCustomPropertyDataType
    Wscript.Echo "Log Custom Property Header: " & _
        objItem.LogCustomPropertyHeader
    Wscript.Echo "Log Custom Property ID: " & _
        objItem.LogCustomPropertyID
    Wscript.Echo "Log Custom Property Mask: " & _
        objItem.LogCustomPropertyMask
    Wscript.Echo "Log Custom Property Name: " & _
        objItem.LogCustomPropertyName
    Wscript.Echo "Log Custom Property Node ID: " & _
        objItem.LogCustomPropertyNodeID
    For Each strProperty in objItem.LogCustomPropertyServicesString
        Wscript.Echo "Log Custom Property Services String: " & _
            strproperty
    Next
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Custom Log Modules

Description
Lists the names of all the custom log modules in an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsCustomLogModule")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsLogModule Instances

Description
Demonstration script that lists all the instances of the IIsLogModule class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsLogModule")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsLogModulesSetting Instances

Description
Demonstration script that lists all the instances of the IIsLogModulesSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsLogModulesSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Log Module Settings

Description
Returns information about all the log module settings on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsLogModuleSetting")

For Each objItem in colItems
    Wscript.Echo "Log Module Id: " & objItem.LogModuleId
    Wscript.Echo "Log Module UI Id: " & objItem.LogModuleUiId
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Log Modules

Description
Lists the names of all the log modules found on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsLogModules")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Logging Options

Description
Returns information about Web service logging options on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")
For Each objItem in colItems
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Local Time Rollover: " & _
        objItem.LogFileLocaltimeRollover
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Web Service Logging Options

Description
Demonstration script that modifies Web service logging options on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.LogFileDirectory = "C:\Logs"
    objItem.LogFileLocaltimeRollover = True
    objItem.LogFilePeriod = 2
    objItem.LogFileTruncateSize = 1000000
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Filter Load Order

Description
Lists filter names and load orders for all the IIS filters on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsFiltersSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Filter Load Order: " & objItem.FilterLoadOrder
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPExpiration Instances

Description
Demonstration script that lists all the instances of the IIsNNTPExpiration class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpExpiration")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPExpirationSetting Instances

Description
Demonstration script that lists all the instances of the IIsNNTPExpirationSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpExpirationSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPExpire Instances

Description
Demonstration script that lists all the instances of the IIsNNTPExpire class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")
Set colItems = objWMIService.ExecQuery("Select * from IIsNntpExpire")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPFeeds Instances

Description
Demonstration script that lists all the instances of the IIsNNTPFeeds class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpFeeds")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPGroupsSetting Instances

Description
Demonstration script that lists all the instances of the IIsNNTPGroupSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpGroupsSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsNNTPRebuildSetting Instances

Description
Demonstration script that lists all the instances of the IIsNNTPRebuildSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpRebuildSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Instances of the IIsNNTPRebuild Class

Description
Demonstration script that lists all the instances of the IIsNNTPRebuild class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpRebuild")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Instances of the IIsNNTPSessionsSetting Class

Description
Demonstration script that lists all the instances of the IIsNNTPSessionsSetting class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpSessionsSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Authentication Properties

Description
Displays global NNTP service authentication properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certifcate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Expiration Information

Description
Displays NNTP expiration setting information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpExpireSetting")

For Each objItem in colItems
    For Each strGroup in objItem.ExpireNewsgroups
        Wscript.Echo "Expire Newsgroups: " & strGroup
    Next
    Wscript.Echo "Expire Policy Name: " & objItem.ExpirePolicyName
    Wscript.Echo "Expire Space: " & objItem.ExpireSpace
    Wscript.Echo "Expire Time: " & objItem.ExpireTime
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Feed Peer Temporary Directories

Description
Lists all the NNTP feed peer temporary directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpFeedsSetting")

For Each objItem in colItems
    Wscript.Echo "Feed Peer Temporary Directory: " & _
        objItem.FeedPeerTempDirectory
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Groups

Description
Lists all the NNTP groups on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpGroups")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Log Modules

Description
Lists all the NNTP log modules on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpInfoSetting")

For Each objItem in colItems
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Server Setting Information

Description
Returns information about all the NNTP servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Admin Email: " & objItem.AdminEmail
    Wscript.Echo "Admin Name: " & objItem.AdminName
    Wscript.Echo "Allow Clien tPosts: " & objItem.AllowClientPosts
    Wscript.Echo "Allow Control Msgs: " & objItem.AllowControlMsgs
    Wscript.Echo "Allow Feedback Posts: " & objItem.AllowFeedPosts
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
    Wscript.Echo "Article Table File: " & objItem.ArticleTableFile
    Wscript.Echo "Article Time Limit: " & objItem.ArticleTimeLimit
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Client Post Hard Limit: " & _
        objItem.ClientPostHardLimit
    Wscript.Echo "Client Post Soft Limit: " & _
        objItem.ClientPostSoftLimit
    Wscript.Echo "Cluster Enabled: " & objItem.ClusterEnabled
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Default Moderator Domain: " & _
        objItem.DefaultModeratorDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disable New News: " & objItem.DisableNewNews
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Feed Post Hard Limit: " & objItem.FeedPostHardLimit
    Wscript.Echo "Feed Post Soft Limit: " & objItem.FeedPostSoftLimit
    Wscript.Echo "Feed Report Period: " & objItem.FeedReportPeriod
    Wscript.Echo "Group Help File: " & objItem.GroupHelpFile
    Wscript.Echo "Group List File: " & objItem.GroupListFile
    Wscript.Echo "Group Var List File: " & objItem.GroupVarListFile
    Wscript.Echo "History Expiration: " & objItem.HistoryExpiration
    Wscript.Echo "History Table File: " & objItem.HistoryTableFile
    Wscript.Echo "Honor Client Msg Ids: " & objItem.HonorClientMsgIds
    Wscript.Echo "List File: " & objItem.ListFile
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext FileWin32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum Search Results: " & objItem.MaxSearchResults
    Wscript.Echo "Moderator File: " & objItem.ModeratorFile
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "News Crawler Time: " & objItem.NewsCrawlerTime
    Wscript.Echo "News Drop Directory: " & objItem.NewsDropDirectory
    Wscript.Echo "News Failed Pickup Directory: " & _
        objItem.NewsFailedPickupDirectory
    Wscript.Echo "News Pickup Directory: " & objItem.NewsPickupDirectory
    Wscript.Echo "NNTP Clear Text Provider: " & _
        objItem.NntpClearTextProvider
    Wscript.Echo "NNTP Command Log Mask: " & objItem.NntpCommandLogMask
    Wscript.Echo "NNTP Organization: " & objItem.NntpOrganization
    Wscript.Echo "NNTP UUCP Name: " & objItem.NntpUucpName
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Pretty Names File: " & objItem.PrettyNamesFile
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Latency: " & objItem.ShutdownLatency
    Wscript.Echo "SMTP Server: " & objItem.SmtpServer
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
    Wscript.Echo "Xover Table File: " & objItem.XoverTableFile
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Service Configuration Information

Description
Returns information about the configuration of the NNTP server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpService")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check Point: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NNTP Service Version: " & _
        objItem.NntpServiceVersion
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo "Process Id: " & objItem.ProcessId
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Service Information

Description
Returns information about the NNTP service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/NNTPSVC")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & _
    objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & _
    objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
For Each strACL in objIIS.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Admin Email: " & objIIS.AdminEmail
Wscript.Echo "Admin Name: " & objIIS.AdminName
Wscript.Echo "Allow Clien tPosts: " & objIIS.AllowClientPosts
Wscript.Echo "Allow Control Msgs: " & objIIS.AllowControlMsgs
Wscript.Echo "Allow Feedback Posts: " & objIIS.AllowFeedPosts
Wscript.Echo "Anonymous Password Sync: " & _
    objIIS.AnonymousPasswordSync
Wscript.Echo "Anonymous User Name: " & objIIS.AnonymousUserName
Wscript.Echo "Anonymous User Password: " & objIIS.AnonymousUserPass
Wscript.Echo "Article Time Limit: " & objIIS.ArticleTimeLimit
Wscript.Echo "Authentication Anonymous: " & objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "Authentication Passport: " & objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "Client Post Hard Limit: " & _
    objIIS.ClientPostHardLimit
Wscript.Echo "Client Post Soft Limit: " & _
    objIIS.ClientPostSoftLimit
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Content Indexed: " & objIIS.ContentIndexed
Wscript.Echo "Default Moderator Domain: " & _
    objIIS.DefaultModeratorDomain
Wscript.Echo "Disable New News: " & objIIS.DisableNewNews
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Feed Post Hard Limit: " & objIIS.FeedPostHardLimit
Wscript.Echo "Feed Post Soft Limit: " & objIIS.FeedPostSoftLimit
Wscript.Echo "Feed Report Period: " & objIIS.FeedReportPeriod
Wscript.Echo "Group Var List File: " & objIIS.GroupVarListFile
Wscript.Echo "History Expiration: " & objIIS.HistoryExpiration
Wscript.Echo "Honor Client Msg Ids: " & objIIS.HonorClientMsgIds
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & _
    objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & _
    objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext FileWin32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Maximum Search Results: " & objIIS.MaxSearchResults
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "News Crawler Time: " & objIIS.NewsCrawlerTime
Wscript.Echo "NNTP Command Log Mask: " & objIIS.NntpCommandLogMask
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & objIIS.ServerListenTimeout
Wscript.Echo "Shutdown Latency: " & objIIS.ShutdownLatency
Wscript.Echo "SMTP Server: " & objIIS.SmtpServer

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Service Setting Information

Description
Returns information about the global metabase NNTP server settings on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certifcate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Admin Email: " & objItem.AdminEmail
    Wscript.Echo "Admin Name: " & objItem.AdminName
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Allow Client Posts: " & objItem.AllowClientPosts
    Wscript.Echo "Allow Control Msgs: " & objItem.AllowControlMsgs
    Wscript.Echo "Allow Feed Posts: " & objItem.AllowFeedPosts
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & objItem.AnonymousUserPass
    Wscript.Echo "Article Time Limit: " & objItem.ArticleTimeLimit
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Client Post Hard Limit: " & _
        objItem.ClientPostHardLimit
    Wscript.Echo "Client Post Soft Limit: " & _
        objItem.ClientPostSoftLimit
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Default Moderator Domain: " & _
        objItem.DefaultModeratorDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Levels To Scan: " & _
        objItem.DirectoryLevelsToScan
    Wscript.Echo "Disable New News: " & objItem.DisableNewNews
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Feed Post Hard Limit: " & objItem.FeedPostHardLimit
    Wscript.Echo "Feed Post Soft Limit: " & objItem.FeedPostSoftLimit
    Wscript.Echo "Feed Report Period: " & objItem.FeedReportPeriod
    Wscript.Echo "Group Var List File: " & objItem.GroupVarListFile
    Wscript.Echo "History Expiration: " & objItem.HistoryExpiration
    Wscript.Echo "Honor Client Msg Ids: " & objItem.HonorClientMsgIds
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & objItem.LogFileTruncateSize
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum EndpointConnections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum SearchResults: " & objItem.MaxSearchResults
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "News Crawler Time: " & objItem.NewsCrawlerTime
    Wscript.Echo "NNTP Command Log Mask: " & objItem.NntpCommandLogMask
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Latency: " & objItem.ShutdownLatency
    Wscript.Echo "SMTP Server: " & objItem.SmtpServer
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Sessions

Description
Lists the names of all the NNTP sessions on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpSessions")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Virtual Directories

Description
Lists the names of all the NNTP virtual directories on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpVirtualDir")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Virtual Directory Information

Description
Returns information about all the NNTP virtual directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Ex Mdb Guid: " & objItem.ExMdbGuid
    Wscript.Echo "Fs Property Path: " & objItem.FsPropertyPath
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "UNC Password: " & objItem.UNCPassword
    Wscript.Echo "UNC User Name: " & objItem.UNCUserName
    Wscript.Echo "Vr Do Expire: " & objItem.VrDoExpire
    Wscript.Echo "Vr Driver Clsid: " & objItem.VrDriverClsid
    Wscript.Echo "Vr Driver Progid: " & objItem.VrDriverProgid
    Wscript.Echo "Vr Own Moderator: " & objItem.VrOwnModerator
    Wscript.Echo "Vr Use Account: " & objItem.VrUseAccount
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Virtual Directory Properties

Description
Returns basic configuration information for all the NNTP virtual directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Virtual Server Properties

Description
Returns global NNTP connection metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "NNTP UUCP Name: " & objItem.NntpUucpName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NNTP Virtual Server Setting Properties

Description
Returns global NNTP virtual server metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Admin Email: " & objItem.AdminEmail
    Wscript.Echo "Allow Client Posts: " & objItem.AllowClientPosts
    Wscript.Echo "Allow Control Msgs: " & objItem.AllowControlMsgs
    Wscript.Echo "Allow Feed Posts: " & objItem.AllowFeedPosts
    Wscript.Echo "Client Post Hard Limit: " & _
        objItem.ClientPostHardLimit
    Wscript.Echo "Client Post Soft Limit: " & _
        objItem.ClientPostSoftLimit
    Wscript.Echo "Default Moderator Domain: " & _
        objItem.DefaultModeratorDomain
    Wscript.Echo "Feed Post Hard Limit: " & objItem.FeedPostHardLimit
    Wscript.Echo "Feed Post Soft Limit: " & objItem.FeedPostSoftLimit
    Wscript.Echo "SMTP Server: " & objItem.SmtpServer
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the NNTP Server State

Description
Returns the state of the NNTP server service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServer")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NNTP Service Version: " &  _
        objItem.NntpServiceVersion
    Wscript.Echo "Server State: " & objItem.ServerState
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the NNTP Server Version

Description
Returns the version of the NNTP server service running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsNntpInfo")

For Each objItem in colItems
    Wscript.Echo "Major IIS Version Number: " & objItem.MajorIIsVersionNumber
    Wscript.Echo "Minor IIS Version Number: " & objItem.MinorIIsVersionNumber
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an NNTP Server Setting Metabase Property

Description
Demonstration script that modifies a metabase property (AllowClientPosts) for all NNTP server sites on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNNTPServerSetting")

For Each objItem in colItems
    objItem.AllowClientPosts = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an NNTP Service Metabase Property Using ADSI

Description
Demonstration script that modifies an NNTP service property (MaxConnections) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/NNTPSVC")
objIIS.MaxConnections = 5000
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an NNTP Service Setting Metabase Property

Description
Demonstration script that modifies a global metabase property (ContentIndexed) for the NNTP server service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNNTPServiceSetting")

For Each objItem in colItems
    objItem.ContentIndexed = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an NNTP Virtual Directory Metabase Property

Description
Demonstration script that modifies the VrDoExpire global NNTP metabase property on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNNTPVirtualDirSetting")

For Each objItem in colItems
    objItem.VrDoExpire = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NNTP Authentication Properties

Description
Demonstration script that modifies global NNTP authentication metabase property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    objItem.AccessSSLMapCert = False
    objItem.AccessSSLNegotiateCert = False
    objItem.AccessSSLRequireCert = False
    objItem.AuthAnonymous = True
    objItem.AuthBasic = True
    objItem.AuthNTLM = False
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NNTP Virtual Directory Properties

Description
Demonstration script that modifies global NNTP default property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpVirtualDirSetting")

For Each objItem in colItems
    objItem.ContentIndexed = True
    objItem.DontLog = False
    objItem.Path = "c:\inetpub\nntpfile\root\accounting"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NNTP Virtual Server Setting Properties

Description
Demonstration script that modifies global NNTP virtual server property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsNntpServiceSetting")

For Each objItem in colItems
    objItem.AdminEmail = "admin@fabrikam.com"
    objItem.AllowClientPosts = True
    objItem.AllowControlMsgs = True
    objItem.AllowFeedPosts = True
    objItem.ClientPostHardLimit = 1000000
    objItem.ClientPostSoftLimit = 250000
    objItem.DefaultModeratorDomain = "fabrikam.com"
    objItem.FeedPostHardLimit = 1000000
    objItem.FeedPostSoftLimit = 250000
    objItem.SmtpServer = "mail.fabrikam.com"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Server Information Using ADSI

Description
Returns information about a POP3 server named POP3SVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/POP3SVC/1")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certifcate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
For Each strACL in objIIS.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Authentication Anonymous: " & objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "Authentication Passport: " & objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "ConnectionT imeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext File Win32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & objIIS.LogFileTruncateSize
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Pop3 Clear Text Provider: " & _
    objIIS.Pop3ClearTextProvider
Wscript.Echo "Pop3 Default Domain: " & objIIS.Pop3DefaultDomain
Wscript.Echo "Pop3 Expire Delay: " & objIIS.Pop3ExpireDelay
Wscript.Echo "Pop3 Expire Mail: " & objIIS.Pop3ExpireMail
Wscript.Echo "Pop3 Expire Start: " & objIIS.Pop3ExpireStart
Wscript.Echo "Pop3 Mail Expiration Time: " & _
    objIIS.Pop3MailExpirationTime
Wscript.Echo "Pop3 Routing Dll: " & objIIS.Pop3RoutingDll
For Each strBinding in objIIS.SecureBindings
    Wscript.Echo "Secure Bindings: " & strBinding
Next
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
For Each strBinding in objIIS.ServerBindings
    Wscript.Echo "Server Bindings: " & strBinding
Next
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & _
    objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & _
    objIIS.ServerListenTimeout
Wscript.Echo "Win32 Error: " & objIIS.Win32Error

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Server Information Using WMI

Description
Returns information about all the POP3 servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3ServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & _
        objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certifcate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Authentication Anonymous: " & _
        objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & _
        objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "ConnectionT imeout: " & _
        objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & _
        objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & _
        objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & _
        objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & _
        objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & _
        objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Odbc Data Source: " & _
        objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Pop3 Clear Text Provider: " & o_
        bjItem.Pop3ClearTextProvider
    Wscript.Echo "Pop3 Default Domain: " & objItem.Pop3DefaultDomain
    Wscript.Echo "Pop3 Expire Delay: " & objItem.Pop3ExpireDelay
    Wscript.Echo "Pop3 Expire Mail: " & objItem.Pop3ExpireMail
    Wscript.Echo "Pop3 Expire Start: " & objItem.Pop3ExpireStart
    Wscript.Echo "Pop3 Mail Expiration Time: " & _
        objItem.Pop3MailExpirationTime
    Wscript.Echo "Pop3 Routing Dll: " & objItem.Pop3RoutingDll
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Server State

Description
Lists the state of the POP3 service on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3Server")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    For Each strSource in objItem.Pop3RoutingSources
        Wscript.Echo "Pop3 Routing Sources: " & strSource
    Next
    Wscript.Echo "Pop3 Service Version: " & _
        objItem.Pop3ServiceVersion
    Wscript.Echo "Server State: " & objItem.ServerState
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Service Configuration Information

Description
Returns information about the configuration of the POP3 server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3Service")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CheckPoint: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & _
        objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path Name: " & objItem.PathName
    For Each strSource in objItem.Pop3RoutingSources
        Wscript.Echo "Pop3 Routing Sources: " & strSource
    Next
    Wscript.Echo "Pop3 Service Version: " & _
        objItem.Pop3ServiceVersion
    Wscript.Echo "ProcessId: " & objItem.ProcessId
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Service Setting Information Using ADSI

Description
Returns information about the POP3 service settings configured on a POP3 server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/POP3SVC")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SS LMapCert: " & objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
Wscript.Echo "Admin ACL Bin: " & objIIS.AdminACLBin
Wscript.Echo "Authentication Anonymous: " & objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "Authentication Passport: " & objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "Caption: " & objIIS.Caption
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Default Logon Domain: " & objIIS.DefaultLogonDomain
Wscript.Echo "Description: " & objIIS.Description
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & _
    objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & _
    objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & _
    objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & _
    objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext File Win32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & _
    objIIS.LogFileTruncateSize
Wscript.Echo "Log Module List: " & objIIS.LogModuleList
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Pop3 Clear Text Provider: " & _
    objIIS.Pop3ClearTextProvider
Wscript.Echo "Pop3 Default Domain: " & objIIS.Pop3DefaultDomain
Wscript.Echo "Pop3 Expire Delay: " & objIIS.Pop3ExpireDelay
Wscript.Echo "Pop3 Expire Mail: " & objIIS.Pop3ExpireMail
Wscript.Echo "Pop3 Expire Start: " & objIIS.Pop3ExpireStart
Wscript.Echo "Pop3 Mail Expiration Time: " & _
    objIIS.Pop3MailExpirationTime
Wscript.Echo "Pop3 Routing Dll: " & objIIS.Pop3RoutingDll
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & _
    objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & _
    objIIS.ServerListenTimeout
Wscript.Echo "Setting ID: " & objIIS.SettingID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Service Setting Information Using WMI

Description
Returns global POP3 server metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3ServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SS LMapCert: " & objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & _
        objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & o_
        bjItem.NTAuthenticationProviders
    Wscript.Echo "Pop3 Clear Text Provider: " & _
        objItem.Pop3ClearTextProvider
    Wscript.Echo "Pop3 Default Domain: " & objItem.Pop3DefaultDomain
    Wscript.Echo "Pop3 Expire Delay: " & objItem.Pop3ExpireDelay
    Wscript.Echo "Pop3 Expire Mail: " & objItem.Pop3ExpireMail
    Wscript.Echo "Pop3 Expire Start: " & objItem.Pop3ExpireStart
    Wscript.Echo "Pop3 Mail Expiration Time: " & _
        objItem.Pop3MailExpirationTime
    Wscript.Echo "Pop3 Routing Dll: " & objItem.Pop3RoutingDll
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List POP3 Sesssions

Description
Lists the names of all the POP3 sessions on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3Sessions")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a POP3 Server Setting Metabase Property

Description
Demonstration script that modifies the AuthPassport property value for all the POIP3 servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3ServerSetting")

For Each objItem in colItems
    objItem.AuthPassport = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a POP3 Service Metabase Setting

Description
Demonstration script that modifies the global POP3 server AuthAnonymous property metabase value on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3ServiceSetting")

For Each objItem in colItems
    objItem.AuthAnonymous = FALSE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a POP3 Virtual Directory Metabase Property

Description
Demonstration script that modifies a global POP3 virtual directory metabase property value (AccessSSLRequireCert) on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsPop3VirtualDirSetting")

For Each objItem in colItems
    objItem.AccessSSLRequireCert = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IIsSMTPSessionsSetting Instances

Description
Demonstration scripts that lists all instances of the IIsSMTPSessionsSettings class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpSessionsSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Advanced Delivery Options

Description
Displays the global SMTP advanced delivery metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Enable Reverse DNS Lookup: " & _
        objItem.EnableReverseDnsLookup
    Wscript.Echo "Fully Qualified Domain Name: " & _
        objItem.FullyQualifiedDomainName
    Wscript.Echo "Hop Count: " & objItem.HopCount
    Wscript.Echo "Masquerade Domain: " & objItem.MasqueradeDomain
    Wscript.Echo "Smart Host: " & objItem.SmartHost
    Wscript.Echo "Smart Host Type: " & objItem.SmartHostType
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Authentication Properties

Description
Displays the global SMTP authentication metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Sasl Logon Domain: " & objItem.SaslLogonDomain
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Domain Setting Information

Description
Displays SMTP domain setting information on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpDomainSetting")

For Each objItem in colItems
    For Each strTurn in objItem.AuthTurnList
        Wscript.Echo "Authentication Turn List: " & strTurn
    Next
    Wscript.Echo "CSide Etrn Domains: " & objItem.CSideEtrnDomains
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Relay For Authentication: " & objItem.RelayForAuth
    Wscript.Echo "Relay IP List: " & objItem.RelayIpList
    Wscript.Echo "Route Action: " & objItem.RouteAction
    Wscript.Echo "Route Action String: " & objItem.RouteActionString
    Wscript.Echo "Route Password: " & objItem.RoutePassword
    Wscript.Echo "Route User Name: " & objItem.RouteUserName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Domains

Description
Lists the names of all the SMTP domains on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsSmtpDomain")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP LDAP Routing Properties

Description
Lists the SMTP LDAP routing properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpRoutingSourceSetting")

For Each objItem in colItems
    Wscript.Echo "SMTP DS Account: " & objItem.SmtpDsAccount
    Wscript.Echo "SMTP DS Bind Type: " & objItem.SmtpDsBindType
    Wscript.Echo "SMTP DS Domain: " & objItem.SmtpDsDomain
    Wscript.Echo "SMTP DS Host: " & objItem.SmtpDsHost
    Wscript.Echo "SMTP DS Naming Context: " & _
        objItem.SmtpDsNamingContext
    Wscript.Echo "SMTP DS Password: " & objItem.SmtpDsPassword
    Wscript.Echo "SMTP DS Schema Type: " & objItem.SmtpDsSchemaType
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Log Modules

Description
Lists all the SMTP log modules on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpInfoSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Outbound Connection Properties

Description
Lists the default SMTP outbound connection metabase properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Maximum Out Connections: " & _
        objItem.MaxOutConnections
    Wscript.Echo "Maximum Out Connections Per Domain: " & _
        objItem.MaxOutConnectionsPerDomain
    Wscript.Echo "Remote SMTP Port: " & objItem.RemoteSmtpPort
    Wscript.Echo "Remote Timeout: " & objItem.RemoteTimeout
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Routing Source Settings

Description
Lists all the SMTP routing source setting properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpRoutingSourceSetting")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "SMTP DS Account: " & objItem.SmtpDsAccount
    Wscript.Echo "SMTP DS Bind Type: " & objItem.SmtpDsBindType
    Wscript.Echo "SMTP DS Data Directory: " & _
        objItem.SmtpDsDataDirectory
    Wscript.Echo "SMTP DS Default Mail Root: " & _
        objItem.SmtpDsDefaultMailRoot
    Wscript.Echo "SMTP DS Domain: " & objItem.SmtpDsDomain
    Wscript.Echo "SMTP DS Flags: " & objItem.SmtpDsFlags
    Wscript.Echo "SMTP DS Host: " & objItem.SmtpDsHost
    Wscript.Echo "SMTP DS Naming Context: " & _
        objItem.SmtpDsNamingContext
    Wscript.Echo "SMTP DS Password: " & objItem.SmtpDsPassword
    Wscript.Echo "SMTP DS Port: " & objItem.SmtpDsPort
    Wscript.Echo "SMTP DS Schema Type: " & objItem.SmtpDsSchemaType
    Wscript.Echo "SMTP DS Use Catalog: " & objItem.SmtpDsUseCat
    Wscript.Echo "SMTP Routing Table Type: " & _
        objItem.SmtpRoutingTableType
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Routing Sources

Description
Lists the names of all the SMTP routing sources on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpRoutingSource")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Server Information

Description
Displays basic SMTP server configuration information for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsSmtpServer")

For Each objItem in colItems
    For Each strRoute in objItem.DomainRouting
        Wscript.Echo "Domain Routing: " & strRoute
    Next
    Wscript.Echo "Local Domains:" & objItem.LocalDomains
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Postmaster Email: " & objItem.PostmasterEmail
    Wscript.Echo "Postmaster Name: " & objItem.PostmasterName
    For Each strSource in objItem.RoutingSources
        Wscript.Echo "Routing Sources: " & strSource
    Next
    Wscript.Echo "Server State: " & objItem.ServerState
    Wscript.Echo "SMTP Service Version: " & objItem.SmtpServiceVersion
    Wscript.Echo "Status: " & objItem.Status
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Server Information Using ADSI

Description
Returns information about an SMTP server named SMTPSVC/1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"
Set objIIS = GetObject("IIS://" & strComputer & "/SMTPSVC/1")

Wscript.Echo "Access Execute: " & objIIS.AccessExecute
Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Access No Physical Directory: " & _
    objIIS.AccessNoPhysicalDir
Wscript.Echo "Access No Remote Execute: " & _
    objIIS.AccessNoRemoteExecute
Wscript.Echo "Access No Remote Read: " & objIIS.AccessNoRemoteRead
Wscript.Echo "Access No Remote Script: " & _
    objIIS.AccessNoRemoteScript
Wscript.Echo "Access No Remote Write: " & _
    objIIS.AccessNoRemoteWrite
Wscript.Echo "Access Read: " & objIIS.AccessRead
Wscript.Echo "Access Script: " & objIIS.AccessScript
Wscript.Echo "Access Source: " & objIIS.AccessSource
Wscript.Echo "Access SSL: " & objIIS.AccessSSL
Wscript.Echo "Access SSL 128: " & objIIS.AccessSSL128
Wscript.Echo "Access SSL Flags: " & objIIS.AccessSSLFlags
Wscript.Echo "Access SSL Map Certificate: " & _
    objIIS.AccessSSLMapCert
Wscript.Echo "Access SSL Negotiate Certificate: " & _
    objIIS.AccessSSLNegotiateCert
Wscript.Echo "Access SSL Require Certificate: " & _
    objIIS.AccessSSLRequireCert
Wscript.Echo "Access Write: " & objIIS.AccessWrite
Wscript.Echo "Add No Headers: " & objIIS.AddNoHeaders
For Each strACL in objIIS.AdminACLBin
    Wscript.Echo "Admin ACL Bin: " & strACL
Next
Wscript.Echo "Allow Anonymous: " & objIIS.AllowAnonymous
Wscript.Echo "Always Use SSl: " & objIIS.AlwaysUseSsl
Wscript.Echo "Anonymous Only: " & objIIS.AnonymousOnly
Wscript.Echo "Anonymous Password Sync: " & _
    objIIS.AnonymousPasswordSync
Wscript.Echo "Anonymous User Name: " & objIIS.AnonymousUserName
Wscript.Echo "Authentication Anonymous: " & objIIS.AuthAnonymous
Wscript.Echo "Authentication Basic: " & objIIS.AuthBasic
Wscript.Echo "Authentication Flags: " & objIIS.AuthFlags
Wscript.Echo "Authentication MD5: " & objIIS.AuthMD5
Wscript.Echo "Authentication NTLM: " & objIIS.AuthNTLM
Wscript.Echo "Authentication Passport: " & objIIS.AuthPassport
Wscript.Echo "Az Enable: " & objIIS.AzEnable
Wscript.Echo "Az Scope Name: " & objIIS.AzScopeName
Wscript.Echo "Az Store Name: " & objIIS.AzStoreName
Wscript.Echo "Bad Mail Directory: " & objIIS.BadMailDirectory
Wscript.Echo "Cluster Enabled: " & objIIS.ClusterEnabled
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Connect Response: " & objIIS.ConnectResponse
Wscript.Echo "Default Domain: " & objIIS.DefaultDomain
Wscript.Echo "Default Logon Domain: " & _
    objIIS.DefaultLogonDomain
Wscript.Echo "Disable Socket Pooling: " & _
    objIIS.DisableSocketPooling
Wscript.Echo "Do Masquerade: " & objIIS.DoMasquerade
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Drop Directory: " & objIIS.DropDirectory
Wscript.Echo "Enable Reverse DNS Lookup: " & _
    objIIS.EnableReverseDnsLookup
Wscript.Echo "Etrn Days: " & objIIS.EtrnDays
Wscript.Echo "Etrn Subdomains: " & objIIS.EtrnSubdomains
Wscript.Echo "Fully Qualified Domain Name: " & _
    objIIS.FullyQualifiedDomainName
Wscript.Echo "Hop Count: " & objIIS.HopCount
Wscript.Echo "Limit Remote Connections: " & _
    objIIS.LimitRemoteConnections
Wscript.Echo "Local Retry Attempts: " & _
    objIIS.LocalRetryAttempts
Wscript.Echo "Local Retry Interval: " & _
    objIIS.LocalRetryInterval
Wscript.Echo "Log Ext File Bytes Received: " & _
    objIIS.LogExtFileBytesRecv
Wscript.Echo "Log Ext File Bytes Sent: " & _
    objIIS.LogExtFileBytesSent
Wscript.Echo "Log Ext File Client IP: " & _
    objIIS.LogExtFileClientIp
Wscript.Echo "Log Ext File Computer Name: " & _
    objIIS.LogExtFileComputerName
Wscript.Echo "Log Ext File Cookie: " & objIIS.LogExtFileCookie
Wscript.Echo "Log Ext File Date: " & objIIS.LogExtFileDate
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log Ext File Host: " & objIIS.LogExtFileHost
Wscript.Echo "Log Ext File Http Status: " & _
    objIIS.LogExtFileHttpStatus
Wscript.Echo "Log Ext File Http SubStatus: " & _
    objIIS.LogExtFileHttpSubStatus
Wscript.Echo "Log Ext File Method: " & objIIS.LogExtFileMethod
Wscript.Echo "Log Ext File Protocol Version: " & _
    objIIS.LogExtFileProtocolVersion
Wscript.Echo "Log Ext File Referer: " & objIIS.LogExtFileReferer
Wscript.Echo "Log Ext File Server IP: " & objIIS.LogExtFileServerIp
Wscript.Echo "Log Ext File Server Port: " & _
    objIIS.LogExtFileServerPort
Wscript.Echo "Log Ext File Site Name: " & objIIS.LogExtFileSiteName
Wscript.Echo "Log Ext File Time: " & objIIS.LogExtFileTime
Wscript.Echo "Log Ext File Time Taken: " & _
    objIIS.LogExtFileTimeTaken
Wscript.Echo "Log Ext File URI Query: " & objIIS.LogExtFileUriQuery
Wscript.Echo "Log Ext File URI Stem: " & objIIS.LogExtFileUriStem
Wscript.Echo "Log Ext File User Agent: " & _
    objIIS.LogExtFileUserAgent
Wscript.Echo "Log Ext File User Name: " & objIIS.LogExtFileUserName
Wscript.Echo "Log Ext File Win32 Status: " & _
    objIIS.LogExtFileWin32Status
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log File Truncate Size: " & _
    objIIS.LogFileTruncateSize
Wscript.Echo "Log Odbc Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log Odbc Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log Odbc Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log Odbc User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "LogT ype: " & objIIS.LogType
Wscript.Echo "Masquerade Domain: " & objIIS.MasqueradeDomain
Wscript.Echo "Maximum Bandwidth: " & objIIS.MaxBandwidth
Wscript.Echo "Maximum Batched Messages: " & _
    objIIS.MaxBatchedMessages
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Maximum Directory Change IO Size: " & _
    objIIS.MaxDirChangeIOSize
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Maximum Mail Objects: " & objIIS.MaxMailObjects
Wscript.Echo "Maximum Message Size: " & objIIS.MaxMessageSize
Wscript.Echo "Maximum Out Connections: " & _
    objIIS.MaxOutConnections
Wscript.Echo "Maximum Out Connections Per Domain: " & _
    objIIS.MaxOutConnectionsPerDomain
Wscript.Echo "Maximum Recipients: " & objIIS.MaxRecipients
Wscript.Echo "Maximum Session Size: " & objIIS.MaxSessionSize
Wscript.Echo "Maximum SMTP Errors: " & objIIS.MaxSmtpErrors
Wscript.Echo "Name: " & objIIS.Name
Wscript.Echo "Name Resolution Type: " & _
    objIIS.NameResolutionType
Wscript.Echo "NT Authentication Providers: " & _
    objIIS.NTAuthenticationProviders
Wscript.Echo "Pickup Directory: " & objIIS.PickupDirectory
Wscript.Echo "Queue Directory: " & objIIS.QueueDirectory
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "Relay For Authentication: " & objIIS.RelayForAuth
Wscript.Echo "Remote Retry Attempts: " & _
    objIIS.RemoteRetryAttempts
Wscript.Echo "Remote Retry Interval: " & _
    objIIS.RemoteRetryInterval
Wscript.Echo "Remote SMTP Port: " & objIIS.RemoteSmtpPort
Wscript.Echo "Remote SMTP Secure Port: " & _
    objIIS.RemoteSmtpSecurePort
Wscript.Echo "Remote Timeout: " & objIIS.RemoteTimeout
Wscript.Echo "Route Action: " & objIIS.RouteAction
Wscript.Echo "Route Password: " & objIIS.RoutePassword
Wscript.Echo "Route User Name: " & objIIS.RouteUserName
Wscript.Echo "Routing Dll: " & objIIS.RoutingDll
Wscript.Echo "Sasl Logon Domain: " & objIIS.SaslLogonDomain
Wscript.Echo "Send Bad To: " & objIIS.SendBadTo
Wscript.Echo "Send Ndr To: " & objIIS.SendNdrTo
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Server Listen Backlog: " & _
    objIIS.ServerListenBacklog
Wscript.Echo "Server Listen Timeout: " & _
    objIIS.ServerListenTimeout
'Wscript.Echo "Setting ID: " & objIIS.SettingID
Wscript.Echo "Should Deliver: " & objIIS.ShouldDeliver
Wscript.Echo "Should Pickup Mail: " & objIIS.ShouldPickupMail
Wscript.Echo "Should Pipeline In: " & objIIS.ShouldPipelineIn
Wscript.Echo "Should Pipeline Out: " & _
    objIIS.ShouldPipelineOut
Wscript.Echo "Smart Host: " & objIIS.SmartHost
Wscript.Echo "Smart Host Type: " & objIIS.SmartHostType
Wscript.Echo "SMTP Aqueue Wait: " & objIIS.SmtpAqueueWait
Wscript.Echo "SMTP Authentication Timeout: " & _
    objIIS.SmtpAuthTimeout
Wscript.Echo "SMTP Bdat Timeout: " & objIIS.SmtpBdatTimeout
Wscript.Echo "SMTP Clear Text Provider: " & _
    objIIS.SmtpClearTextProvider
Wscript.Echo "SMTP Connect Timeout: " & objIIS.SmtpConnectTimeout
Wscript.Echo "SMTP Data Timeout: " & objIIS.SmtpDataTimeout
Wscript.Echo "SMTP Disable Relay: " & objIIS.SmtpDisableRelay
Wscript.Echo "SMTP Domain Validation Flags: " & _
    objIIS.SmtpDomainValidationFlags
Wscript.Echo "SMTP Dot Stuff Pickup Directory Files: " & _
    objIIS.SmtpDotStuffPickupDirFiles
Wscript.Echo "SMTP DSN Language ID: " & objIIS.SmtpDSNLanguageID
Wscript.Echo "SMTP DSN Options: " & objIIS.SmtpDSNOptions
Wscript.Echo "SMTP Eventlog Level: " & objIIS.SmtpEventlogLevel
Wscript.Echo "SMTP Helo No Domain: " & objIIS.SmtpHeloNoDomain
Wscript.Echo "SMTP Helo Timeout: " & objIIS.SmtpHeloTimeout
Wscript.Echo "SMTP Inbound Command Support Options: " & o_
    bjIIS.SmtpInboundCommandSupportOptions
Wscript.Echo "SMTP IP Restriction Flag: " & _
    objIIS.SmtpIpRestrictionFlag
Wscript.Echo "SMTP Local Delay Expire Minutes: " & _
    objIIS.SmtpLocalDelayExpireMinutes
Wscript.Echo "SMTP Local NDR Expire Minutes: " & _
    objIIS.SmtpLocalNDRExpireMinutes
Wscript.Echo "SMTP Mail From Timeout: " & _
    objIIS.SmtpMailFromTimeout
Wscript.Echo "SMTP Mail No Helo: " & objIIS.SmtpMailNoHelo
Wscript.Echo "SMTP Maximum Remote Q Threads: " & _
    objIIS.SmtpMaxRemoteQThreads
Wscript.Echo "SMTP Outbound Command Support Options: " & _
    objIIS.SmtpOutboundCommandSupportOptions
Wscript.Echo "SMTP Rcpt To Timeout: " & objIIS.SmtpRcptToTimeout
Wscript.Echo "SMTP Remote Delay Expire Minutes: " & _
    objIIS.SmtpRemoteDelayExpireMinutes
Wscript.Echo "SMTP Remote NDR Expire Minutes: " & _
    objIIS.SmtpRemoteNDRExpireMinutes
Wscript.Echo "SMTP Remote Progressive Retry: " & _
    objIIS.SmtpRemoteProgressiveRetry
Wscript.Echo "SMTP Remote Retry Threshold: " & _
    objIIS.SmtpRemoteRetryThreshold
Wscript.Echo "SMTP Rset Timeout: " & objIIS.SmtpRsetTimeout
Wscript.Echo "SMTP Sasl Timeout: " & objIIS.SmtpSaslTimeout
Wscript.Echo "SMTP SSL Certifcate Hostname Validation: " & _
    objIIS.SmtpSSLCertHostnameValidation
Wscript.Echo "SMTP SSL Require Trusted CA: " & _
    objIIS.SmtpSSLRequireTrustedCA
Wscript.Echo "SMTP Turn Timeout: " & objIIS.SmtpTurnTimeout
Wscript.Echo "SMTP Use Tcp Dns: " & objIIS.SmtpUseTcpDns
Wscript.Echo "Updated Default Domain: " & _
    objIIS.UpdatedDefaultDomain
Wscript.Echo "Updated FQDN: " & objIIS.UpdatedFQDN
Wscript.Echo "Win32 Error: " & objIIS.Win32Error

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Server Setting Information

Description
Returns information about all the individual SMTP servers on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " &  _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " &  _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " &  _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " &  _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " &  _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " &  _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Add No Headers: " & objItem.AddNoHeaders
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Always Use SSl: " & objItem.AlwaysUseSsl
    Wscript.Echo "Anonymous Only: " & objItem.AnonymousOnly
    Wscript.Echo "Anonymous Password Sync: " &  _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Bad Mail Directory: " & objItem.BadMailDirectory
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Cluster Enabled: " & objItem.ClusterEnabled
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Connect Response: " & objItem.ConnectResponse
    Wscript.Echo "Default Domain: " & objItem.DefaultDomain
    Wscript.Echo "Default Logon Domain: " &  _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disable Socket Pooling: " &  _
        objItem.DisableSocketPooling
    Wscript.Echo "Do Masquerade: " & objItem.DoMasquerade
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Drop Directory: " & objItem.DropDirectory
    Wscript.Echo "Enable Reverse DNS Lookup: " &  _
        objItem.EnableReverseDnsLookup
    Wscript.Echo "Etrn Days: " & objItem.EtrnDays
    Wscript.Echo "Etrn Subdomains: " & objItem.EtrnSubdomains
    Wscript.Echo "Fully Qualified Domain Name: " &  _
        objItem.FullyQualifiedDomainName
    Wscript.Echo "Hop Count: " & objItem.HopCount
    Wscript.Echo "Limit Remote Connections: " &  _
        objItem.LimitRemoteConnections
    Wscript.Echo "Local Retry Attempts: " &  _
        objItem.LocalRetryAttempts
    Wscript.Echo "Local Retry Interval: " &  _
        objItem.LocalRetryInterval
    Wscript.Echo "Log Ext File Bytes Received: " &  _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " &  _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " &  _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " &  _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " &  _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " &  _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " &  _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " &  _
        objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " &  _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " &  _
        objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " &  _
        objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " &  _
        objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " &  _
        objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " &  _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " &  _
        objItem.LogFileTruncateSize
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "LogT ype: " & objItem.LogType
    Wscript.Echo "Masquerade Domain: " & objItem.MasqueradeDomain
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Batched Messages: " &  _
        objItem.MaxBatchedMessages
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Directory Change IO Size: " &  _
        objItem.MaxDirChangeIOSize
    Wscript.Echo "Maximum Endpoint Connections: " &  _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum Mail Objects: " & objItem.MaxMailObjects
    Wscript.Echo "Maximum Message Size: " & objItem.MaxMessageSize
    Wscript.Echo "Maximum Out Connections: " & objItem.MaxOutConnections
    Wscript.Echo "Maximum Out Connections Per Domain: " &  _
        objItem.MaxOutConnectionsPerDomain
    Wscript.Echo "Maximum Recipients: " & objItem.MaxRecipients
    Wscript.Echo "Maximum Session Size: " & objItem.MaxSessionSize
    Wscript.Echo "Maximum SMTP Errors: " & objItem.MaxSmtpErrors
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Name Resolution Type: " & objItem.NameResolutionType
    Wscript.Echo "NT Authentication Providers: " &  _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Pickup Directory: " & objItem.PickupDirectory
    Wscript.Echo "Queue Directory: " & objItem.QueueDirectory
    Wscript.Echo "Realm: " & objItem.Realm
    Wscript.Echo "Relay For Authentication: " & objItem.RelayForAuth
    Wscript.Echo "Relay IP List: " & objItem.RelayIpList
    Wscript.Echo "Remote Retry Attempts: " & objItem.RemoteRetryAttempts
    Wscript.Echo "Remote Retry Interval: " & objItem.RemoteRetryInterval
    Wscript.Echo "Remote SMTP Port: " & objItem.RemoteSmtpPort
    Wscript.Echo "Remote SMTP Secure Port: " &  _
        objItem.RemoteSmtpSecurePort
    Wscript.Echo "Remote Timeout: " & objItem.RemoteTimeout
    Wscript.Echo "Route Action: " & objItem.RouteAction
    Wscript.Echo "Route Password: " & objItem.RoutePassword
    Wscript.Echo "Route User Name: " & objItem.RouteUserName
    Wscript.Echo "Routing Dll: " & objItem.RoutingDll
    Wscript.Echo "Sasl Logon Domain: " & objItem.SaslLogonDomain
    Wscript.Echo "Send Bad To: " & objItem.SendBadTo
    Wscript.Echo "Send Ndr To: " & objItem.SendNdrTo
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " &  _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " &  _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Should Deliver: " & objItem.ShouldDeliver
    Wscript.Echo "Should Pickup Mail: " & objItem.ShouldPickupMail
    Wscript.Echo "Should Pipeline In: " & objItem.ShouldPipelineIn
    Wscript.Echo "Should Pipeline Out: " & objItem.ShouldPipelineOut
    Wscript.Echo "Smart Host: " & objItem.SmartHost
    Wscript.Echo "Smart Host Type: " & objItem.SmartHostType
    Wscript.Echo "SMTP Aqueue Wait: " & objItem.SmtpAqueueWait
    Wscript.Echo "SMTP Authentication Timeout: " &  _
        objItem.SmtpAuthTimeout
    Wscript.Echo "SMTP Bdat Timeout: " & objItem.SmtpBdatTimeout
    Wscript.Echo "SMTP Clear Text Provider: " &  _
        objItem.SmtpClearTextProvider
    Wscript.Echo "SMTP Connect Timeout: " &  _
        objItem.SmtpConnectTimeout
    Wscript.Echo "SMTP Data Timeout: " & objItem.SmtpDataTimeout
    Wscript.Echo "SMTP Disable Relay: " & objItem.SmtpDisableRelay
    Wscript.Echo "SMTP Domain Validation Flags: " &  _
        objItem.SmtpDomainValidationFlags
    Wscript.Echo "SMTP Dot Stuff Pickup Directory Files: " &  _
        objItem.SmtpDotStuffPickupDirFiles
    Wscript.Echo "SMTP DSN Language ID: " & objItem.SmtpDSNLanguageID
    Wscript.Echo "SMTP DSN Options: " & objItem.SmtpDSNOptions
    Wscript.Echo "SMTP Eventlog Level: " & objItem.SmtpEventlogLevel
    Wscript.Echo "SMTP Helo No Domain: " & objItem.SmtpHeloNoDomain
    Wscript.Echo "SMTP Helo Timeout: " & objItem.SmtpHeloTimeout
    Wscript.Echo "SMTP Inbound Command Support Options: " &  _
        objItem.SmtpInboundCommandSupportOptions
    Wscript.Echo "SMTP IP Restriction Flag: " &  _
        objItem.SmtpIpRestrictionFlag
    Wscript.Echo "SMTP Local Delay Expire Minutes: " &  _
        objItem.SmtpLocalDelayExpireMinutes
    Wscript.Echo "SMTP Local NDR Expire Minutes: " &  _
        objItem.SmtpLocalNDRExpireMinutes
    Wscript.Echo "SMTP Mail From Timeout: " &  _
        objItem.SmtpMailFromTimeout
    Wscript.Echo "SMTP Mail No Helo: " & objItem.SmtpMailNoHelo
    Wscript.Echo "SMTP Maximum Remote Q Threads: " &  _
        objItem.SmtpMaxRemoteQThreads
    Wscript.Echo "SMTP Outbound Command Support Options: " &  _
        objItem.SmtpOutboundCommandSupportOptions
    Wscript.Echo "SMTP Rcpt To Timeout: " & objItem.SmtpRcptToTimeout
    Wscript.Echo "SMTP Remote Delay Expire Minutes: " &  _
        objItem.SmtpRemoteDelayExpireMinutes
    Wscript.Echo "SMTP Remote NDR Expire Minutes: " &  _
        objItem.SmtpRemoteNDRExpireMinutes
    Wscript.Echo "SMTP Remote Progressive Retry: " &  _
        objItem.SmtpRemoteProgressiveRetry
    Wscript.Echo "SMTP Remote Retry Threshold: " &  _
        objItem.SmtpRemoteRetryThreshold
    Wscript.Echo "SMTP Rset Timeout: " & objItem.SmtpRsetTimeout
    Wscript.Echo "SMTP Sasl Timeout: " & objItem.SmtpSaslTimeout
    Wscript.Echo "SMTP SSL Certifcate Hostname Validation: " &  _
        objItem.SmtpSSLCertHostnameValidation
    Wscript.Echo "SMTP SSL Require Trusted CA: " & _
        objItem.SmtpSSLRequireTrustedCA
    Wscript.Echo "SMTP Turn Timeout: " & objItem.SmtpTurnTimeout
    Wscript.Echo "SMTP Use Tcp Dns: " & objItem.SmtpUseTcpDns
    Wscript.Echo "Updated Default Domain: " &  _
        objItem.UpdatedDefaultDomain
    Wscript.Echo "Updated FQDN: " & objItem.UpdatedFQDN
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Service Configuration Information

Description
Returns information about the configuration of the SMTP server service on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpService")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check Point: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    For Each strRoute in objItem.DomainRouting
        Wscript.Echo "Domain Routing: " & strRoute
    Next
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Local Domains: " & objItem.LocalDomains
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo "Process Id: " & objItem.ProcessId
    For Each strRoute in objItem.RoutingSources
        Wscript.Echo "Routing Sources: " & strRoute
    Next
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "SMTP Service Version: " & _
        objItem.SmtpServiceVersion
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Service Properties Using ADSI

Description
Returns information about the SMTP service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/SMTPSVC")

Wscript.Echo "Access Flags: " & objIIS.AccessFlags
Wscript.Echo "Disable Socket Pooling: " & _
    objIIS.DisableSocketPooling
Wscript.Echo "Allow Anonymous: " & objIIS.AllowAnonymous
Wscript.Echo "Don't Log: " & objIIS.DontLog
Wscript.Echo "Anonymous Only: " & objIIS.AnonymousOnly
Wscript.Echo "Anonymous Password Sync: " & _
    objIIS.AnonymousPasswordSync
Wscript.Echo "Anonymous User Name: " & objIIS.AnonymousUserName
Wscript.Echo "Anonymous User Password: " & _
    objIIS.AnonymousUserPass
Wscript.Echo "Connection Timeout: " & objIIS.ConnectionTimeout
Wscript.Echo "Log Ext File Flags: " & objIIS.LogExtFileFlags
Wscript.Echo "Log ODBC Data Source: " & objIIS.LogOdbcDataSource
Wscript.Echo "Log ODBC Password: " & objIIS.LogOdbcPassword
Wscript.Echo "Log File Directory: " & objIIS.LogFileDirectory
Wscript.Echo "Log ODBC Table Name: " & objIIS.LogOdbcTableName
Wscript.Echo "Log ODBC User Name: " & objIIS.LogOdbcUserName
Wscript.Echo "Log File Period: " & objIIS.LogFilePeriod
Wscript.Echo "Log Plugin Clsid: " & objIIS.LogPluginClsid
Wscript.Echo "Log File Truncate Size: " & _
    objIIS.LogFileTruncateSize
Wscript.Echo "Log Type: " & objIIS.LogType
Wscript.Echo "Maximum Connections: " & objIIS.MaxConnections
Wscript.Echo "Server Comment: " & objIIS.ServerComment
Wscript.Echo "Maximum Endpoint Connections: " & _
    objIIS.MaxEndpointConnections
Wscript.Echo "Server Listen Timeout: " & _
    objIIS.ServerListenTimeout
Wscript.Echo "Realm: " & objIIS.Realm
Wscript.Echo "Server AutoStart: " & objIIS.ServerAutoStart

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Service Setting Information

Description
Returns global SMTP server metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Add No Headers: " & objItem.AddNoHeaders
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Allow Anonymous: " & objItem.AllowAnonymous
    Wscript.Echo "Always Use Ssl: " & objItem.AlwaysUseSsl
    Wscript.Echo "Anonymous Only: " & objItem.AnonymousOnly
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & _
        objItem.AnonymousUserPass
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Bad Mail Directory: " & objItem.BadMailDirectory
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Connect Response: " & objItem.ConnectResponse
    Wscript.Echo "Default Domain: " & objItem.DefaultDomain
    Wscript.Echo "Default Logon Domain: " & _
        objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disable Socket Pooling: " & _
        objItem.DisableSocketPooling
    Wscript.Echo "Do Masquerade: " & objItem.DoMasquerade
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Drop Directory: " & objItem.DropDirectory
    Wscript.Echo "Enable Reverse DNS Lookup: " & _
        objItem.EnableReverseDnsLookup
    Wscript.Echo "Etrn Days: " & objItem.EtrnDays
    Wscript.Echo "Etrn Subdomains: " & objItem.EtrnSubdomains
    Wscript.Echo "Fully Qualified Domain Name: " & _
        objItem.FullyQualifiedDomainName
    Wscript.Echo "Hop Count: " & objItem.HopCount
    Wscript.Echo "Limit Remote Connections: " & _
        objItem.LimitRemoteConnections
    Wscript.Echo "Local Retry Attempts: " & objItem.LocalRetryAttempts
    Wscript.Echo "Local Retry Interval: " & objItem.LocalRetryInterval
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & _
        objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & _
        objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & objItem.LogFileTruncateSize
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Masquerade Domain: " & objItem.MasqueradeDomain
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Batched Messages: " & objItem.MaxBatchedMessages
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Diectory rChange IO Size: " & _
        objItem.MaxDirChangeIOSize
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum Mail Objects: " & objItem.MaxMailObjects
    Wscript.Echo "Maximum Message Size: " & objItem.MaxMessageSize
    Wscript.Echo "Maximum Out Connections: " & objItem.MaxOutConnections
    Wscript.Echo "Maximum Out Connections Per Domain: " & _
        objItem.MaxOutConnectionsPerDomain
    Wscript.Echo "Maximum Recipients: " & objItem.MaxRecipients
    Wscript.Echo "Maximum Session Size: " & objItem.MaxSessionSize
    Wscript.Echo "Maximum SMTP Errors: " & objItem.MaxSmtpErrors
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Name Resolution Type: " & objItem.NameResolutionType
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Pickup Directory: " & objItem.PickupDirectory
    Wscript.Echo "Queue Directory: " & objItem.QueueDirectory
    Wscript.Echo "Realm: " & objItem.Realm
    Wscript.Echo "Relay For Authentication : " & objItem.RelayForAuth
    For Each strIP in objItem.RelayIpList
        Wscript.Echo "Relay IP List: " & strIP
    Next
    Wscript.Echo "Remote Retry Attempts: " & _
        objItem.RemoteRetryAttempts
    Wscript.Echo "Remote Retry Interval: " & _
        objItem.RemoteRetryInterval
    Wscript.Echo "Remote SMTP Port: " & objItem.RemoteSmtpPort
    Wscript.Echo "Remote SMTP Secure Port: " & _
        objItem.RemoteSmtpSecurePort
    Wscript.Echo "Remote Timeout: " & objItem.RemoteTimeout
    Wscript.Echo "Route Action: " & objItem.RouteAction
    Wscript.Echo "Route Password: " & objItem.RoutePassword
    Wscript.Echo "Route User Name: " & objItem.RouteUserName
    Wscript.Echo "Routing Dll: " & objItem.RoutingDll
    Wscript.Echo "Sasl Logon Domain: " & objItem.SaslLogonDomain
    Wscript.Echo "Send Bad To: " & objItem.SendBadTo
    Wscript.Echo "Send Ndr To: " & objItem.SendNdrTo
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Should Deliver: " & objItem.ShouldDeliver
    Wscript.Echo "Should Pickup Mail: " & objItem.ShouldPickupMail
    Wscript.Echo "Should Pipeline In: " & objItem.ShouldPipelineIn
    Wscript.Echo "Should Pipeline Out: " & objItem.ShouldPipelineOut
    Wscript.Echo "Smart Host: " & objItem.SmartHost
    Wscript.Echo "Smart Host Type: " & objItem.SmartHostType
    Wscript.Echo "SMTP Adv Queue Dll: " & objItem.SmtpAdvQueueDll
    Wscript.Echo "SMTP Aqueue Wait: " & objItem.SmtpAqueueWait
    Wscript.Echo "SMTP Authetication Timeout: " & _
        objItem.SmtpAuthTimeout
    Wscript.Echo "SMTP Bdat Timeout: " & objItem.SmtpBdatTimeout
    Wscript.Echo "SMTP Clear Text Provider: " & _
        objItem.SmtpClearTextProvider
    Wscript.Echo "SMTP Command Log Mask: " & _
        objItem.SmtpCommandLogMask
    Wscript.Echo "SMTP Connect Timeout: " & _
        objItem.SmtpConnectTimeout
    Wscript.Echo "SMTP Data Timeout: " & objItem.SmtpDataTimeout
    Wscript.Echo "SMTP Disable Relay: " & objItem.SmtpDisableRelay
    Wscript.Echo "SMTP Domain Validation Flags: " & _
        objItem.SmtpDomainValidationFlags
    Wscript.Echo "SMTP Dot Stuff Pickup Directory Files: " & _
        objItem.SmtpDotStuffPickupDirFiles
    Wscript.Echo "SMTP DSN Language ID: " & _
        objItem.SmtpDSNLanguageID
    Wscript.Echo "SMTP DSN Options: " & objItem.SmtpDSNOptions
    Wscript.Echo "SMTP Eventlog Level: " & objItem.SmtpEventlogLevel
    Wscript.Echo "SMTP Flush Mail File: " & _
        objItem.SmtpFlushMailFile
    Wscript.Echo "SMTP Helo No Domain: " & objItem.SmtpHeloNoDomain
    Wscript.Echo "SMTP Helo Timeout: " & objItem.SmtpHeloTimeout
    Wscript.Echo "SMTP Inbound Command Support Options: " & _
        objItem.SmtpInboundCommandSupportOptions
    Wscript.Echo "SMTP IP Restriction Flag: " & _
        objItem.SmtpIpRestrictionFlag
    Wscript.Echo "SMTP Local Delay Expire Minutes: " & _
        objItem.SmtpLocalDelayExpireMinutes
    Wscript.Echo "SMTP Local NDR Expire Minutes: " & _
        objItem.SmtpLocalNDRExpireMinutes
    Wscript.Echo "SMTP Mail From Timeout: " & _
        objItem.SmtpMailFromTimeout
    Wscript.Echo "SMTP Mail No Helo: " & objItem.SmtpMailNoHelo
    Wscript.Echo "SMTP Maximum Remote Q Threads: " & _
        objItem.SmtpMaxRemoteQThreads
    Wscript.Echo "SMTP Outbound Command Support Options: " & _
        objItem.SmtpOutboundCommandSupportOptions
    Wscript.Echo "SMTP Rcpt To Timeout: " & objItem.SmtpRcptToTimeout
    Wscript.Echo "SMTP Remote Delay Expire Minutes: " & _
        objItem.SmtpRemoteDelayExpireMinutes
    Wscript.Echo "SMTP Remote NDR Expire Minutes: " & _
        objItem.SmtpRemoteNDRExpireMinutes
    Wscript.Echo "SMTP Remote Progressive Retry: " & _
        objItem.SmtpRemoteProgressiveRetry
    Wscript.Echo "SMTP Remote Retry Threshold: " & _
        objItem.SmtpRemoteRetryThreshold
    Wscript.Echo "SMTP Rset Timeout: " & objItem.SmtpRsetTimeout
    Wscript.Echo "SMTP Sasl Timeout: " & objItem.SmtpSaslTimeout
    Wscript.Echo "SMTP SSL Certificate Hostname Validation: " & _
        objItem.SmtpSSLCertHostnameValidation
    Wscript.Echo "SMTP SSL Require Trusted CA: " & _
        objItem.SmtpSSLRequireTrustedCA
    Wscript.Echo "SMTP Turn Timeout: " & objItem.SmtpTurnTimeout
    Wscript.Echo "SMTP Use Tcp Dns: " & objItem.SmtpUseTcpDns
    Wscript.Echo "Updated Default Domain: " & _
        objItem.UpdatedDefaultDomain
    Wscript.Echo "Updated FQDN: " & objItem.UpdatedFQDN
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Sessions

Description
Returns the names of all the SMTP sessions running on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsSmtpSessions")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Virtual Directories

Description
Returns the names of all the virtual SMTP directories on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery( _
    "Select * from IIsSmtpVirtualDir")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Virtual Directory Properties

Description
Returns global SMTP virtual directory metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "UNC Password: " & objItem.UNCPassword
    Wscript.Echo "UNC User Name: " & objItem.UNCUserName
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Virtual Server Delivery Properties

Description
Returns global SMTP delivery metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "SMTP Local Delay Expire Minutes: " & _
        objItem.SmtpLocalDelayExpireMinutes
    Wscript.Echo "SMTP Local NDR Expire Minutes: " & _
        objItem.SmtpLocalNDRExpireMinutes
    Wscript.Echo "SMTP Remote Delay Expire Minutes: " & _
        objItem.SmtpRemoteDelayExpireMinutes
    Wscript.Echo "SMTP Remote NDR Expire Minutes: " & _
        objItem.SmtpRemoteNDRExpireMinutes
    Wscript.Echo "SMTP Remote Progressive Retry: " & _
        objItem.SmtpRemoteProgressiveRetry
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Virtual Server General Properties

Description
Returns global SMTP general metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SMTP Virtual Server Message Properties

Description
Returns global SMTP message metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

 For Each objItem in colItems
    Wscript.Echo "Bad Mail Directory: " & objItem.BadMailDirectory
    Wscript.Echo "Maximum Batched Messages: " & _
        objItem.MaxBatchedMessages
    Wscript.Echo "Maximum Message Size: " & objItem.MaxMessageSize
    Wscript.Echo "Maximum Recipients: " & objItem.MaxRecipients
    Wscript.Echo "Maximum Session Size: " & objItem.MaxSessionSize
    Wscript.Echo "Send Ndr To: " & objItem.SendNdrTo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the SMTP Server Version

Description
Returns the version of the SMTP Server service running on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsSmtpInfo")

For Each objItem in colItems
    Wscript.Echo "Major IIS Version Number: " & _
        objItem.MajorIIsVersionNumber
    Wscript.Echo "Minor IIS Version Number: " & _
        objItem.MinorIIsVersionNumber
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an SMTP Service Property Using ADSI

Description
Demonstration script that modifies an SMTP service property (ServerComment) in the IIS metabase.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "LocalHost"

Set objIIS = GetObject("IIS://" & strComputer & "/SMTPSVC")
objIIS.ServerComment = "This is an internal SMTP server."
objIIS.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Advanced Delivery Options

Description
Demonstration script that modifies global SMTP advanced delivery metabase properties on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    objItem.EnableReverseDnsLookup = False
    objItem.HopCount = 10
    objItem.MasqueradeDomain = "fabrikam.com"
    objItem.SmartHost = "smtp-server.fabrikam.com"
    objItem.SmartHostType = 1
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Authentication Properties

Description
Demonstration script that modifies global SMTP authentication metabase properties on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    objItem.AuthAnonymous = True
    objItem.AuthBasic = True
    objItem.AuthNTLM = True
    objItem.SaslLogonDomain = "fabrikam.com"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Outbound Connection Properties

Description
Demonstration script that modifies global SMTP outbound connection metabase properties on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    objItem.MaxOutConnections = 500
    objItem.MaxOutConnectionsPerDomain = 250
    objItem.RemoteSmtpPort = 25
    objItem.RemoteTimeout = 900
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Virtual Server Delivery Properties

Description
Demonstration script that modifies global SMTP virtual directory metabase property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    objItem.SmtpLocalDelayExpireMinutes = 1000
    objItem.SmtpLocalNDRExpireMinutes = 4000
    objItem.SmtpRemoteDelayExpireMinutes = 1000
    objItem.SmtpRemoteNDRExpireMinutes = 4000
    objItem.SmtpRemoteProgressiveRetry = "60,120,240"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Virtual Server General Properties

Description
Demonstration script that modifies global SMTP metabase property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

For Each objItem in colItems
    objItem.ConnectionTimeout = 1200
    objItem.DontLog = True
    objItem.MaxConnections = 10000
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SMTP Virtual Server Message Properties

Description
Demonstration script that modifies global SMTP virtual server message metabase property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsSmtpServiceSetting")

 For Each objItem in colItems
    objItem.BadMailDirectory = "C:\Badmail"
    objItem.MaxBatchedMessages = 30
    objItem.MaxMessageSize = 500000
    objItem.MaxRecipients = 50
    objItem.MaxSessionSize = 1000000
    objItem.SendNdrTo = "email-admin@fabrikam.com"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Continue a Paused Web Server

Description
Continues a paused Web server named W3SVC/2142295254.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebServer Where Name = " & _
        "'W3SVC/2142295254'")

For Each objItem in colItems
    objItem.Continue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a New Web Site

Description
Creates a new Web site named Test Site.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set objWebService = objWMIService.ExecQuery _
    ("Select * From IISWebService")

arrBindings = Array(0)
Set arrBindings(0) = _
    objWMIService.Get("ServerBinding").SpawnInstance_()
arrBindings(0).IP = "192.168.1.1"
arrBindings(0).Port = "8383"
arrBindings(0).Hostname = "atl-ws-01"

For Each objItem in objWebService
    objItem.CreateNewSite "Test Site", arrBindings, _
        "c:\inetpub\wwwroot"
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Basic Web Site Properties

Description
Lists global Web site metabase property values for a server running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Allow Keep Alive: " & objItem.AllowKeepAlive
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Server Comment: " & objItem.ServerComment
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Directories

Description
Returns information about all the virtual Web directories on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebVirtualDir")

For Each objItem in colItems
    Wscript.Echo "Application Isolated: " & objItem.AppIsolated
    Wscript.Echo "Application Package ID: " & objItem.AppPackageID
    Wscript.Echo "Application Package Name: " & objItem.AppPackageName
    Wscript.Echo "Application Root: " & objItem.AppRoot
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Directory Information

Description
Returns global Web virtual directory metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebVirtualDirSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & objItem.AnonymousUserPass
    Wscript.Echo "Application Allow Client Debug: " & _
        objItem.AppAllowClientDebug
    Wscript.Echo "Application Allow Debugging: " & _
        objItem.AppAllowDebugging
    Wscript.Echo "Application Friendly Name: " & objItem.AppFriendlyName
    Wscript.Echo "Application Oop Recover Limit: " & _
        objItem.AppOopRecoverLimit
    Wscript.Echo "Application Pool Id: " & objItem.AppPoolId
    Wscript.Echo "Application Wam Clsid: " & objItem.AppWamClsid
    Wscript.Echo "ASP Allow Out Of Process Components: " & _
        objItem.AspAllowOutOfProcComponents
    Wscript.Echo "ASP Allow Session State: " & _
        objItem.AspAllowSessionState
    Wscript.Echo "ASP Application Service Flags: " & _
        objItem.AspAppServiceFlags
    Wscript.Echo "ASP Buffering Limit: " & objItem.AspBufferingLimit
    Wscript.Echo "ASP Buffering On: " & objItem.AspBufferingOn
    Wscript.Echo "ASP Calc Line Number: " & objItem.AspCalcLineNumber
    Wscript.Echo "ASP Codepage: " & objItem.AspCodepage
    Wscript.Echo "ASP Disk Template Cache Directory: " & _
        objItem.AspDiskTemplateCacheDirectory
    Wscript.Echo "ASP Enable Application Restart: " & _
        objItem.AspEnableApplicationRestart
    Wscript.Echo "ASP Enable ASP Html Fallback: " & _
        objItem.AspEnableAspHtmlFallback
    Wscript.Echo "ASP Enable Chunked Encoding: " & _
        objItem.AspEnableChunkedEncoding
    Wscript.Echo "ASP Enable Parent Paths: " & _
        objItem.AspEnableParentPaths
    Wscript.Echo "ASP Enable Sxs: " & objItem.AspEnableSxs
    Wscript.Echo "ASP Enable Tracker: " & objItem.AspEnableTracker
    Wscript.Echo "ASP Enable Typelib Cache: " & _
        objItem.AspEnableTypelibCache
    Wscript.Echo "ASP Errors To NT Log: " & objItem.AspErrorsToNTLog
    Wscript.Echo "ASP Exception Catch Enable: " & _
        objItem.AspExceptionCatchEnable
    Wscript.Echo "ASP Execute In MTA: " & objItem.AspExecuteInMTA
    Wscript.Echo "ASP Keep Session ID Secure: " & _
        objItem.AspKeepSessionIDSecure
    Wscript.Echo "ASP LCID: " & objItem.AspLCID
    Wscript.Echo "ASP Log Error Requests: " & _
        objItem.AspLogErrorRequests
    Wscript.Echo "ASP Maximum Disk Template Cache Files: " & _
        objItem.AspMaxDiskTemplateCacheFiles
    Wscript.Echo "ASP Maximum Request Entity Allowed: " & _
        objItem.AspMaxRequestEntityAllowed
    Wscript.Echo "ASP Partition ID: " & objItem.AspPartitionID
    Wscript.Echo "ASP Processor Thread Maximum: " & _
        objItem.AspProcessorThreadMax
    Wscript.Echo "ASP Queue Connection Test Time: " & _
        objItem.AspQueueConnectionTestTime
    Wscript.Echo "ASP Queue Timeout: " & objItem.AspQueueTimeout
    Wscript.Echo "ASP Request Queue Maximum: " & _
        objItem.AspRequestQueueMax
    Wscript.Echo "AspRunOnEndAnonymously: " & _
        objItem.AspRunOnEndAnonymously
    Wscript.Echo "ASP Script Engine Cache Max: " & _
        objItem.AspScriptEngineCacheMax
    Wscript.Echo "ASP Script Error Message: " & _
        objItem.AspScriptErrorMessage
    Wscript.Echo "ASP Script Error Sent To Browser: " & _
        objItem.AspScriptErrorSentToBrowser
    Wscript.Echo "ASP Script File Cache Size: " & _
        objItem.AspScriptFileCacheSize
    Wscript.Echo "ASP Script Language: " & objItem.AspScriptLanguage
    Wscript.Echo "ASP Script Timeout: " & objItem.AspScriptTimeout
    Wscript.Echo "ASP Session Maximum: " & objItem.AspSessionMax
    Wscript.Echo "ASP Session Timeout: " & objItem.AspSessionTimeout
    Wscript.Echo "ASP Sxs Name: " & objItem.AspSxsName
    Wscript.Echo "ASP Track Threading Model: " & _
        objItem.AspTrackThreadingModel
    Wscript.Echo "ASP Use Partition: " & objItem.AspUsePartition
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Authentication Persistence: " & _
        objItem.AuthPersistence
    Wscript.Echo "Authentication Persist Single Request: " & _
        objItem.AuthPersistSingleRequest
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Impersonation Level: " & objItem.AzImpersonationLevel
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "BITS Allow Overwrites: " & objItem.BITSAllowOverwrites
    Wscript.Echo "BITS Cleanup Work Item Key: " & _
        objItem.BITSCleanupWorkItemKey
    Wscript.Echo "BITS Host ID: " & objItem.BITSHostId
    Wscript.Echo "BITS Host ID Fallback Timeout: " & _
        objItem.BITSHostIdFallbackTimeout
    Wscript.Echo "BITS Maximum Upload Size: " & _
        objItem.BITSMaximumUploadSize
    Wscript.Echo "BITS Server Notification Type: " & _
        objItem.BITSServerNotificationType
    Wscript.Echo "BITS Server Notification URL: " & _
        objItem.BITSServerNotificationURL
    Wscript.Echo "BITS Session Directory: " & _
        objItem.BITSSessionDirectory
    Wscript.Echo "BITS Session Timeout: " & objItem.BITSSessionTimeout
    Wscript.Echo "BITS Upload Enabled: " & objItem.BITSUploadEnabled
    Wscript.Echo "BITS Upload Metadata Version: " & _
        objItem.BITSUploadMetadataVersion
    Wscript.Echo "Cache Control Custom: " & objItem.CacheControlCustom
    Wscript.Echo "Cache Control Maximum Age: " & _
        objItem.CacheControlMaxAge
    Wscript.Echo "Cache Control No Cache: " & objItem.CacheControlNoCache
    Wscript.Echo "Cache ISAPI: " & objItem.CacheISAPI
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CGI Timeout: " & objItem.CGITimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Create CGI With New Console: " & _
        objItem.CreateCGIWithNewConsole
    Wscript.Echo "Create Process As User: " & objItem.CreateProcessAsUser
    Wscript.Echo "Default Doc: " & objItem.DefaultDoc
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Browse Flags: " & objItem.DirBrowseFlags
    Wscript.Echo "Directory Browse Show Date: " & objItem.DirBrowseShowDate
    Wscript.Echo "Directory Browse Show Extension: " & _
        objItem.DirBrowseShowExtension
    Wscript.Echo "Directory Browse Show Long Date: " & _
        objItem.DirBrowseShowLongDate
    Wscript.Echo "Directory Browse Show Size: " & objItem.DirBrowseShowSize
    Wscript.Echo "Directory Browse Show Time: " & objItem.DirBrowseShowTime
    Wscript.Echo "Disable Static File Cache: " & _
        objItem.DisableStaticFileCache
    Wscript.Echo "Do Dynamic Compression: " & objItem.DoDynamicCompression
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Do Static Compression: " & objItem.DoStaticCompression
    Wscript.Echo "Enable Default Doc: " & objItem.EnableDefaultDoc
    Wscript.Echo "Enable Directory Browsing: " & objItem.EnableDirBrowsing
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
    Wscript.Echo "Enable Reverse Dns: " & objItem.EnableReverseDns
    Wscript.Echo "FrontPage Web: " & objItem.FrontPageWeb
    Wscript.Echo "Http Expires: " & objItem.HttpExpires
    Wscript.Echo "Http Redirect: " & objItem.HttpRedirect
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Maximum Request Entity Allowed: " & _
        objItem.MaxRequestEntityAllowed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Passport Require AD Mapping: " & _
        objItem.PassportRequireADMapping
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Pool Idc Timeout: " & objItem.PoolIdcTimeout
    Wscript.Echo "Realm: " & objItem.Realm
    For Each strHeader in objItem.RedirectHeaders
        Wscript.Echo "Redirect Headers: " &  strHeader
    Next
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SSI Exec Disable: " & objItem.SSIExecDisable
    Wscript.Echo "UNC Password: " & objItem.UNCPassword
    Wscript.Echo "UNC User Name: " & objItem.UNCUserName
    Wscript.Echo "Upload Read Ahead Size: " & objItem.UploadReadAheadSize
    Wscript.Echo "Use Digest SSP: " & objItem.UseDigestSSP
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Directories

Description
Returns information about all the Web directories on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebDirectory")

For Each objItem in colItems
    Wscript.Echo "Application Isolated: " & objItem.AppIsolated
    Wscript.Echo "Application Package ID: " & objItem.AppPackageID
    Wscript.Echo "Application Package Name: " & objItem.AppPackageName
    Wscript.Echo "Application Root: " & objItem.AppRoot
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Status: " & objItem.Status
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Directory Property Information

Description
Returns global Web directory metabase property values on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebDirectorySetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & _
        objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & _
        objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & o_
        bjItem.AnonymousUserPass
    Wscript.Echo "Application Allow Client Debug: " & _
        objItem.AppAllowClientDebug
    Wscript.Echo "Application Allow Debugging: " & _
        objItem.AppAllowDebugging
    Wscript.Echo "Application Friendly Name: " & _
        objItem.AppFriendlyName
    Wscript.Echo "Application Oop Recover Limit: " & _
        objItem.AppOopRecoverLimit
    Wscript.Echo "Application Pool ID: " & objItem.AppPoolId
    Wscript.Echo "Application Wam Clsid: " & objItem.AppWamClsid
    Wscript.Echo "ASP Allow Out Of Process Components: " & _
        objItem.AspAllowOutOfProcComponents
    Wscript.Echo "ASP Allow Session State: " & _
        objItem.AspAllowSessionState
    Wscript.Echo "ASP Application Service Flags: " & _
        objItem.AspAppServiceFlags
    Wscript.Echo "ASP Buffering Limit: " & objItem.AspBufferingLimit
    Wscript.Echo "ASP Buffering On: " & objItem.AspBufferingOn
    Wscript.Echo "ASP Calc Line Number: " & objItem.AspCalcLineNumber
    Wscript.Echo "ASP Codepage: " & objItem.AspCodepage
    Wscript.Echo "ASP Disk Template Cache Directory: " & _
        objItem.AspDiskTemplateCacheDirectory
    Wscript.Echo "ASP Enable Application Restart: " & _
        objItem.AspEnableApplicationRestart
    Wscript.Echo "ASP Enable ASP Html Fallback: " & _
        objItem.AspEnableAspHtmlFallback
    Wscript.Echo "ASP Enable Chunked Encoding: " & _
        objItem.AspEnableChunkedEncoding
    Wscript.Echo "ASP Enable Parent Paths: " & _
        objItem.AspEnableParentPaths
    Wscript.Echo "ASP Enable Sxs: " & objItem.AspEnableSxs
    Wscript.Echo "ASP Enable Tracker: " & objItem.AspEnableTracker
    Wscript.Echo "ASP Enable Typelib Cache: " & _
        objItem.AspEnableTypelibCache
    Wscript.Echo "ASP Errors To NT Log: " & objItem.AspErrorsToNTLog
    Wscript.Echo "ASP Exception Catch Enable: " & _
        objItem.AspExceptionCatchEnable
    Wscript.Echo "ASP Execute In MTA: " & objItem.AspExecuteInMTA
    Wscript.Echo "ASP Keep Session ID Secure: " & o_
        bjItem.AspKeepSessionIDSecure
    Wscript.Echo "ASP LCID: " & objItem.AspLCID
    Wscript.Echo "ASP Log Error Requests: " & _
        objItem.AspLogErrorRequests
    Wscript.Echo "ASP Max Disk Template Cache Files: " & _
        objItem.AspMaxDiskTemplateCacheFiles
    Wscript.Echo "ASP Max Request Entity Allowed: " & _
        objItem.AspMaxRequestEntityAllowed
    Wscript.Echo "ASP Partition ID: " & objItem.AspPartitionID
    Wscript.Echo "ASP Processor Thread Max: " & objItem.AspProcessorThreadMax
    Wscript.Echo "ASP Queue Connection Test Time: " & _
        objItem.AspQueueConnectionTestTime
    Wscript.Echo "ASP Queue Timeout: " & objItem.AspQueueTimeout
    Wscript.Echo "ASP Request Queue Max: " & objItem.AspRequestQueueMax
    Wscript.Echo "ASP Run On End Anonymously: " & _
        objItem.AspRunOnEndAnonymously
    Wscript.Echo "ASP Script Engine Cache Maximum: " & _
        objItem.AspScriptEngineCacheMax
    Wscript.Echo "ASP Script Error Message: " & objItem.AspScriptErrorMessage
    Wscript.Echo "ASP Script Error Sent To Browser: " & _
        objItem.AspScriptErrorSentToBrowser
    Wscript.Echo "ASP Script File Cache Size: " & _
        objItem.AspScriptFileCacheSize
    Wscript.Echo "ASP Script Language: " & objItem.AspScriptLanguage
    Wscript.Echo "ASP Script Timeout: " & objItem.AspScriptTimeout
    Wscript.Echo "ASP Session Maximum: " & objItem.AspSessionMax
    Wscript.Echo "ASP Session Timeout: " & objItem.AspSessionTimeout
    Wscript.Echo "ASP Sxs Name: " & objItem.AspSxsName
    Wscript.Echo "ASP Track Threading Model: " & _
        objItem.AspTrackThreadingModel
    Wscript.Echo "ASP Use Partition: " & objItem.AspUsePartition
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Authentication Persistence: " & objItem.AuthPersistence
    Wscript.Echo "Authentication PersistSingleRequest: " & _
        objItem.AuthPersistSingleRequest
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Impersonation Level: " & objItem.AzImpersonationLevel
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Cache Control Custom: " & objItem.CacheControlCustom
    Wscript.Echo "Cache Control Maximum Age: " & objItem.CacheControlMaxAge
    Wscript.Echo "Cache Control No Cache: " & objItem.CacheControlNoCache
    Wscript.Echo "Cache ISAPI: " & objItem.CacheISAPI
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CGI Timeout: " & objItem.CGITimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Create CGI With New Console: " & _
        objItem.CreateCGIWithNewConsole
    Wscript.Echo "Create Process As User: " & objItem.CreateProcessAsUser
    Wscript.Echo "Default Doc: " & objItem.DefaultDoc
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Browse Flags: " & objItem.DirBrowseFlags
    Wscript.Echo "Directory Browse Show Date: " & _
        objItem.DirBrowseShowDate
    Wscript.Echo "Directory Browse Show Extension: " & _
        objItem.DirBrowseShowExtension
    Wscript.Echo "Directory Browse Show Long Date: " & _
        objItem.DirBrowseShowLongDate
    Wscript.Echo "Directory Browse Show Size: " & objItem.DirBrowseShowSize
    Wscript.Echo "Directory Browse Show Time: " & objItem.DirBrowseShowTime
    Wscript.Echo "Disable Static File Cache: " & _
        objItem.DisableStaticFileCache
    Wscript.Echo "Do Dynamic Compression: " & objItem.DoDynamicCompression
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Do Static Compression: " & objItem.DoStaticCompression
    Wscript.Echo "Enable Default Doc: " & objItem.EnableDefaultDoc
    Wscript.Echo "Enable Dir Browsing: " & objItem.EnableDirBrowsing
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
    Wscript.Echo "Enable Reverse DNS: " & objItem.EnableReverseDns
    Wscript.Echo "FrontPage Web: " & objItem.FrontPageWeb
    Wscript.Echo "Http Expires: " & objItem.HttpExpires
    Wscript.Echo "Http Redirect: " & objItem.HttpRedirect
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Maximum Request Entity Allowed: " & _
        objItem.MaxRequestEntityAllowed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Passport Require AD Mapping: " & _
        objItem.PassportRequireADMapping
    Wscript.Echo "Pool Idc Timeout: " & objItem.PoolIdcTimeout
    Wscript.Echo "Realm: " & objItem.Realm
    For Each strHeader in objItem.RedirectHeaders
        Wscript.Echo "Redirect Headers: " & strHeader
    Next
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown TimeL imit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SSI Exec Disable: " & objItem.SSIExecDisable
    Wscript.Echo "Upload Read Ahead Size: " & _
        objItem.UploadReadAheadSize
    Wscript.Echo "Use Digest SSP: " & objItem.UseDigestSSP
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web File Property Information

Description
Returns global Web file metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebFileSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory : " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & objItem.AnonymousUserPass
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "AuthenticationPassport: " & objItem.AuthPassport
    Wscript.Echo "Authentication Persistence: " & objItem.AuthPersistence
    Wscript.Echo "Authentication Persist Single Request: " & _
        objItem.AuthPersistSingleRequest
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Impersonation Level: " & objItem.AzImpersonationLevel
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Cache Control Custom: " & objItem.CacheControlCustom
    Wscript.Echo "Cache Control Maximum Age: " & objItem.CacheControlMaxAge
    Wscript.Echo "Cache Control No Cache: " & objItem.CacheControlNoCache
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CGI Timeout: " & objItem.CGITimeout
    Wscript.Echo "Create CGI With New Console: " & _
        objItem.CreateCGIWithNewConsole
    Wscript.Echo "Create Process As User: " & objItem.CreateProcessAsUser
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disable Static File Cache: " & _
        objItem.DisableStaticFileCache
    Wscript.Echo "Do Dynamic Compression: " & objItem.DoDynamicCompression
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Do Static Compression: " & objItem.DoStaticCompression
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
    Wscript.Echo "Enable Reverse Dns: " & objItem.EnableReverseDns
    Wscript.Echo "Http Expires: " & objItem.HttpExpires
    Wscript.Echo "Http Redirect: " & objItem.HttpRedirect
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Maximum Request Entity Allowed: " & _
        objItem.MaxRequestEntityAllowed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Passport Require AD Mapping: " & _
        objItem.PassportRequireADMapping
    Wscript.Echo "Pool Idc Timeout: " & objItem.PoolIdcTimeout
    Wscript.Echo "Realm: " & objItem.Realm
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "SSI Exec Disable: " & objItem.SSIExecDisable
    Wscript.Echo "Upload Read Ahead Size: " & _
        objItem.UploadReadAheadSize
    Wscript.Echo "Use Digest SSP: " & objItem.UseDigestSSP
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Files

Description
Lists the names of all the Web files found on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebFile")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server Configuration Information

Description
Returns global Web info metabase property values for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebInfoSetting")

For Each objItem in colItems
    Wscript.Echo "Admin Server: " & objItem.AdminServer
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Server Configuration Auto Password Sync: " & _
        objItem.ServerConfigAutoPWSync
    Wscript.Echo "Server Configuration Flags: " & _
        objItem.ServerConfigFlags
    Wscript.Echo "Server Configuration SSL 128: " & _
        objItem.ServerConfigSSL128
    Wscript.Echo "Server Configuration SSL 40: " & _
        objItem.ServerConfigSSL40
    Wscript.Echo "Server Configuration SSL Allow Encryption: " & _
        objItem.ServerConfigSSLAllowEncrypt
    Wscript.Echo "Setting ID: " & objItem.SettingID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server Information

Description
Returns global Web server information for a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServer")

For Each objItem in colItems
    Wscript.Echo "Application Isolated: " & objItem.AppIsolated
    Wscript.Echo "Application Package ID: " & objItem.AppPackageID
    Wscript.Echo "Application Package Name: " & objItem.AppPackageName
    Wscript.Echo "Application Root: " & objItem.AppRoot
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Server State: " & objItem.ServerState
    Wscript.Echo "Status: " & objItem.Status
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Server Setting Information

Description
Displays information about all the Web sites on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServerSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Allow Keep Alive: " & objItem.AllowKeepAlive
    Wscript.Echo "Allow Path Information For Script Mappings: " & _
        objItem.AllowPathInfoForScriptMappings
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & objItem.AnonymousUserPass
    Wscript.Echo "Applocation Allow Client Debug: " & _
        objItem.AppAllowClientDebug
    Wscript.Echo "Application Allow Debugging: " & _
        objItem.AppAllowDebugging
    Wscript.Echo "Application Friendly Name: " & objItem.AppFriendlyName
    Wscript.Echo "Application Oop Recover Limit: " & _
        objItem.AppOopRecoverLimit
    Wscript.Echo "Application Pool Id: " & objItem.AppPoolId
    Wscript.Echo "Application Wam Clsid: " & objItem.AppWamClsid
    Wscript.Echo "ASP Allow Out Of Process Components: " & _
        objItem.AspAllowOutOfProcComponents
    Wscript.Echo "ASP Allow Session State: " & _
        objItem.AspAllowSessionState
    Wscript.Echo "ASP Application Service Flags: " & _
        objItem.AspAppServiceFlags
    Wscript.Echo "ASP Buffering Limit: " & objItem.AspBufferingLimit
    Wscript.Echo "ASP Buffering On: " & objItem.AspBufferingOn
    Wscript.Echo "ASP Calc Line Number: " & objItem.AspCalcLineNumber
    Wscript.Echo "ASP Codepage: " & objItem.AspCodepage
    Wscript.Echo "ASP Disk Template Cache Directory: " & _
        objItem.AspDiskTemplateCacheDirectory
    Wscript.Echo "ASP Enable Application Restart: " & _
        objItem.AspEnableApplicationRestart
    Wscript.Echo "ASP Enable ASP Html Fallback: " & _
        objItem.AspEnableAspHtmlFallback
    Wscript.Echo "ASP Enable Chunked Encoding: " & o_
        bjItem.AspEnableChunkedEncoding
    Wscript.Echo "ASP Enable Parent Paths: " & _
        objItem.AspEnableParentPaths
    Wscript.Echo "ASP Enable Sxs: " & objItem.AspEnableSxs
    Wscript.Echo "ASP Enable Tracker: " & objItem.AspEnableTracker
    Wscript.Echo "ASP Enable Typelib Cache: " & _
        objItem.AspEnableTypelibCache
    Wscript.Echo "ASP Errors To NT Log: " & objItem.AspErrorsToNTLog
    Wscript.Echo "ASP Exception Catch Enable: " & _
        objItem.AspExceptionCatchEnable
    Wscript.Echo "ASP Execute In MTA: " & objItem.AspExecuteInMTA
    Wscript.Echo "ASP Keep Session ID Secure: " & _
        objItem.AspKeepSessionIDSecure
    Wscript.Echo "ASP LCID: " & objItem.AspLCID
    Wscript.Echo "ASP Log Error Requests: " & _
        objItem.AspLogErrorRequests
    Wscript.Echo "ASP Maximum Disk Template Cache Files: " & _
        objItem.AspMaxDiskTemplateCacheFiles
    Wscript.Echo "ASP Maximum Request Entity Allowed: " & _
        objItem.AspMaxRequestEntityAllowed
    Wscript.Echo "ASP Partition ID: " & objItem.AspPartitionID
    Wscript.Echo "ASP Processor Thread Maximum: " & _
        objItem.AspProcessorThreadMax
    Wscript.Echo "ASP Queue Connection Test Time: " & _
        objItem.AspQueueConnectionTestTime
    Wscript.Echo "ASP Queue Timeout: " & objItem.AspQueueTimeout
    Wscript.Echo "ASP Request Queue Maximum: " & _
        objItem.AspRequestQueueMax
    Wscript.Echo "ASP Run OnEnd Anonymously: " & _
        objItem.AspRunOnEndAnonymously
    Wscript.Echo "ASP Script Engine Cache Maximum: " & _
        objItem.AspScriptEngineCacheMax
    Wscript.Echo "ASP Script Error Message: " & _
        objItem.AspScriptErrorMessage
    Wscript.Echo "ASP Script Error Sent To Browser: " & _
        objItem.AspScriptErrorSentToBrowser
    Wscript.Echo "ASP Script File Cache Size: " & _
        objItem.AspScriptFileCacheSize
    Wscript.Echo "ASP Script Language: " & objItem.AspScriptLanguage
    Wscript.Echo "ASP Script Timeout: " & objItem.AspScriptTimeout
    Wscript.Echo "ASP Session Maximum: " & objItem.AspSessionMax
    Wscript.Echo "ASP Session Timeout: " & objItem.AspSessionTimeout
    Wscript.Echo "ASP Sxs Name: " & objItem.AspSxsName
    Wscript.Echo "ASP Track Threading Model: " & _
        objItem.AspTrackThreadingModel
    Wscript.Echo "ASP Use Partition: " & objItem.AspUsePartition
    Wscript.Echo "Authentication Advanced Notify Disable: " & _
        objItem.AuthAdvNotifyDisable
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication Change Disable: " & _
        objItem.AuthChangeDisable
    Wscript.Echo "Authentication Change Unsecure: " & _
        objItem.AuthChangeUnsecure
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Authentication Persistence: " & objItem.AuthPersistence
    Wscript.Echo "Authentication PersistSingleRequest: " & _
        objItem.AuthPersistSingleRequest
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Impersonation Level: " & objItem.AzImpersonationLevel
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Cache Control Custom: " & objItem.CacheControlCustom
    Wscript.Echo "Cache Control Maximum Age: " & objItem.CacheControlMaxAge
    Wscript.Echo "Cache Control No Cache: " & objItem.CacheControlNoCache
    Wscript.Echo "Cache ISAPI: " & objItem.CacheISAPI
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Certifcate Check Mode: " & objItem.CertCheckMode
    Wscript.Echo "CGI Timeout: " & objItem.CGITimeout
    Wscript.Echo "Cluster Enabled: " & objItem.ClusterEnabled
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Create CGI With New Console: " & _
        objItem.CreateCGIWithNewConsole
    Wscript.Echo "Create Process As User: " & objItem.CreateProcessAsUser
    Wscript.Echo "Default Doc: " & objItem.DefaultDoc
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Browse Flags: " & objItem.DirBrowseFlags
    Wscript.Echo "Directory Browse Show Date: " & objItem.DirBrowseShowDate
    Wscript.Echo "Directory Browse Show Extension: " & _
        objItem.DirBrowseShowExtension
    Wscript.Echo "Directory Browse Show Long Date: " & _
        objItem.DirBrowseShowLongDate
    Wscript.Echo "Directory Browse Show Size: " & objItem.DirBrowseShowSize
    Wscript.Echo "Directory Browse Show Time: " & objItem.DirBrowseShowTime
    Wscript.Echo "Disable Socket Pooling: " & objItem.DisableSocketPooling
    Wscript.Echo "Disable Static File Cache: " & _
        objItem.DisableStaticFileCache
    Wscript.Echo "Do Dynamic Compression: " & objItem.DoDynamicCompression
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Do Static Compression: " & objItem.DoStaticCompression
    Wscript.Echo "Enable Default Doc: " & objItem.EnableDefaultDoc
    Wscript.Echo "Enable Dir Browsing: " & objItem.EnableDirBrowsing
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
    Wscript.Echo "Enable Reverse DNS: " & objItem.EnableReverseDns
    Wscript.Echo "FrontPage Web: " & objItem.FrontPageWeb
    Wscript.Echo "Http Expires: " & objItem.HttpExpires
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server IP: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Local Time Rollover: " & _
        objItem.LogFileLocaltimeRollover
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & objItem.LogFileTruncateSize
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Bandwidth Blocked: " & _
        objItem.MaxBandwidthBlocked
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum Request Entity Allowed: " & _
        objItem.MaxRequestEntityAllowed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Passport Require AD Mapping: " & _
        objItem.PassportRequireADMapping
    Wscript.Echo "Password Cache TTL: " & objItem.PasswordCacheTTL
    Wscript.Echo "Password Change Flags: " & objItem.PasswordChangeFlags
    Wscript.Echo "Password Expire Prenotify Days: " & _
        objItem.PasswordExpirePrenotifyDays
    Wscript.Echo "Pool Idc Timeout: " & objItem.PoolIdcTimeout
    Wscript.Echo "Process NT CRIf Logged On: " & _
        objItem.ProcessNTCRIfLoggedOn
    Wscript.Echo "Realm: " & objItem.Realm
    For Each strHeader in objItem.RedirectHeaders
        Wscript.Echo "Redirect Headers: " & strHeader
    Next
    Wscript.Echo "Revocation Freshness Time: " & _
        objItem.RevocationFreshnessTime
    Wscript.Echo "Revocation URL Retrieval Timeout: " & _
        objItem.RevocationURLRetrievalTimeout
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Command: " & objItem.ServerCommand
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server ID: " & objItem.ServerID
    Wscript.Echo "Server Listen Backlog: " & objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & objItem.ServerListenTimeout
    Wscript.Echo "Server Size: " & objItem.ServerSize
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SSI Exec Disable: " & objItem.SSIExecDisable
    Wscript.Echo "SSL Always Negotiate Client Certificate: " & _
        objItem.SSLAlwaysNegoClientCert
    Wscript.Echo "Ssl Ctl Identifier: " & objItem.SslCtlIdentifier
    Wscript.Echo "Ssl Ctl Store Name: " & objItem.SslCtlStoreName
    Wscript.Echo "SSL Store Name: " & objItem.SSLStoreName
    Wscript.Echo "Upload Read Ahead Size: " & _
        objItem.UploadReadAheadSize
    Wscript.Echo "Use Digest SSP: " & objItem.UseDigestSSP
    Wscript.Echo "Win32 Error: " & objItem.Win32Error
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Configuration Information

Description
Displays information about the IIS Web service service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebService")

For Each objItem in colItems
    Wscript.Echo "Accept Pause: " & objItem.AcceptPause
    Wscript.Echo "Accept Stop: " & objItem.AcceptStop
    Wscript.Echo "Application Isolated: " & objItem.AppIsolated
    Wscript.Echo "Application Package ID: " & objItem.AppPackageID
    Wscript.Echo "Application Package Name: " & _
        objItem.AppPackageName
    Wscript.Echo "Application Root: " & objItem.AppRoot
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check Point: " & objItem.CheckPoint
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Desktop Interact: " & objItem.DesktopInteract
    Wscript.Echo "Display Name: " & objItem.DisplayName
    Wscript.Echo "Error Control: " & objItem.ErrorControl
    Wscript.Echo "Exit Code: " & objItem.ExitCode
    Wscript.Echo "Installation Date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo "Process ID: " & objItem.ProcessId
    Wscript.Echo "Service Specific Exit Code: " & _
        objItem.ServiceSpecificExitCode
    Wscript.Echo "Service Type: " & objItem.ServiceType
    Wscript.Echo "SSL Certificate Hash: " & objItem.SSLCertHash
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Start Name: " & objItem.StartName
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Tag Id: " & objItem.TagId
    Wscript.Echo "Wait Hint: " & objItem.WaitHint
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Service Setting Properties

Description
Displays global Web site metabase property values for an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Access Execute: " & objItem.AccessExecute
    Wscript.Echo "Access Flags: " & objItem.AccessFlags
    Wscript.Echo "Access No Physical Directory: " & _
        objItem.AccessNoPhysicalDir
    Wscript.Echo "Access No Remote Execute: " & _
        objItem.AccessNoRemoteExecute
    Wscript.Echo "Access No Remote Read: " & objItem.AccessNoRemoteRead
    Wscript.Echo "Access No Remote Script: " & _
        objItem.AccessNoRemoteScript
    Wscript.Echo "Access No Remote Write: " & objItem.AccessNoRemoteWrite
    Wscript.Echo "Access Read: " & objItem.AccessRead
    Wscript.Echo "Access Script: " & objItem.AccessScript
    Wscript.Echo "Access Source: " & objItem.AccessSource
    Wscript.Echo "Access SSL: " & objItem.AccessSSL
    Wscript.Echo "Access SSL 128: " & objItem.AccessSSL128
    Wscript.Echo "Access SSL Flags: " & objItem.AccessSSLFlags
    Wscript.Echo "Access SSL Map Certificate: " & _
        objItem.AccessSSLMapCert
    Wscript.Echo "Access SSL Negotiate Certificate: " & _
        objItem.AccessSSLNegotiateCert
    Wscript.Echo "Access SSL Require Certificate: " & _
        objItem.AccessSSLRequireCert
    Wscript.Echo "Access Write: " & objItem.AccessWrite
    Wscript.Echo "Admin ACL Bin: " & objItem.AdminACLBin
    Wscript.Echo "Admin Server: " & objItem.AdminServer
    Wscript.Echo "Allow Keep Alive: " & objItem.AllowKeepAlive
    Wscript.Echo "Allow Path Information For Script Mappings: " & _
        objItem.AllowPathInfoForScriptMappings
    Wscript.Echo "Anonymous Password Sync: " & _
        objItem.AnonymousPasswordSync
    Wscript.Echo "Anonymous User Name: " & objItem.AnonymousUserName
    Wscript.Echo "Anonymous User Password: " & objItem.AnonymousUserPass
    Wscript.Echo "Application Allow Client Debug: " & _
        objItem.AppAllowClientDebug
    Wscript.Echo "Application Allow Debugging: " & _
        objItem.AppAllowDebugging
    Wscript.Echo "Application Friendly Name: " & objItem.AppFriendlyName
    Wscript.Echo "Application Pool ID: " & objItem.AppPoolId
    Wscript.Echo "Application Wam Clsid: " & objItem.AppWamClsid
    Wscript.Echo "ASP Allow Out Of Processs Components: " & _
        objItem.AspAllowOutOfProcComponents
    Wscript.Echo "ASP Allow Session State: " & _
        objItem.AspAllowSessionState
    Wscript.Echo "ASP Application Service Flags: " & _
        objItem.AspAppServiceFlags
    Wscript.Echo "ASP Buffering Limit: " & objItem.AspBufferingLimit
    Wscript.Echo "ASP Buffering On: " & objItem.AspBufferingOn
    Wscript.Echo "ASP Calc Line Number: " & objItem.AspCalcLineNumber
    Wscript.Echo "ASP Codepage: " & objItem.AspCodepage
    Wscript.Echo "ASP Disk Template Cache Directory: " & _
        objItem.AspDiskTemplateCacheDirectory
    Wscript.Echo "ASP Enable Application Restart: " & _
        objItem.AspEnableApplicationRestart
    Wscript.Echo "ASP Enable ASP Html Fallback: " & _
        objItem.AspEnableAspHtmlFallback
    Wscript.Echo "ASP Enable Chunked Encoding: " & o_
        bjItem.AspEnableChunkedEncoding
    Wscript.Echo "ASP Enable Parent Paths: " & _
        objItem.AspEnableParentPaths
    Wscript.Echo "ASP Enable Sxs: " & objItem.AspEnableSxs
    Wscript.Echo "ASP Enable Tracker: " & objItem.AspEnableTracker
    Wscript.Echo "ASP Enable Typelib Cache: " & _
        objItem.AspEnableTypelibCache
    Wscript.Echo "ASP Errors To NT Log: " & objItem.AspErrorsToNTLog
    Wscript.Echo "ASP Exception Catch Enable: " & _
        objItem.AspExceptionCatchEnable
    Wscript.Echo "ASP Execute in MTA: " & objItem.AspExecuteInMTA
    Wscript.Echo "ASP Keep Session ID Secure: " & _
        objItem.AspKeepSessionIDSecure
    Wscript.Echo "ASP LCID: " & objItem.AspLCID
    Wscript.Echo "ASP Log Error Requests: " & _
        objItem.AspLogErrorRequests
    Wscript.Echo "ASP Maximum Disk Template Cache Files: " & _
        objItem.AspMaxDiskTemplateCacheFiles
    Wscript.Echo "ASP Maximum Request Entity Allowed: " & _
        objItem.AspMaxRequestEntityAllowed
    Wscript.Echo "ASP Partition ID: " & objItem.AspPartitionID
    Wscript.Echo "ASP Processor Thread Maximum: " & _
        objItem.AspProcessorThreadMax
    Wscript.Echo "ASP Queue Connection Test Time: " & _
        objItem.AspQueueConnectionTestTime
    Wscript.Echo "ASP Queue Timeout: " & objItem.AspQueueTimeout
    Wscript.Echo "ASP Request Queue Maximum: " & _
        objItem.AspRequestQueueMax
    Wscript.Echo "ASP Run On End Anonymously: " & _
        objItem.AspRunOnEndAnonymously
    Wscript.Echo "ASP Script Engine Cache Maximum: " & _
        objItem.AspScriptEngineCacheMax
    Wscript.Echo "ASP Script Error Message: " & _
        objItem.AspScriptErrorMessage
    Wscript.Echo "ASP Script Error Sent To Browser: " & _
        objItem.AspScriptErrorSentToBrowser
    Wscript.Echo "ASP Script File Cache Size: " & _
        objItem.AspScriptFileCacheSize
    Wscript.Echo "ASP Script Language: " & objItem.AspScriptLanguage
    Wscript.Echo "ASP Script Timeout: " & objItem.AspScriptTimeout
    Wscript.Echo "ASP Session Max: " & objItem.AspSessionMax
    Wscript.Echo "ASP Session Timeout: " & objItem.AspSessionTimeout
    Wscript.Echo "ASP Sxs Name: " & objItem.AspSxsName
    Wscript.Echo "ASP Track Threading Model: " & _
        objItem.AspTrackThreadingModel
    Wscript.Echo "ASP Use Partition: " & objItem.AspUsePartition
    Wscript.Echo "Authentication Advanced Notify Disable: " & _
        objItem.AuthAdvNotifyDisable
    Wscript.Echo "Authentication Anonymous: " & objItem.AuthAnonymous
    Wscript.Echo "Authentication Basic: " & objItem.AuthBasic
    Wscript.Echo "Authentication ChangeDisable: " & _
        objItem.AuthChangeDisable
    Wscript.Echo "Authentication ChangeUnsecure: " & _
        objItem.AuthChangeUnsecure
    Wscript.Echo "Authentication ChangeURL: " & objItem.AuthChangeURL
    Wscript.Echo "Authentication ExpiredUnsecureURL: " & _
        objItem.AuthExpiredUnsecureURL
    Wscript.Echo "Authentication ExpiredURL: " & objItem.AuthExpiredURL
    Wscript.Echo "Authentication Flags: " & objItem.AuthFlags
    Wscript.Echo "Authentication MD5: " & objItem.AuthMD5
    Wscript.Echo "Authentication Notify Password Exp Unsecure URL: " & _
        objItem.AuthNotifyPwdExpUnsecureURL
    Wscript.Echo "Authentication Notify Password Exp URL: " & _
        objItem.AuthNotifyPwdExpURL
    Wscript.Echo "Authentication NTLM: " & objItem.AuthNTLM
    Wscript.Echo "Authentication Passport: " & objItem.AuthPassport
    Wscript.Echo "Authentication Persistence: " & objItem.AuthPersistence
    Wscript.Echo "Authentication PersistSingleRequest: " & _
        objItem.AuthPersistSingleRequest
    Wscript.Echo "Az Enable: " & objItem.AzEnable
    Wscript.Echo "Az Impersonation Level: " & _
        objItem.AzImpersonationLevel
    Wscript.Echo "Az Scope Name: " & objItem.AzScopeName
    Wscript.Echo "Az Store Name: " & objItem.AzStoreName
    Wscript.Echo "Cache Control Custom: " & objItem.CacheControlCustom
    Wscript.Echo "Cache Control Maximum Age: " & _
        objItem.CacheControlMaxAge
    Wscript.Echo "Cache Control No Cache: " & objItem.CacheControlNoCache
    Wscript.Echo "Cache ISAPI: " & objItem.CacheISAPI
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Central Binary Logging Enabled: " & _
        objItem.CentralBinaryLoggingEnabled
    Wscript.Echo "Certificate Check Mode: " & objItem.CertCheckMode
    Wscript.Echo "CGI Timeout: " & objItem.CGITimeout
    Wscript.Echo "Connection Timeout: " & objItem.ConnectionTimeout
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Create CGI With New Console: " & _
        objItem.CreateCGIWithNewConsole
    Wscript.Echo "Create Process As User: " & objItem.CreateProcessAsUser
    Wscript.Echo "Default Doc: " & objItem.DefaultDoc
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Default Logon Domain: " & objItem.DefaultLogonDomain
    Wscript.Echo "Demand Start Threshold: " & objItem.DemandStartThreshold
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Directory Browse Flags: " & objItem.DirBrowseFlags
    Wscript.Echo "Directory Browse Show Date: " & objItem.DirBrowseShowDate
    Wscript.Echo "Directory Browse Show Extension: " & _
        objItem.DirBrowseShowExtension
    Wscript.Echo "Directory Browse Show Long Date: " & _
        objItem.DirBrowseShowLongDate
    Wscript.Echo "Directory Browse Show Size: " & objItem.DirBrowseShowSize
    Wscript.Echo "Directory Browse Show Time: " & objItem.DirBrowseShowTime
    Wscript.Echo "Directory Levels To Scan: " & _
        objItem.DirectoryLevelsToScan
    Wscript.Echo "Disable Socket Pooling: " & objItem.DisableSocketPooling
    Wscript.Echo "Disable Static File Cache: " & _
        objItem.DisableStaticFileCache
    Wscript.Echo "Do Dynamic Compression: " & objItem.DoDynamicCompression
    Wscript.Echo "Don't Log: " & objItem.DontLog
    Wscript.Echo "Do Static Compression: " & objItem.DoStaticCompression
    Wscript.Echo "Downlevel Admin Instance: " & _
        objItem.DownlevelAdminInstance
    Wscript.Echo "Enable Default Doc: " & objItem.EnableDefaultDoc
    Wscript.Echo "Enable Directory Browsing: " & objItem.EnableDirBrowsing
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
    Wscript.Echo "Enable Reverse DNS: " & objItem.EnableReverseDns
    Wscript.Echo "Header Wait Timeout: " & objItem.HeaderWaitTimeout
    Wscript.Echo "Http Expires: " & objItem.HttpExpires
    Wscript.Echo "IIs5 Isolation Mode Enabled: " & _
        objItem.IIs5IsolationModeEnabled
    Wscript.Echo "Log Ext File Bytes Received: " & _
        objItem.LogExtFileBytesRecv
    Wscript.Echo "Log Ext File Bytes Sent: " & objItem.LogExtFileBytesSent
    Wscript.Echo "Log Ext File Client IP: " & objItem.LogExtFileClientIp
    Wscript.Echo "Log Ext File Computer Name: " & _
        objItem.LogExtFileComputerName
    Wscript.Echo "Log Ext File Cookie: " & objItem.LogExtFileCookie
    Wscript.Echo "Log Ext File Date: " & objItem.LogExtFileDate
    Wscript.Echo "Log Ext File Flags: " & objItem.LogExtFileFlags
    Wscript.Echo "Log Ext File Host: " & objItem.LogExtFileHost
    Wscript.Echo "Log Ext File Http Status: " & _
        objItem.LogExtFileHttpStatus
    Wscript.Echo "Log Ext File Http SubStatus: " & _
        objItem.LogExtFileHttpSubStatus
    Wscript.Echo "Log Ext File Method: " & objItem.LogExtFileMethod
    Wscript.Echo "Log Ext File Protocol Version: " & _
        objItem.LogExtFileProtocolVersion
    Wscript.Echo "Log Ext File Referer: " & objItem.LogExtFileReferer
    Wscript.Echo "Log Ext File Server Ip: " & objItem.LogExtFileServerIp
    Wscript.Echo "Log Ext File Server Port: " & _
        objItem.LogExtFileServerPort
    Wscript.Echo "Log Ext File Site Name: " & objItem.LogExtFileSiteName
    Wscript.Echo "Log Ext File Time: " & objItem.LogExtFileTime
    Wscript.Echo "Log Ext File Time Taken: " & objItem.LogExtFileTimeTaken
    Wscript.Echo "Log Ext File URI Query: " & objItem.LogExtFileUriQuery
    Wscript.Echo "Log Ext File URI Stem: " & objItem.LogExtFileUriStem
    Wscript.Echo "Log Ext File User Agent: " & objItem.LogExtFileUserAgent
    Wscript.Echo "Log Ext File User Name: " & objItem.LogExtFileUserName
    Wscript.Echo "Log Ext File Win32 Status: " & _
        objItem.LogExtFileWin32Status
    Wscript.Echo "Log File Directory: " & objItem.LogFileDirectory
    Wscript.Echo "Log File Local Time Rollover: " & _
        objItem.LogFileLocaltimeRollover
    Wscript.Echo "Log File Period: " & objItem.LogFilePeriod
    Wscript.Echo "Log File Truncate Size: " & objItem.LogFileTruncateSize
    Wscript.Echo "Log in UTF8: " & objItem.LogInUTF8
    Wscript.Echo "Log Module List: " & objItem.LogModuleList
    Wscript.Echo "Log Odbc Data Source: " & objItem.LogOdbcDataSource
    Wscript.Echo "Log Odbc Password: " & objItem.LogOdbcPassword
    Wscript.Echo "Log Odbc Table Name: " & objItem.LogOdbcTableName
    Wscript.Echo "Log Odbc User Name: " & objItem.LogOdbcUserName
    Wscript.Echo "Logon Method: " & objItem.LogonMethod
    Wscript.Echo "Log Plugin Clsid: " & objItem.LogPluginClsid
    Wscript.Echo "Log Type: " & objItem.LogType
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Endpoint Connections: " & _
        objItem.MaxEndpointConnections
    Wscript.Echo "Maximum Global Bandwidth: " & _
        objItem.MaxGlobalBandwidth
    Wscript.Echo "Maximum Request Entity Allowed: " & _
        objItem.MaxRequestEntityAllowed
    Wscript.Echo "Minimum File Bytes Per Second: " & _
        objItem.MinFileBytesPerSec
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "NT Authentication Providers: " & _
        objItem.NTAuthenticationProviders
    Wscript.Echo "Passport Require AD Mapping: " & _
        objItem.PassportRequireADMapping
    Wscript.Echo "Password Cache TTL: " & objItem.PasswordCacheTTL
    Wscript.Echo "Password Change Flags: " & _
        objItem.PasswordChangeFlags
    Wscript.Echo "Password Expire Prenotify Days: " & _
        objItem.PasswordExpirePrenotifyDays
    Wscript.Echo "Pool Idc Timeout: " & objItem.PoolIdcTimeout
    Wscript.Echo "Process NTCRIf Logged On: " & _
        objItem.ProcessNTCRIfLoggedOn
    Wscript.Echo "Rapid Fail Protection Interval: " & _
        objItem.RapidFailProtectionInterval
    Wscript.Echo "Rapid Fail Protection Maximum Crashes: " & _
        objItem.RapidFailProtectionMaxCrashes
    Wscript.Echo "Realm: " & objItem.Realm
    For Each strHeader in objItem.RedirectHeaders
        Wscript.Echo "Redirect Headers: " & strHeader
    Next
    Wscript.Echo "Revocation Freshness Time: " & _
        objItem.RevocationFreshnessTime
    Wscript.Echo "Revocation URL Retrieval Timeout: " & _
        objItem.RevocationURLRetrievalTimeout
    Wscript.Echo "Server AutoStart: " & objItem.ServerAutoStart
    Wscript.Echo "Server Comment: " & objItem.ServerComment
    Wscript.Echo "Server Listen Backlog: " & _
        objItem.ServerListenBacklog
    Wscript.Echo "Server Listen Timeout: " & _
        objItem.ServerListenTimeout
    Wscript.Echo "Server Size: " & objItem.ServerSize
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Shutdown Time Limit: " & objItem.ShutdownTimeLimit
    Wscript.Echo "SSI Exec Disable: " & objItem.SSIExecDisable
    Wscript.Echo "SSL Always Negotiate Client Certificate: " & _
        objItem.SSLAlwaysNegoClientCert
    Wscript.Echo "SSL Store Name: " & objItem.SSLStoreName
    Wscript.Echo "Ssl Use Ds Mapper: " & objItem.SslUseDsMapper
    Wscript.Echo "Upload Read Ahead Size: " & _
        objItem.UploadReadAheadSize
    Wscript.Echo "Use Digest SSP: " & objItem.UseDigestSSP
    Wscript.Echo "WAM User Name: " & objItem.WAMUserName
    Wscript.Echo "WAM User Pass: " & objItem.WAMUserPass
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Site Document Properties

Description
Displays global document property values for IIS Web sites.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")
For Each objItem in colItems
    Wscript.Echo "Default Doc: " & objItem.DefaultDoc
    Wscript.Echo "Default Doc Footer: " & objItem.DefaultDocFooter
    Wscript.Echo "Enable Default Doc: " & objItem.EnableDefaultDoc
    Wscript.Echo "Enable Doc Footer: " & objItem.EnableDocFooter
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Site Home Directory Properties

Description
Displays global metabase values for IIS Web site home directories.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Application Pool ID: " & objItem.AppPoolId
    Wscript.Echo "Content Indexed: " & objItem.ContentIndexed
    Wscript.Echo "Don't Log: " & objItem.DontLog
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Web Site Performance Properties

Description
Displays performance information for all Web sites on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Maximum Bandwidth: " & objItem.MaxBandwidth
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web File Setting Metabase Property

Description
Demonstration script that modifies a global Web file metabase property (EnableDocFooter) on a computer running IIS 6.0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebFileSetting")

For Each objItem in colItems
    objItem.EnableDocFooter = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Web Info Metabase Property

Description
Demonstration script that modifies a Web info metabase property (ServerConfigSSLAllowEncrypt) on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebInfoSetting")

For Each objItem in colItems
    objItem.ServerConfigSSLAllowEncrypt = TRUE
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Basic Web Site Properties

Description
Demonstration script that modifies default Web site metabase properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.AllowKeepAlive = True
    objItem.ConnectionTimeout = 1200
    objItem.DontLog = False
    objItem.ServerComment = "This is an intranet-only server."
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Web Site Document Properties

Description
Demonstration script that modifies default Web site document metabase properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    strDocs = objItem.DefaultDoc
    objItem.DefaultDoc = strDocs & ",index.htm"
    objItem.DefaultDocFooter = "FILE:c:\config\footer.htm"
    objItem.EnableDefaultDoc = True
    objItem.EnableDocFooter = True
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Web Site Home Directory Properties

Description
Demonstration script that modifies default Web site home directory metabase properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.ContentIndexed = True
    objItem.DontLog = True
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Web Site Performance Properties

Description
Demonstration script that modifies default Web site performance metabase properties on an IIS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsWebServiceSetting")

For Each objItem in colItems
    objItem.MaxBandwidth = -1
    objItem.MaxConnections = 10000
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Web Site Service Properties

Description
Demonstration script that modifies IIS compression schemes property values.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from IIsCompressionSchemesSetting")

For Each objItem in colItems
    objItem.HcCompressionDirectory = "C:\Compressed_Files"
    objItem.HcDoDynamicCompression = True
    objItem.HcDoStaticCompression = True
    objItem.DoDiskSpaceLimiting = True
    objItem.HcMaxDiskSpaceUsage = 200000000
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause a Web Server

Description
Pauses an IIS Web server named W3SVC/2142295254.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebServer Where Name = " & _
        "'W3SVC/2142295254'")

For Each objItem in colItems
    objItem.Pause
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start a Web Server

Description
Starts an IIS Web server named W3SVC/2142295254.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebServer Where Name = " & _
        "'W3SVC/2142295254'")

For Each objItem in colItems
    objItem.Start
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop a Web Server

Description
Stops an IIS Web server named W3SVC/2142295254.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}\\" _
        & strComputer & "\root\microsoftiisv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From IIsWebServer Where Name = " & _
        "'W3SVC/2142295254'")

For Each objItem in colItems
    objItem.Stop
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add WMI Data to an Event Log Entry

Description
Writes an event that includes additional information such as user name and the amount of free disk space on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const EVENT_FAILED = 2

Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objNetwork = Wscript.CreateObject("Wscript.Network")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery _
    ("Select * from win32_perfformatteddata_perfdisk_logicaldisk")

For Each objDisk in colDiskDrives
    strDriveSpace = objDisk.Name & " " & objDisk.FreeMegabytes _
        & VbCrLf
Next

strEventDescription = "Payroll application could not be installed on " _
    & objNetwork.UserDomain & "\" & objNetwork.ComputerName _
        & " by user " & objNetwork.UserName & _
            ". Free space on each drive is: " & strDriveSpace
objShell.LogEvent EVENT_FAILED, strEventDescription

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Back Up and Clear an Event Log

Description
Backs up and clears the Application event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='Application'")

For Each objLogfile in colLogFiles
    errBackupLog = objLogFile.BackupEventLog("c:\scripts\application.evt")
    If errBackupLog <> 0 Then
        Wscript.Echo "The Application event log could not be backed up."
    Else
        objLogFile.ClearEventLog()
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Back Up and Clear Large Event Logs

Description
Backs up and clears an event log if the log file size is larger than 20 megabytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
        & strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")

For Each objLogfile in colLogFiles
    If objLogFile.FileSize > 100000 Then
       strBackupLog = objLogFile.BackupEventLog _
           ("c:\scripts\" & objLogFile.LogFileName & ".evt")
       objLogFile.ClearEventLog()
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy Event Log Events to a Database

Description
Retrieves events from all the event logs and records these in a database with the DSN Name of EventLogs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRetrievedEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent")

For Each objEvent in colRetrievedEvents
    objRS.AddNew
    objRS("Category") = objEvent.Category
    objRS("ComputerName") = objEvent.ComputerName
    objRS("EventCode") = objEvent.EventCode
    objRS("Message") = objEvent.Message
    objRS("RecordNumber") = objEvent.RecordNumber
    objRS("SourceName") = objEvent.SourceName
    objRS("TimeWritten") = objEvent.TimeWritten
    objRS("Type") = objEvent.Type
    objRS("User") = objEvent.User
    objRS.Update
Next

objRS.Close
objConn.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy the Previous Day’s Event Log Events to a Database

Description
Retrieves events from all the event logs that were recorded on the previous day, and writes these records to a database with the DSN Name EventLogs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objConn = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")

objConn.Open "DSN=EventLogs;"
objRS.CursorLocation = 3
objRS.Open "SELECT * FROM EventTable" , objConn, 3, 3

Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")

DateToCheck = Date - 1
dtmEndDate.SetVarDate Date, True
dtmStartDate.SetVarDate DateToCheck, True

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
        & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")

For each objEvent in colEvents
    objRS.AddNew
    objRS("Category") = objEvent.Category
    objRS("ComputerName") = objEvent.ComputerName
    objRS("EventCode") = objEvent.EventCode
    objRS("Message") = objEvent.Message
    objRS("RecordNumber") = objEvent.RecordNumber
    objRS("SourceName") = objEvent.SourceName
    objRS("TimeWritten") = objEvent.TimeWritten
    objRS("Type") = objEvent.Type
    objRS("User") = objEvent.User
    objRS.Update
Next

objRS.Close
objConn.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Custom Event Log

Description
Creates a custom event log named Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Const NO_VALUE = Empty

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\EventLog\Scripts\", NO_VALUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create Unique File Names for Event Log Backups

Description
Backs up and clears the Application event log, generating a unique file name for each backup based on the current date.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

dtmThisDay = Day(Date)
dtmThisMonth = Month(Date)
dtmThisYear = Year(Date)
strBackupName = dtmThisYear & "_" & dtmThisMonth & "_" & dtmThisDay

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Backup)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='Application'")

For Each objLogfile in colLogFiles
    objLogFile.BackupEventLog("c:\scripts\" & strBackupName & _
        "_application.evt")
    objLogFile.ClearEventLog()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Events from an Event Log

Description
Retrieves all the events from the Application event log on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where Logfile = 'Application'")

For Each objEvent in colLoggedEvents
    Wscript.Echo "Category: " & objEvent.Category
    Wscript.Echo "Computer Name: " & objEvent.ComputerName
    Wscript.Echo "Event Code: " & objEvent.EventCode
    Wscript.Echo "Message: " & objEvent.Message
    Wscript.Echo "Record Number: " & objEvent.RecordNumber
    Wscript.Echo "Source Name: " & objEvent.SourceName
    Wscript.Echo "Time Written: " & objEvent.TimeWritten
    Wscript.Echo "Event Type: " & objEvent.Type
    Wscript.Echo "User: " & objEvent.User
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Stop Events

Description
Queries the System event log for any events written due to a stop event (blue screen).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where Logfile = 'System'" _
        & " and SourceName = 'SaveDump'")

For Each objEvent in colLoggedEvents
    Wscript.Echo "Event date: " & objEvent.TimeGenerated
    Wscript.Echo "Description: " & objEvent.Message
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Event Log Properties

Description
Retrieves a list of properties for all the event logs on a computer, except the Security event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objInstalledLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")

For each objLogfile in objInstalledLogFiles
    Wscript.Echo "Name: " &  objLogfile.LogFileName
    Wscript.Echo "Maximum Size: " &  objLogfile.MaxFileSize
    If objLogfile.OverWriteOutdated > 365 Then
        Wscript.Echo "Overwrite Outdated Records: Never."
    ElseIf objLogfile.OverWriteOutdated = 0 Then
        Wscript.Echo "Overwrite Outdated Records: As needed."
    Else
        Wscript.Echo "Overwrite Outdated Records After: " &  _
            objLogfile.OverWriteOutdated & " days" &
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Events For a Specific Day From An Event Log

Description
Retrieves all the events recorded on a specific date from all the event logs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const CONVERT_TO_LOCAL_TIME = True

Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmEndDate = CreateObject("WbemScripting.SWbemDateTime")
DateToCheck = CDate("2/18/2002")
dtmStartDate.SetVarDate DateToCheck, CONVERT_TO_LOCAL_TIME
dtmEndDate.SetVarDate DateToCheck + 1, CONVERT_TO_LOCAL_TIME

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where TimeWritten >= '" _
        & dtmStartDate & "' and TimeWritten < '" & dtmEndDate & "'")

For Each objEvent in colEvents
    Wscript.Echo "Category: " & objEvent.Category
    Wscript.Echo "Computer Name: " & objEvent.ComputerName
    Wscript.Echo "Event Code: " & objEvent.EventCode
    Wscript.Echo "Message: " & objEvent.Message
    Wscript.Echo "Record Number: " & objEvent.RecordNumber
    Wscript.Echo "Source Name: " & objEvent.SourceName
    Wscript.Echo "Time Written: " & objEvent.TimeWritten
    Wscript.Echo "Event Type: " & objEvent.Type
    Wscript.Echo "User: " & objEvent.User
    Wscript.Echo objEvent.LogFile
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Events From a Specific Event Log

Description
Retrieves all the events from the Application event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where Logfile = 'Application'")

For Each objEvent in colLoggedEvents
    Wscript.Echo "Category: " & objEvent.Category
    Wscript.Echo "Computer Name: " & objEvent.ComputerName
    Wscript.Echo "Event Code: " & objEvent.EventCode
    Wscript.Echo "Message: " & objEvent.Message
    Wscript.Echo "Record Number: " & objEvent.RecordNumber
    Wscript.Echo "Source Name: " & objEvent.SourceName
    Wscript.Echo "Time Written: " & objEvent.TimeWritten
    Wscript.Echo "Event Type: " & objEvent.Type
    Wscript.Echo "User: " & objEvent.User
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Events Using an Asynchronous Query

Description
Uses an asynchronous query to retrieve all the events recorded in the event logs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Const POPUP_DURATION = 10
Const OK_BUTTON = 0

Set objWSHShell = Wscript.CreateObject("Wscript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objSink = WScript.CreateObject("WbemScripting.SWbemSink","SINK_")
objWMIService.InstancesOfAsync objSink, "Win32_NTLogEvent"
Error = objWshShell.Popup("Starting event retrieval", POPUP_DURATION, _
    "Event Retrieval", OK_BUTTON)

Sub SINK_OnCompleted(iHResult, objErrorObject, objAsyncContext)
    WScript.Echo "Asynchronous operation is done."
End Sub

Sub SINK_OnObjectReady(objEvent, objAsyncContext)
    Wscript.Echo "Category: " & objEvent.Category
    Wscript.Echo "Computer Name: " & objEvent.ComputerName
    Wscript.Echo "Event Code: " & objEvent.EventCode
    Wscript.Echo "Message: " & objEvent.Message
    Wscript.Echo "Record Number: " & objEvent.RecordNumber
    Wscript.Echo "Source Name: " & objEvent.SourceName
    Wscript.Echo "Time Written: " & objEvent.TimeWritten
    Wscript.Echo "Event Type: " & objEvent.Type
    Wscript.Echo "User: " & objEvent.User
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Security Log Properties

Description
Retrieves properties for the Security event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Security)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='Security'")

For Each objLogFile in colLogFiles
    Wscript.Echo objLogFile.NumberOfRecords
    Wscript.Echo "Maximum Size: " &  objLogfile.MaxFileSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Specific Events from an Event Log

Description
Retrieves all events with an event code of 6008 from the System event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLoggedEvents = objWMIService.ExecQuery _
        ("Select * from Win32_NTLogEvent Where Logfile = 'System' and " _
            & "EventCode = '6008'")

Wscript.Echo "Improper shutdowns: " & colLoggedEvents.Count

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List System Event Log Properties

Description
Reports the number of events currently recorded in the System event log.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile where LogFileName='System'")

For Each objLogFile in colLogFiles
    Wscript.Echo objLogFile.NumberOfRecords
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Event Log Properties

Description
Sets the maximum size of all event logs to 250 megabytes, and enables the log to overwrite any events older than 14 days.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Security)}!\\" & _
        strComputer & "\root\cimv2")

Set colLogFiles = objWMIService.ExecQuery _
    ("Select * from Win32_NTEventLogFile")

For each objLogfile in colLogFiles
    strLogFileName = objLogfile.Name
    Set wmiSWbemObject = GetObject _
        ("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
            & "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
    wmiSWbemObject.MaxFileSize = 2500000000
    wmiSWbemObject.OverwriteOutdated = 14
    wmiSWbemObject.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Event Logs in Real Time

Description
Creates a temporary event consumer that monitors event logs for events with an event ID of 533.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate, (Security)}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("Select * from __instancecreationevent where " _
        & "TargetInstance isa 'Win32_NTLogEvent' " _
            & "and TargetInstance.EventCode = '533' ")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
     strAlertToSend = objLatestEvent.TargetInstance.User _
         & " attempted to access DatabaseServer."
     Wscript.Echo strAlertToSend
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Write Events to a Remote Event Log

Description
Writes an event to the Application event log on a remote computer named PrimaryServer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.LogEvent EVENT_SUCCESS, _
    "Payroll application successfully installed." , "\\PrimaryServer"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Write Events to the Local Event Log

Description
Writes an event to the Application event log on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const EVENT_SUCCESS = 0

Set objShell = Wscript.CreateObject("Wscript.Shell")

objShell.LogEvent EVENT_SUCCESS, _
    "Payroll application successfully installed."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Write to a Custom Event Log Using EventCreate

Description
Uses the EventCreate.exe utility to write an event to a custom event log named Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set WshShell = WScript.CreateObject("WScript.Shell")

strCommand = "eventcreate /T Error /ID 100 /L Scripts /D " & _
    Chr(34) & "Test event." & Chr(34)
WshShell.Run strcommand

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Comma Separated Values Log

Description
Extracts the information in the DHCP Server log to individual fields and records.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Windows\System32\DHCP\" _
    & "DhcpSrvLog-Mon.log", ForReading)

Do While objTextFile.AtEndOfStream <> True
    If inStr(objtextFile.Readline, ",") Then
        arrDHCPRecord = split(objTextFile.Readline, ",")
        Wscript.Echo "Event ID: " & arrDHCPRecord(0)
        Wscript.Echo "Date: " & arrDHCPRecord(1)
        Wscript.Echo "Time: " & arrDHCPRecord(2)
        Wscript.Echo "Description: " & arrDHCPRecord(3)
        Wscript.Echo "IP Address: " & arrDHCPRecord(4)
        Wscript.Echo "Host Name: " & arrDHCPRecord(5)
        Wscript.Echo "MAC Address: " & arrDHCPRecord(6)
    Else
        objTextFile.Skipline
    End If
    i = i + 1
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Fixed Width Column Log

Description
Extracts the information in the NetSetup log to individual fields and records.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Windows\Debug\Netsetup.log", _
    ForReading)

Do While objTextFile.AtEndOfStream <> True
    strLinetoParse = objTextFile.ReadLine
    dtmEventDate = Mid(strLinetoParse, 1, 6)
    dtmEventTime = Mid(strLinetoParse, 7, 9)
    strEventDescription = Mid(strLinetoParse, 16)
    Wscript.Echo "Date: " & dtmEventDate
    Wscript.Echo "Time: " & dtmEventTime
    Wscript.Echo "Description: " & strEventDescription & VbCrLf
Loop
objFSO.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Schedule Interval Information

Description
Returns Microsoft Exchange 2003 schedule interval information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_ScheduleInterval")

For Each objItem in colItems
    Wscript.Echo "Start time: " & objItem.StartTime
    Wscript.Echo "Stop time: " & objItem.StopTime
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Cluster Resource Information

Description
Lists cluster resource information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" &  _
        strComputer & "\CIMV2\Applications\Exchange")

Set colItems = objWMIService.ExecQuery _
     ("Select * from ExchangeClusterResource")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Owner: " & objItem.Owner
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo "Virtual machine: " & objItem.VirtualMachine
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Connector State Information

Description
Lists connector state information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" &  _
        strComputer & "\CIMV2\Applications\Exchange")

Set colItems = objWMIService.ExecQuery _
    ("Select * from ExchangeConnectorState")

For Each objItem in colItems
    Wscript.Echo "Distinguished name: " & objItem.DN
    Wscript.Echo "Group distinguished name: " & objItem.GroupDN
    Wscript.Echo "Group GUID: " & objItem.GroupGUID
    Wscript.Echo "GUID: " & objItem.GUID
    Wscript.Echo "Is up: " & objItem.IsUp
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Domain Controller Information

Description
Lists domain controller information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_DSAccessDC")

For Each objItem in colItems
    Wscript.Echo "Configuration: " & objItem.Configuration
    Wscript.Echo "Directory type: " & objItem.DirectoryType
    Wscript.Echo "Is fast: " & objItem.IsFast
    Wscript.Echo "Is in sync: " & objItem.IsInSync
    Wscript.Echo "Is up: " & objItem.IsUp
    Wscript.Echo "LDAP port: " & objItem.LDAPPort
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Folder Tree Information

Description
Returns information about the folder tree found on a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_FolderTree")

For Each objItem in colItems
    Wscript.Echo "Administrative group: " & _
        objItem.AdministrativeGroup
    Wscript.Echo "Administrative noe: " & _
        objItem.AdministrativeNote
    Wscript.Echo "Associated public stores: " & _
        objItem.AssociatedPublicStores
    Wscript.Echo "Creation time: " & objItem.CreationTime
    Wscript.Echo "GUID: " & objItem.GUID
    Wscript.Echo "Has local public store: " & _
        objItem.HasLocalPublicStore
    Wscript.Echo "Last modification time: " & _
        objItem.LastModificationTime
    Wscript.Echo "MAPI folder tree: " & objItem.MAPIFolderTree
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Root folder URL: " & objItem.RootFolderURL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Link Information

Description
Returns information about Exchange links on a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_Link")

For Each objItem in colItems
    Wscript.Echo "Action freeze: " & objItem.ActionFreeze
    Wscript.Echo "Action kick: " & objItem.ActionKick
    Wscript.Echo "Action thaw: " & objItem.ActionThaw
    Wscript.Echo "Extended state info: " & _
        objItem.ExtendedStateInfo
    Wscript.Echo "Global stop: " & objItem.GlobalStop
    Wscript.Echo "Link distinguished name: " & objItem.LinkDN
    Wscript.Echo "Link ID: " & objItem.LinkID
    Wscript.Echo "Link name: " & objItem.LinkName
    Wscript.Echo "Message count: " & objItem.MessageCount
    Wscript.Echo "Next scheduled connection: " & _
        objItem.NextScheduledConnection
    Wscript.Echo "Oldest message: " & objItem.OldestMessage
    Wscript.Echo "Protocol name: " & objItem.ProtocolName
    Wscript.Echo "Size: " & objItem.Size
    Wscript.Echo "State action: " & objItem.StateActive
    Wscript.Echo "State flags: " & objItem.StateFlags
    Wscript.Echo "State frozen: " & objItem.StateFrozen
    Wscript.Echo "State ready: " & objItem.StateReady
    Wscript.Echo "State remote: " & objItem.StateRemote
    Wscript.Echo "State retry: " & objItem.StateRetry
    Wscript.Echo "State scheduled: " & objItem.StateScheduled
    Wscript.Echo "Support link actions: " & _
        objItem.SupportLinkActions
    Wscript.Echo "Type currently unreachable: " & _
        objItem.TypeCurrentlyUnreachable
    Wscript.Echo "Type deferred deilvery: " & _
        objItem.TypeDeferredDelivery
    Wscript.Echo "Type internal: " & objItem.TypeInternal
    Wscript.Echo "Type local delivery: " & _
        objItem.TypeLocalDelivery
    Wscript.Echo "Type pending categorization: " & _
        objItem.TypePendingCategorization
    Wscript.Echo "Type pending routing: " & _
        objItem.TypePendingRouting
    Wscript.Echo "Type pending submission: " & _
        objItem.TypePendingSubmission
    Wscript.Echo "Type remote delivery: " & _
        objItem.TypeRemoteDelivery
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Virtual machine: " & objItem.VirtualMachine
    Wscript.Echo "Virtual server name: " & _
        objItem.VirtualServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Logon Information

Description
Lists logon information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery("Select * from Exchange_Logon")

For Each objItem in colItems
    Wscript.Echo "Client version: " & objItem.ClientVersion
    Wscript.Echo "Code page ID: " & objItem.CodePageID
    Wscript.Echo "Folder operations rate: " & _
        objItem.FolderOperationsRate
    Wscript.Echo "Host addess: " & objItem.HostAddress
    Wscript.Echo "Last operation time: " & _
        objItem.LastOperationTime
    Wscript.Echo "Locale ID: " & objItem.LocaleID
    Wscript.Echo "Logged-on user account: " & _
        objItem.LoggedOnUserAccount
    Wscript.Echo "Logged-on user's malibx legacy distinguished name: " _
        & objItem.LoggedOnUsersMailboxLegacyDN
    Wscript.Echo "Logon time: " & objItem.LogonTime
    Wscript.Echo "Mailbox display name: " & _
        objItem.MailboxDisplayName
    Wscript.Echo "Mailbox legacy distinguished name: " & _
        objItem.MailboxLegacyDN
    Wscript.Echo "Messaging operation count: " & _
        objItem.MessagingOperationRate
    Wscript.Echo "Open attachment count: " & _
        objItem.OpenAttachmentCount
    Wscript.Echo "Open folder count: " & objItem.OpenFolderCount
    Wscript.Echo "Open message count: " & objItem.OpenMessageCount
    Wscript.Echo "Other operation rate: " & _
        objItem.OtherOperationRate
    Wscript.Echo "Progress operation rate: " & _
        objItem.ProgressOperationRate
    Wscript.Echo "Row ID: " & objItem.RowID
    Wscript.Echo "Server name: " & objItem.ServerName
    Wscript.Echo "Storage group name: " & objItem.StorageGroupName
    Wscript.Echo "Store name: " & objItem.StoreName
    Wscript.Echo "Store type: " & objItem.StoreType
    Wscript.Echo "Stream operation rate: " & _
        objItem.StreamOperationRate
    Wscript.Echo "Table operation rate: " & _
        objItem.TableOperationRate
    Wscript.Echo "Total operation rate: " & _
        objItem.TotalOperationRate
    Wscript.Echo "Transfer operation rate: " & _
        objItem.TransferOperationRate
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Mailbox Information

Description
Returns mailbox information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_Mailbox")

For Each objItem in colItems
    Wscript.Echo "Associated content count: " & _
        objItem.AssocContentCount
    Wscript.Echo "Date discovered absent in directory service: " & _
        objItem.DateDiscoveredAbsentInDS
    Wscript.Echo "Delete messages size extended: " & _
        objItem.DeletedMessageSizeExtended
    Wscript.Echo "Last logged-on user account: " & _
        objItem.LastLoggedOnUserAccount
    Wscript.Echo "Last logoff time: " & objItem.LastLogoffTime
    Wscript.Echo "Last logon time: " & objItem.LastLogonTime
    Wscript.Echo "Legacy distinguished name: " & objItem.LegacyDN
    Wscript.Echo "Mailbox display name: " & _
        objItem.MailboxDisplayName
    Wscript.Echo "Mailbox GUID: " & objItem.MailboxGUID
    Wscript.Echo "Server name: " & objItem.ServerName
    Wscript.Echo "Size: " & objItem.Size
    Wscript.Echo "Storage group name: " & _
        objItem.StorageGroupName
    Wscript.Echo "Storage limit information: " & _
        objItem.StorageLimitInfo
    Wscript.Echo "Store name: " & objItem.StoreName
    Wscript.Echo "Total items: " & objItem.TotalItems
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Message Tracking Entry Information

Description
Returns message tracking entry information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_MessageTrackingEntry")

For Each objItem in colItems
    Wscript.Echo "Attempted partner server: " &  _
        objItem.AttemtpedPartnerServer
    Wscript.Echo "Client IP: " & objItem.ClientIP
    Wscript.Echo "Client name: " & objItem.ClientName
    Wscript.Echo "Cost: " & objItem.Cost
    Wscript.Echo "Delivery time: " & objItem.DeliveryTime
    Wscript.Echo "Encrypted: " & objItem.Encrypted
    Wscript.Echo "Entry type: " & objItem.EntryType
    Wscript.Echo "Expansion DL: " & objItem.ExpansionDL
    Wscript.Echo "Key ID: " & objItem.KeyID
    Wscript.Echo "Linked message ID: " &  _
        objItem.LinkedMessageID
    Wscript.Echo "Message ID: " & objItem.MessageID
    Wscript.Echo "Origination time: " & objItem.OriginationTime
    Wscript.Echo "Partner server: " & objItem.PartnerServer
    Wscript.Echo "Priority: " & objItem.Priority
    Wscript.Echo "Recipient address: " &  _
        objItem.RecipientAddress
    Wscript.Echo "Recipient count: " & objItem.RecipientCount
    Wscript.Echo "Recipient status: " & objItem.RecipientStatus
    Wscript.Echo "Sender address: " & objItem.SenderAddress
    Wscript.Echo "Server IP: " & objItem.ServerIP
    Wscript.Echo "Server name: " & objItem.ServerName
    Wscript.Echo "Size: " & objItem.Size
    Wscript.Echo "Subject: " & objItem.Subject
    Wscript.Echo "Subject ID: " & objItem.SubjectID
    Wscript.Echo "Time logged: " & objItem.TimeLogged
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Public Folder Information

Description
Returns public folder information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_PublicFolder")

For Each objItem in colItems
    Wscript.Echo "Address book name: " & objItem.AddressBookName
    Wscript.Echo "Administrative note: " & _
        objItem.AdministrativeNote
    Wscript.Echo "Administrative security descriptor: " & _
        objItem.AdminSecurityDescriptor
    Wscript.Echo "Active Directory proxy path: " & _
        objItem.ADProxyPath
    Wscript.Echo "Associated messgae count: " & _
        objItem.AssociatedMessageCount
    Wscript.Echo "Attachment count: " & objItem.AttachmentCount
    Wscript.Echo "Categorization count: " & _
        objItem.CategorizationCount
    Wscript.Echo "Comment: " & objItem.Comment
    Wscript.Echo "Contact count: " & objItem.ContactCount
    Wscript.Echo "Contains rules: " & objItem.ContainsRules
    Wscript.Echo "Creation time: " & objItem.CreationTime
    Wscript.Echo "Deleted item lifetime: " & _
        objItem.DeletedItemLifetime
    Wscript.Echo "Folder tree: " & objItem.FolderTree
    Wscript.Echo "Friendly URL: " & objItem.FriendlyURL
    Wscript.Echo "Has children: " & objItem.HasChildren
    Wscript.Echo "Has local replica: " & objItem.HasLocalReplica
    Wscript.Echo "Is mail enabled: " & objItem.IsMailEnabled
    Wscript.Echo "Is normal folder: " & objItem.IsNormalFolder
    Wscript.Echo "Is search folder: " & objItem.IsSearchFolder
    Wscript.Echo "Is secure in site: " & objItem.IsSecureInSite
    Wscript.Echo "Last access time: " & objItem.LastAccessTime
    Wscript.Echo "Last modification time: " & _
        objItem.LastModificationTime
    Wscript.Echo "Maximum item size: " & objItem.MaximumItemSize
    Wscript.Echo "Message count: " & objItem.MessageCount
    Wscript.Echo "Message with attachments count: " & _
        objItem.MessageWithAttachmentsCount
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Normal message size: " & _
        objItem.NormalMessageSize
    Wscript.Echo "owner count: " & objItem.OwnerCount
    Wscript.Echo "Parent friendly URL: " & _
        objItem.ParentFriendlyURL
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo "Prohibit post limit: " & _
        objItem.ProhibitPostLimit
    Wscript.Echo "Publish in address book: " & _
        objItem.PublishInAddressBook
    Wscript.Echo "Recipiejt count on associated messages: " & _
        objItem.RecipientCountOnAssociatedMessages
    Wscript.Echo "Recipient count on normal messages: " & _
        objItem.RecipientCountOnNormalMessages
    Wscript.Echo "Replica age limit: " & objItem.ReplicaAgeLimit
    Wscript.Echo "Replica list: " & objItem.ReplicaList
    Wscript.Echo "Replication message priority: " & _
        objItem.ReplicationMessagePriority
    Wscript.Echo "Replication schedule: " & _
        objItem.ReplicationSchedule
    Wscript.Echo "Replication style: " & objItem.ReplicationStyle
    Wscript.Echo "Replication count: " & objItem.RestrictionCount
    Wscript.Echo "Security descriptor: " & _
        objItem.SecurityDescriptor
    Wscript.Echo "Storage limit style: " & objItem.StorageLimitStyle
    Wscript.Echo "Target address: " & objItem.TargetAddress
    Wscript.Echo "Total message size: " & objItem.TotalMessageSize
    Wscript.Echo "URL: " & objItem.URL
    Wscript.Echo "Use public store age limits: " & _
        objItem.UsePublicStoreAgeLimits
    Wscript.Echo "Use public store deleted item lifetime: " & _
        objItem.UsePublicStoreDeletedItemLifetime
    Wscript.Echo "Warning limit: " & objItem.WarningLimit
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Queue Information

Description
Returns queue information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery("Select * from ExchangeQueue")

For Each objItem in colItems
    Wscript.Echo "Can enumerate all: " & objItem.CanEnumAll
    Wscript.Echo "Can enumerate failures: " & objItem.CanEnumFailed
    Wscript.Echo "Van enumerate first N messages: " & _
        objItem.CanEnumFirstNMessages
    Wscript.Echo "Can enumerate frozen messages: " & _
        objItem.CanEnumFrozen
    Wscript.Echo "Can enumerate messages not meeting the criteria: " & _
        objItem.CanEnumInvertSense
    Wscript.Echo "Can enumerate messages larger than X: " & _
        objItem.CanEnumLargerThan
    Wscript.Echo "Can enumerate largest N messages: " & _
        objItem.CanEnumNLargestMessages
    Wscript.Echo "Can enumerate oldest N messages: " & _
        objItem.CanEnumNOldestMessages
    Wscript.Echo "Can enumerate messages older than X: " & _
        objItem.CanEnumOlderThan
    Wscript.Echo "Can enumerate recipients: " & _
        objItem.CanEnumRecipient
    Wscript.Echo "Can enumerate senders: " & objItem.CanEnumSender
    Wscript.Echo "Global stop: " & objItem.GlobalStop
    Wscript.Echo "Increasing time: " & objItem.IncreasingTime
    Wscript.Echo "Link name: " & objItem.LinkName
    Wscript.Echo "Message enumeration flags supported: " & _
        objItem.MsgEnumFlagsSupported
    Wscript.Echo "Number of messages: " & objItem.NumberOfMessages
    Wscript.Echo "Protocol name: " & objItem.ProtocolName
    Wscript.Echo "Queue name: " & objItem.QueueName
    Wscript.Echo "Size of queue: " & objItem.SizeOfQueue
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Virtual machine: " & objItem.VirtualMachine
    Wscript.Echo "Virtual server name: " & objItem.VirtualServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Queued Message Information

Description
Returns information about queued messages on a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_QueuedMessage")

For Each objItem in colItems
    Wscript.Echo "Action deleted NDR: " & objItem.ActionDeletedNDR
    Wscript.Echo "Action deleted no NDR: " & _
        objItem.ActionDeletedNoNDR
    Wscript.Echo "Action freeze: " & objItem.ActionFreeze
    Wscript.Echo "Action thaw: " & objItem.ActionThaw
    Wscript.Echo "Expiry: " & objItem.Expiry
    Wscript.Echo "High priority: " & objItem.HighPriority
    Wscript.Echo "Link ID: " & objItem.LinkID
    Wscript.Echo "Link name: " & objItem.LinkName
    Wscript.Echo "Low priority: " & objItem.LowPriority
    Wscript.Echo "Message ID: " & objItem.MessageID
    Wscript.Echo "Normal priority: " & objItem.NormalPriority
    Wscript.Echo "Protocol ID: " & objItem.ProtocolName
    Wscript.Echo "Queue ID: " & objItem.QueueID
    Wscript.Echo "Queue name: " & objItem.QueueName
    Wscript.Echo "Received: " & objItem.Received
    Wscript.Echo "Recipient count: " & objItem.RecipientCount
    Wscript.Echo "Recipients: " & objItem.Recipients
    Wscript.Echo "Sender: " & objItem.Sender
    Wscript.Echo "Size: " & objItem.Size
    Wscript.Echo "State flags: " & objItem.StateFlags
    Wscript.Echo "State frozen: " & objItem.StateFrozen
    Wscript.Echo "State retry: " & objItem.StateRetry
    Wscript.Echo "Subject: " & objItem.Subject
    Wscript.Echo "Submission: " & objItem.Submission
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Virtual machine: " & objItem.VirtualMachine
    Wscript.Echo "Virtual server name: " & _
        objItem.VirtualServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Server Information

Description
Returns basic configuration information for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery("Select * from Exchange_Server")

For Each objItem in colItems
    Wscript.Echo "Administrative group: " & _
        objItem.AdministrativeGroup
    Wscript.Echo "Administrative note: " & objItem.AdministrativeNote
    Wscript.Echo "Creation time: " & objItem.CreationTime
    Wscript.Echo "Distinguished name: " & objItem.DN
    Wscript.Echo "Exchange version: " & objItem.ExchangeVersion
    Wscript.Echo "Fully-qualified domain name: " & objItem.FQDN
    Wscript.Echo "GUID: " & objItem.GUID
    Wscript.Echo "Is front-end server: " & objItem.IsFrontEndServer
    Wscript.Echo "Last modification time: " & _
        objItem.LastModificationTime
    Wscript.Echo "Message tracking enabled: " & _
        objItem.MessageTrackingEnabled
    Wscript.Echo "Message tracking log file lifetime: " & _
        objItem.MessageTrackingLogFileLifetime
    Wscript.Echo "Message tracking log file path: " & _
        objItem.MessageTrackingLogFilePath
    Wscript.Echo "Monitoring enabled: " & objItem.MonitoringEnabled
    Wscript.Echo "MTA data path: " & objItem.MTADataPath
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Routing group: " & objItem.RoutingGroup
    Wscript.Echo "Subject logging enabled: " & _
        objItem.SubjectLoggingEnabled
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Server State Information

Description
Returns information about the current state of a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" &  _
        strComputer & "\CIMV2\Applications\Exchange")

Set colItems = objWMIService.ExecQuery _
    ("Select * from ExchangeServerState")

For Each objItem in colItems
    Wscript.Echo "Cluster state: " & objItem.ClusterState
    Wscript.Echo "Cluster state string: " & _
        objItem.ClusterStateString
    Wscript.Echo "CPU state: " & objItem.CPUState
    Wscript.Echo "CPU state string: " & objItem.CPUStateString
    Wscript.Echo "Disks state: " & objItem.DisksState
    Wscript.Echo "Diskss state string: " & objItem.DisksStateString
    Wscript.Echo "Distinguished name: " & objItem.DN
    Wscript.Echo "Group dsitinguihsed name: " & objItem.GroupDN
    Wscript.Echo "Group GUID: " & objItem.GroupGUID
    Wscript.Echo "GUID: " & objItem.GUID
    Wscript.Echo "Memory state: " & objItem.MemoryState
    Wscript.Echo "Memory state string: " & _
        objItem.MemoryStateString
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Queues state: " & objItem.QueuesState
    Wscript.Echo "Queues state string: " & _
        objItem.QueuesStateString
    Wscript.Echo "Server maintenance: " & _
        objItem.ServerMaintenance
    Wscript.Echo "Server state: " & objItem.ServerState
    Wscript.Echo "Server state string: " & _
        objItem.ServerStateString
    Wscript.Echo "Services state: " & objItem.ServicesState
    Wscript.Echo "Services state string: " & _
        objItem.ServicesStateString
    Wscript.Echo "Unreachable: " & objItem.Unreachable
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange Virtual Server Queue Information

Description
Lists information about the virtual server queues on a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_QueueVirtualServer")

For Each objItem in colItems
    Wscript.Echo "Global actions supported: " & _
        objItem.GlobalActionsSupported
    Wscript.Echo "Global stop: " & objItem.GlobalStop
    Wscript.Echo "Protocol name: " & objItem.ProtocolName
    Wscript.Echo "Virtual machine: " & objItem.VirtualMachine
    Wscript.Echo "Virtual server name: " & _
        objItem.VirtualServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Exchange XML Queue Data

Description
Returns information about the XML queue on a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_QueueData")

For Each objItem in colItems
    Wscript.Echo "Server name: " & objItem.ServerName
    Wscript.Echo "XML queue data: " & objItem.XMLQueueData
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Queued Cache Reload Time

Description
Reports the queued cash reload time for a computer running Microsoft Exchange Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\ROOT\MicrosoftExchangeV2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Exchange_QueueCacheReloadEvent")

For Each objItem in colItems
    Wscript.Echo "Reload time: " & objItem.ReloadTime
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Send Email from a Script

Description
Demonstration script that uses CDO to send email from a computer where the SMTP Service has been installed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "monitor1@fabrikam.com"
objEmail.To = "admin1@fabrikam.com"
objEmail.Subject = "Atl-dc-01 down"
objEmail.Textbody = "Atl-dc-01 is no longer accessible over the network."
objEmail.Send

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Send Email without Installing the SMTP Service

Description
Demonstration script that uses CDO to send email from a computer where the SMTP Service has not been installed. Replace the name smarthost with the name of your SMTP server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "admin1@fabrikam.com"
objEmail.To = "admin2@fabrikam.com"
objEmail.Subject = "Server down"
objEmail.Textbody = "Server1 is no longer accessible over the network."
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
        "smarthost"
objEmail.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Data to a Spreadsheet Cell

Description
Demonstration script that adds the words "Test Value" to cell 1,1 in a new spreadsheet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "Test value"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Formatted Data to a Spreadsheet

Description
Demonstration script that adds the words "test value" to a new spreadsheet, then formats the cell containing the value.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "Test value"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Font.Size = 24
objExcel.Cells(1, 1).Font.ColorIndex = 3

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create User Accounts Based on Information in a Spreadsheet

Description
Demonstration script that creates new Active Directory user accounts based on information stored in an Excel spreadsheet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\Scripts\New_users.xls")

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
    Set objOU = GetObject("ou=Finance, dc=fabrikam, dc=com")
    Set objUser = objOU.Create _
        ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
    objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
    objUser.GivenName = objExcel.Cells(intRow, 3).Value
    objUser.SN = objExcel.Cells(intRow, 4).Value
    objUser.AccountDisabled = FALSE
    objUser.SetInfo
    intRow = intRow + 1
Loop

objExcel.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Format a Range of Cells

Description
Demonstration script that adds data to four different cells in a spreadsheet, then uses the Range object to format multiple cells at the same time.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add

objExcel.Cells(1, 1).Value = "Name"
objExcel.Cells(1, 1).Font.Bold = TRUE
objExcel.Cells(1, 1).Interior.ColorIndex = 30
objExcel.Cells(1, 1).Font.ColorIndex = 2
objExcel.Cells(2, 1).Value = "Test value 1"
objExcel.Cells(3, 1).Value = "Test value 2"
objExcel.Cells(4, 1).Value = "Tets value 3"
objExcel.Cells(5, 1).Value = "Test value 4"

Set objRange = objExcel.Range("A1","A5")
objRange.Font.Size = 14

Set objRange = objExcel.Range("A2","A5")
objRange.Interior.ColorIndex = 36

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.AutoFit()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory Data in a Spreadsheet

Description
Demonstration script that retrieves data from Active Directory and then displays that data in an Excel spreadsheet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add

objExcel.Cells(1, 1).Value = "Last name"
objExcel.Cells(1, 2).Value = "First name"
objExcel.Cells(1, 3).Value = "Department"
objExcel.Cells(1, 4).Value = "Phone number"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 100
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
    "SELECT givenName, SN, department, telephoneNumber FROM " _
        & "'LDAP://dc=fabrikam,dc=microsoft,dc=com' WHERE " _
            & "objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
x = 2

Do Until objRecordSet.EOF
    objExcel.Cells(x, 1).Value = _
        objRecordSet.Fields("SN").Value
    objExcel.Cells(x, 2).Value = _
        objRecordSet.Fields("givenName").Value
    objExcel.Cells(x, 3).Value = _
        objRecordSet.Fields("department").Value
    objExcel.Cells(x, 4).Value = _
        objRecordSet.Fields("telephoneNumber").Value
    x = x + 1
    objRecordSet.MoveNext
Loop

Set objRange = objExcel.Range("A1")
objRange.Activate

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()

Set objRange = objExcel.Range("B1")
objRange.Activate
Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()

Set objRange = objExcel.Range("C1")
objRange.Activate

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()

Set objRange = objExcel.Range("D1")
objRange.Activate

Set objRange = objExcel.ActiveCell.EntireColumn
objRange.Autofit()

Set objRange = objExcel.Range("A1").SpecialCells(11)
Set objRange2 = objExcel.Range("C1")
Set objRange3 = objExcel.Range("A1")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Excel Color Values

Description
Demonstration script that displays the various colors -- and their related color index -- available when programmatically controlling Microsoft Excel.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True
objExcel.Workbooks.Add

For i = 1 to 56
    objExcel.Cells(i, 1).Value = i
    objExcel.Cells(i, 1).Interior.ColorIndex = i
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Data in a Spreadsheet

Description
Demonstration script that retrieves information about each service running on a computer, and then displays that data in an Excel spreadsheet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add

x = 1
strComputer = "."
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
    ("Select * From Win32_Service")

For Each objService in colServices
    objExcel.Cells(x, 1) = objService.Name
    objExcel.Cells(x, 2) = objService.State
    x = x + 1
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Open an Excel Spreadsheet

Description
Demonstration script that opens an existing Excel spreadsheet named C:\Scripts\New_users.xls.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\New_users.xls")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read an Excel Spreadsheet

Description
Demonstration script that reads the values stored in a spreadsheet named C:\Scripts\New_users.xls.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open _
    ("C:\Scripts\New_users.xls")

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
    Wscript.Echo "CN: " & objExcel.Cells(intRow, 1).Value
    Wscript.Echo "sAMAccountName: " & objExcel.Cells(intRow, 2).Value
    Wscript.Echo "GivenName: " & objExcel.Cells(intRow, 3).Value
    Wscript.Echo "LastName: " & objExcel.Cells(intRow, 4).Value
    intRow = intRow + 1
Loop

objExcel.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Formatted Table to a Word Document

Description
Demonstration script that retrieves service data from a computer and then displays that data in a formatted table in Microsoft Word.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()

Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)

x=1

strComputer = "."
Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objItem in colItems
    If x > 1 Then
        objTable.Rows.Add()
    End If
    objTable.Cell(x, 1).Range.Font.Bold = True
    objTable.Cell(x, 1).Range.Text = objItem.Name
    objTable.Cell(x, 2).Range.text = objItem.DisplayName
    objTable.Cell(x, 3).Range.text = objItem.State
    x = x + 1
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Table to a Word Document

Description
Demonstration script that retrieves service information from a computer and then displays that information in tabular format in Microsoft Word.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()

Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)

x=1

strComputer = "."
Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objItem in colItems
    If x > 1 Then
        objTable.Rows.Add()
    End If
    objTable.Cell(x, 1).Range.Text = objItem.Name
    objTable.Cell(x, 2).Range.text = objItem.DisplayName
    objTable.Cell(x, 3).Range.text = objItem.State
    x = x + 1
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Formatted Text to a Word Document

Description
Demonstration script that displays formatted data in a Microsoft Word document.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")

objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "Network Adapter Report"
objSelection.TypeParagraph()

objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Append Text to a Word Document

Description
Demonstration script that appends the current date to the existing Microsoft Word document C:\Scripts\Word\Testdoc.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const END_OF_STORY = 6
Const MOVE_SELECTION = 0

Set objWord = CreateObject("Word.Application")
objWord.Visible = True

Set objDoc = objWord.Documents.Open("c:\scripts\word\testdoc.doc")
Set objSelection = objWord.Selection
objSelection.EndKey END_OF_STORY, MOVE_SELECTION

objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Size = "10"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Apply a Style to a Table in a Word Document

Description
Demonstration script that retrieves service data from a computer, displays that data in a table in Microsoft Word, then formats the data by using a predefined Microsoft Word style

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()

Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
objTable.Range.Font.Size = 10
objTable.Range.Style = "Table Contemporary"

x=2

objTable.Cell(x, 1).Range.Text = "Service Name"
objTable.Cell(x, 2).Range.text = "Display Name"
objTable.Cell(x, 3).Range.text = "State"

strComputer = "."
Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objItem in colItems
    If x > 1 Then
        objTable.Rows.Add()
    End If
    objTable.Cell(x, 1).Range.Text = objItem.Name
    objTable.Cell(x, 2).Range.text = objItem.DisplayName
    objTable.Cell(x, 3).Range.text = objItem.State
    x = x + 1
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a New Word Document

Description
Demonstration script that creates and displays a new Microsoft Word document.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create and Save a Word Document

Description
Demonstration script that retrieves network adapter data from a computer, displays that data in a Microsoft Word document, and then saves the document as C:\Scripts\Word\Testdoc.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Caption = "Test Caption"
objWord.Visible = True

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "Network Adapter Report"
objSelection.TypeParagraph()

objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()

objSelection.Font.Size = "10"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")

For Each objItem in colItems

    objSelection.Font.Bold = True
    objSelection.TypeText "ARP Always Source Route: "
    objSelection.Font.Bold = False
    objSelection.TypeText "" & objItem.ArpAlwaysSourceRoute
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "ARP Use EtherSNAP: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.ArpUseEtherSNAP
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Caption: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.Caption
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Database Path: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""   & objItem.DatabasePath
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Dead GW Detection Enabled: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""   & objItem.DeadGWDetectEnabled
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default IP Gateway: "
    objSelection.Font.Bold = False
    objSelection.TypeText "" & objItem.DefaultIPGateway
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default TOS: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.DefaultTOS
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Default TTL: "
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.DefaultTTL
    objSelection.TypeParagraph()

    objSelection.Font.Bold = True
    objSelection.TypeText "Description: "
    objSelection.Font.Bold = True
    objSelection.Font.Bold = False
    objSelection.TypeText ""  & objItem.Description
    objSelection.TypeParagraph()

    objSelection.TypeParagraph()

Next

objDoc.SaveAs("C:\Scripts\Word\testdoc.doc")
objWord.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display Service Information in a Word Document

Description
Demonstration script that retrieves service information from a computer and then displays that data in a Microsoft Word document.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Visible = True

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

objSelection.TypeText "Services Report"
objSelection.TypeParagraph()
objSelection.TypeText "" & Now
objSelection.TypeParagraph()
objSelection.TypeParagraph()

strComputer = "."
Set objWMIService = _
    GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objItem in colItems
    objSelection.TypeText objItem.DisplayName & " -- " & objItem.State
    objSelection.TypeParagraph()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Microsoft Word Properties

Description
Demonstration script that lists Microsoft Word configuration settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objWord = CreateObject("Word.Application")
Wscript.Echo "Active Printer:", objWord.ActivePrinter

For Each objAddIn in objWord.AddIns
    Wscript.Echo "AddIn: ", objAddIn
Next

Wscript.Echo "Application:", objWord.Application
Wscript.Echo "Assistant:", objWord.Assistant

For Each objCaption in objWord.AutoCaptions
    Wscript.Echo "AutoCaptions:", objCaption
Next
Wscript.Echo "Automation Security:", objWord.AutomationSecurity
Wscript.Echo "Background Printing Status:", objWord.BackgroundPrintingStatus
Wscript.Echo "Background Saving Status:", objWord.BackgroundSavingStatus
Wscript.Echo "Browse Extra File Type:", objWord.BrowseExtraFileTypes
Wscript.Echo "Build:", objWord.Build
Wscript.Echo "Caps Lock:", objWord.CapsLock
Wscript.Echo "Caption:", objWord.Caption

For Each objLabel in objWord.CaptionLabels
    Wscript.Echo "Caption Label:", objLabel
Next

Wscript.Echo "Check Language:", objWord.CheckLanguage

For Each objAddIn in objWord.COMAddIns
    Wscript.Echo "COM AddIn:", objAddIn
Next

Wscript.Echo "Creator:", objWord.Creator

For Each objDictionary in objWord.CustomDictionaries
    Wscript.Echo "Custom Dictionary:", objDictionary
Next

Wscript.Echo "Customization Context:", objWord.CustomizationContext
Wscript.Echo "Default Legal Blackline:", objWord.DefaultLegalBlackline
Wscript.Echo "Default Save Format:", objWord.DefaultSaveFormat
Wscript.Echo "Default Table Separator:", objWord.DefaultTableSeparator

For Each objDialog in objWord.Dialogs
    Wscript.Echo "Dialog:", objDialog
Next

Wscript.Echo "Display Alerts:", objWord.DisplayAlerts
Wscript.Echo "Display Recent Files:", objWord.DisplayRecentFiles
Wscript.Echo "Display Screen Tips:", objWord.DisplayScreenTips
Wscript.Echo "Display Scroll Bars:", objWord.DisplayScrollBars

For Each objDocument in objWord.Documents
    Wscript.Echo "Document:", objDocument
Next

Wscript.Echo "Email Template:", objWord.EmailTemplate
Wscript.Echo "Enable Cancel Key:", objWord.EnableCancelKey
Wscript.Echo "Feature Install:", objWord.FeatureInstall

For Each objConverter in objWord.FileConverters
    Wscript.Echo "File Converter:", objConverter
Next

Wscript.Echo "Focus In MailHeader:", objWord.FocusInMailHeader

For Each objFont in objWord.FontNames
    Wscript.Echo "Font Name:", objFont
Next

Wscript.Echo "Height", objWord.Height

For Each objBinding in objWord.KeyBindings
    Wscript.Echo "Key Binding:", objBinding
Next

For Each objFont in objWord.LandscapeFontNames
    Wscript.Echo "Landscape Font Name:", objFont
Next

Wscript.Echo "Language", objWord.Language

For Each objLanguage in objWord.Languages
    Wscript.Echo "Language:", objLanguage
Next

Wscript.Echo "Left", objWord.Left
Wscript.Echo "Mail System:", objWord.MailSystem
Wscript.Echo "MAPI Available:", objWord.MAPIAvailable
Wscript.Echo "Math Coprocessor Available:", objWord.MathCoprocessorAvailable
Wscript.Echo "Mouse Available:", objWord.MouseAvailable
Wscript.Echo "Name:", objWord.Name
Wscript.Echo "Normal Template:", objWord.NormalTemplate
Wscript.Echo "Num Lock:", objWord.NumLock
Wscript.Echo "Parent:", objWord.Parent
Wscript.Echo "Path:", objWord.Path
Wscript.Echo "Path Separator:", objWord.PathSeparator
Wscript.Echo "Print Preview:", objWord.PrintPreview

For Each objFile in objWord.RecentFiles
    Wscript.Echo "Recent File:", objFile
Next

Wscript.Echo "Screen Updating:", objWord.ScreenUpdating
Wscript.Echo "Show Visual Basic Editor:", objWord.ShowVisualBasicEditor
Wscript.Echo "Special Mode:", objWord.SpecialMode
Wscript.Echo "Startup Path:", objWord.StartupPath

For Each objTask in objWord.Tasks
    Wscript.Echo "Task:", objTask
Next

For Each objTemplate in objWord.Templates
    Wscript.Echo "Template:", objTemplate
Next

Wscript.Echo "Top:", objWord.Top
Wscript.Echo "Usable Height:", objWord.UsableHeight
Wscript.Echo "Usable Width:", objWord.UsableWidth
Wscript.Echo "User Address:", objWord.UserAddress
Wscript.Echo "User Control:", objWord.UserControl
Wscript.Echo "User Initials:", objWord.UserInitials
Wscript.Echo "User Name:", objWord.UserName
Wscript.Echo "Version:", objWord.Version
Wscript.Echo "Visible:", objWord.Visible
Wscript.Echo "Width:", objWord.Width

For Each objWindow in objWord.Windows
    Wscript.Echo "Window:", objWindow
Next

Wscript.Echo "Window State:", objWord.WindowState
objWord.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Bookmark Text in a Word Document

Description
Demonstration script that changes the text of two different bookmarks in an existing Microsoft Word document.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
objWord.Caption = "Test Caption"
objWord.Visible = True

Set objDoc = objWord.Documents.Open("c:\scripts\word\bookmarkdoc.doc")

Set objRange = objDoc.Bookmarks("NameBookmark").Range
objRange.Text = "Bob"

Set objRange = objDoc.Bookmarks("AddressBookmark").Range
objRange.Text = "999"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Open and Print a Word Document

Description
Demonstration script that opens and prints and existing Microsoft Word document.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("c:\scripts\inventory.doc")

objDoc.PrintOut()
objWord.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Bookmark in a Word Document

Description
Demonstration script that retrieves the values of two different Microsoft Word bookmarks.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("c:\scripts\word\bookmarkdoc.doc")
Set objRange = objDoc.Bookmarks("NameBookmark").Range

Wscript.Echo objRange.Text

Set objRange = objDoc.Bookmarks("AddressBookmark").Range
Wscript.Echo objRange.Text

objWord.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use Word to Search for Files

Description
Demonstration script that uses Microsoft Word to locate all the .mp3 files stored on drive C of the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()

objWord.FileSearch.FileName = "*.mp3"
objWord.FileSearch.LookIn = "C:\"
objWord.FileSearch.SearchSubfolders = True
objWord.FileSearch.Execute

For Each objFile in objWord.FileSearch.FoundFiles
    Wscript.Echo objFile
Next

objWord.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Static IP Address

Description
Sets the IP address of a computer to 192.168.1.141, and sets the IP gateway to 192.168.1.100.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)

For Each objNetAdapter in colNetAdapters
    errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
    errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
    If errEnable = 0 Then
        WScript.Echo "The IP address has been changed."
    Else
        WScript.Echo "The IP address could not be changed."
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign the DNS Domain for a Network Adapter

Description
Sets the DNS domain for a TCP/IP-bound network adapter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    Wscript.Echo objNetCard.SetDNSDomain("fabrikam.com")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign the WINS Server for a Network Adapter

Description
Sets the primary and secondary WINS server for a TCP/IP-bound network adapter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    strPrimaryServer = "192.168.1.100"
    strSecondaryServer = "192.168.1.200"
    objNetCard.SetWINSServer strPrimaryServer, strSecondaryServer
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Dead Gateway Detection for All Network Adapters

Description
Configures all network adapters on a computer to automatically detect dead gateways.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDeadGWDetect(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable DHCP

Description
Enables the DHCP client service on a computer. The computer will then use DHCP to obtain an IP address rather than use a static IP address.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each objNetAdapter In colNetAdapters
    errEnable = objNetAdapter.EnableDHCP()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable DNS on All Network Adapters

Description
Enables DNS for all network adapters on a computer, configuring the host name to fabrikam1 and designating hr.fabrikam.com and research.fabrikam.com as DNS search order suffixes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
strHostName = "fabrikam1"
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.EnableDNS strHostName, , , arrDNSSuffixes

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable IPFilter Security on All Network Adapters

Description
Enables IP filter security for all the network adapters installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.EnableIPFilterSec(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable IPSec on a Network Adapter

Description
Enables IP security for a network adapter. In this script, all TCP and UDP ports as well as all IP protocols are allowed; hence the value 0 is passed to the EnableIPSec method in each case. If only specific ports or protocols are allowed, these should be passed in the form of arrays.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ALLOW_ALL = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrPermittedTCPPorts = Array(ALLOW_ALL)
    arrPermittedUDPPorts = Array(ALLOW_ALL)
    arrPermittedIPProtocols = Array(ALLOW_ALL)
    objNetCard.EnableIPSec arrPermittedTCPPorts, arrPermittedUDPPorts, _
        arrPermittedIPProtocols
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable PMTU Discovery on all Network Adapters

Description
Enables a computer to automatically discover the maximum transmission unit on a network. To disable auto-discovery of the maximum transmission unit, pass the value False to the SetPMTUDiscovery method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUDiscovery(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable WINS for All Network Adapters

Description
Enables WINS on all the network adapters installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const DNS_ENABLED_FOR_WINS_RESOLUTION = True
Const USE_LMHOST_FILE = False

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
errResult = objNetworkSettings.EnableWINS(DNS_ENABLED_FOR_WINS_RESOLUTION,_
     USE_LMHOST_FILE)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify ARP Queries to Use EtherSNAP

Description
Configures the network adapters on a computer to use 802.3 SNAP encoding for Ethernet packets.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpUseEtherSNAP(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify ARP Queries to Use Source Routing

Description
Configures TCP/IP to always use source routing on all Token Ring networks.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetArpAlwaysSourceRoute(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Dynamic DNS Registration for a Network Adapter

Description
Configures dynamic DNS registration for a network adapter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const FULL_DNS_REGISTRATION = True
Const DOMAIN_DNS_REGISTRATION = False

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, _
        DOMAIN_DNS_REGISTRATION
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Keep Alive Time for All Network Adapters

Description
Configures the keep alive time for all network adapters on a computer to 300,000 milliseconds (5 minutes).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveTime(300000)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NetBIOS Use on a Network Adapter

Description
Enables NetBIOS for a network adapter. To enable NetBIOS via DHCP, pass the value 0 to the SetTCPIPNetBIOS method (instead of the value 1). Pass the value 2 to disable NetBIOS.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetTCPIPNetBIOS(1)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify PMTUBH Detection on All Network Adapters

Description
Enables the auto-discovery of black hole routers when determining the maximum transmission unit on a network. To disable auto-discovery of black hole routers, pass the value False to the SetPMTUBHDetect method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetPMTUBHDetect(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Allowed Number of TCP Connections

Description
Sets the maximum allowed number of simultaneously-opened TCP connections on a computer to 10.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPNumConnections(10)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Database Path for all Network Adapters

Description
Sets the path to the standard Internet database files (HOSTS, LMHOSTS, NETWORKS, PROTOCOLS) used by the Windows Sockets interface.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDatabasePath("c:\windows\system32\drivers\etc")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Default Time-to-Live for All Network Adapters

Description
Sets the default time-to-live value in the header of outgoing IP packets to 64 (this represents the number of routers an IP packet can pass through before being discarded). Valid TTL values range from 1 to 255, with a default value of 32.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetDefaultTTL(64)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the DNS Server Search Order for a Network Adapter

Description
Configures a TCP/IP-bound network adapter to use two DNS servers: 192.168.1.100 and 192.168.1.200. Note that even if a computer only uses one DNS server, the IP address of that server must still be passed to the SetDNSServerSearchOrder method as an array (in that case, an array with only one element).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrDNSServers = Array("192.168.1.100", "192.168.1.200")
    objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the DNS Suffix Search Order for All Network Adapters

Description
Configure a computer to use two DNS suffixes -- hr.fabrikam.com and research.fabrikam.com -- when performing DNS searches. Note that even if a computer uses only a single DNS suffix, this value must still be passed to the SetDNSSuffixSearchOrder method as an array (in that case, an array with a single element).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
arrDNSSuffixes = Array("hr.fabrikam.com", "research.fabrikam.com")
objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Forward Buffer Memory for All Network Adapters

Description
Configures the forward buffer memory for all network adapters on a computer. Values should be supplied in multiples of 256.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetForwardBufferMemory(74240)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Gateways for a Network Adapter

Description
Configures two gateways -- 192.168.1.100 and 192.168.1.200 -- for a network adapter. Note that even if only one gateway is specified, the IP address for that gateway must be passed as part of an array (in that case, an array with only a single element).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrGateways = Array("192.168.1.100", "192.168.1.200")
    objNetCard.SetGateways(arrGateways)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the IGMP Level for All Network Adapters

Description
Disables IGMP multicasting on a computer. To enable IP multicasting, pass the value 1 to the SetIGMPLevel method. Pass the value 2 to allow both IP and IGMP multicasting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIGMPLevel(0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the IP Connection Metric for a Network Adapter

Description
Sets the IP connection metric for a network adapter to 100. Connection metrics can range from 1 to 9,999, with a default value of 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.SetIPConnectionMetric(100)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the IPX Frame Type

Description
Configures the IPX network number and frame type for a network adapter. In this case, the frame type is set to AUTO (value of 255). Because the frame type is set to AUTO, the network number must be set to 0. Note that both the network number and the frame types must be passed as arrays, even if there is only a single element (for example, one frame type).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const AUTO = 255
Const NETWORK_NUMBER = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    arrNetworkNumber = Array(NETWORK_NUMBER)
    arrFrameTypes = Array(AUTO)
    objNetCard.SetIPXFrameTypeNetworkPairs arrNetworkNumber, arrFrameTypes
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the IPX Virtual Network Number

Description
Sets the IPX internal network number of a computer to network number 5.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPXVirtualNetworkNumber(5)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Keep Alive Interval for all Network Adapters

Description
Configures the keep alive interval for all network adapters on a computer to 300,00 milliseconds (5 minutes).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetKeepAliveInterval(300000)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Maximum Allowed TCP Connection Retransmissions

Description
Configures the number of times TCP will retransmit a connection attempt before abandoning the effort. Valid values range from 0 to 0xFFFFFFFF.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPMaxConnectRetransmissions(10)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Maximum Allowed TCP Data Retransmissions

Description
Configures the number of times TCP will attempt to retransmit an individual data segment before abandoning the effort. Valid values range from 0 to 0xFFFFFFFF.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPMaxDataRetransmissions(10)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the MTU for all Network Adapters

Description
Configures the maximum transmission unit for all network adapters installed in a computer. Valid values range from a minimum of 68 bytes to the maximum number of bytes supported by the network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetMTU(68)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Number of Allowed Forward Packets

Description
Configures the number of forward packets allocated to the router packet queue. Valid values range from 1 to 0xFFFFFFFE.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetNumForwardPackets(1)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the TCP Window Size for All Network Adapters

Description
Sets the TCP window size for all network adapters on a computer. Valid windows sizes range from 0 to 65,535 bytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTCPWindowSize(65535)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Urgent Pointer Use for All Network Adapters

Description
Configures a computer to use the RFC 1122 specification for urgent data rather than the mode used by Berkeley Software Design- (BSD) derived systems. To use the BSD mode instead, pass the value False to the SetTcpRFC1122UrgentPointer method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetTcpUseRFC1122UrgentPointer(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Zero-Broadcast Use for All Network Adapters

Description
Configures a computer to use zero-broadcasts (0.0.0.0) rather than one-broadcasts (255.255.255.255). Zero-broadcasts are the default used on systems derived from BSD implementations.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.SetIPUseZeroBroadcast(True)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release All DHCP Leases

Description
Releases all the DHCP leases currently in use on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.ReleaseDHCPLeaseAll()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release the DHCP Lease for a Network Adapter

Description
Releases the DHCP leases for all TCP/IP-bound network adapters on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.ReleaseDHCPLease()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Renew All DHCP Leases

Description
Renews all the DHCP leases currently in use on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objNetworkSettings.RenewDHCPLeaseAll()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Renew the DHCP Lease for a Network Adapter

Description
Renews the DHCP lease for each TCP/IP-bound network adapter in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetCards = objWMIService.ExecQuery _
    ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objNetCard in colNetCards
    objNetCard.RenewDHCPLease()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IP Addresses for a Computer

Description
Returns the IP address for each IP-enabled network adapter installed in a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")

For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then
        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
            WScript.Echo IPConfig.IPAddress(i)
        Next
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IP Configuration Data

Description
WMI script that returns configuration data similar to that returned by Ipconfig.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAdapters = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

n = 1
WScript.Echo

For Each objAdapter in colAdapters
   WScript.Echo "Network Adapter " & n
   WScript.Echo "================="
   WScript.Echo "  Description: " & objAdapter.Description

   WScript.Echo "  Physical (MAC) address: " & objAdapter.MACAddress
   WScript.Echo "  Host name:              " & objAdapter.DNSHostName

   If Not IsNull(objAdapter.IPAddress) Then
      For i = 0 To UBound(objAdapter.IPAddress)
         WScript.Echo "  IP address:             " & objAdapter.IPAddress(i)
      Next
   End If

   If Not IsNull(objAdapter.IPSubnet) Then
      For i = 0 To UBound(objAdapter.IPSubnet)
         WScript.Echo "  Subnet:                 " & objAdapter.IPSubnet(i)
      Next
   End If

   If Not IsNull(objAdapter.DefaultIPGateway) Then
      For i = 0 To UBound(objAdapter.DefaultIPGateway)
         WScript.Echo "  Default gateway:        " & _
             objAdapter.DefaultIPGateway(i)
      Next
   End If

   WScript.Echo
   WScript.Echo "  DNS"
   WScript.Echo "  ---"
   WScript.Echo "    DNS servers in search order:"

   If Not IsNull(objAdapter.DNSServerSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSServerSearchOrder)
         WScript.Echo "      " & objAdapter.DNSServerSearchOrder(i)
      Next
   End If

   WScript.Echo "    DNS domain: " & objAdapter.DNSDomain

   If Not IsNull(objAdapter.DNSDomainSuffixSearchOrder) Then
      For i = 0 To UBound(objAdapter.DNSDomainSuffixSearchOrder)
         WScript.Echo "    DNS suffix search list: " & _
             objAdapter.DNSDomainSuffixSearchOrder(i)
      Next
   End If

   WScript.Echo
   WScript.Echo "  DHCP"
   WScript.Echo "  ----"
   WScript.Echo "    DHCP enabled:        " & objAdapter.DHCPEnabled
   WScript.Echo "    DHCP server:         " & objAdapter.DHCPServer

   If Not IsNull(objAdapter.DHCPLeaseObtained) Then
      utcLeaseObtained = objAdapter.DHCPLeaseObtained
      strLeaseObtained = WMIDateStringToDate(utcLeaseObtained)
   Else
      strLeaseObtained = ""
   End If
   WScript.Echo "    DHCP lease obtained: " & strLeaseObtained

   If Not IsNull(objAdapter.DHCPLeaseExpires) Then
      utcLeaseExpires = objAdapter.DHCPLeaseExpires
      strLeaseExpires = WMIDateStringToDate(utcLeaseExpires)
   Else
      strLeaseExpires = ""
   End If
   WScript.Echo "    DHCP lease expires:  " & strLeaseExpires

   WScript.Echo
   WScript.Echo "  WINS"
   WScript.Echo "  ----"
   WScript.Echo "    Primary WINS server:   " & objAdapter.WINSPrimaryServer
   WScript.Echo "    Secondary WINS server: " & objAdapter.WINSSecondaryServer
   WScript.Echo

   n = n + 1

Next

Function WMIDateStringToDate(utcDate)
   WMIDateStringToDate = CDate(Mid(utcDate, 5, 2)  & "/" & _
       Mid(utcDate, 7, 2)  & "/" & _
           Left(utcDate, 4)    & " " & _
               Mid (utcDate, 9, 2) & ":" & _
                   Mid(utcDate, 11, 2) & ":" & _
                      Mid(utcDate, 13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IP4 Route Table Information

Description
Returns information about the IP route tables configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_IP4RouteTable")

For Each objItem in colItems
    Wscript.Echo "Age: " & objItem.Age
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Destination: " & objItem.Destination
    Wscript.Echo "Information: " & objItem.Information
    Wscript.Echo "Interface Index: " & objItem.InterfaceIndex
    Wscript.Echo "Mask: " & objItem.Mask
    Wscript.Echo "Metric 1: " & objItem.Metric1
    Wscript.Echo "Metric 2: " & objItem.Metric2
    Wscript.Echo "Metric 3: " & objItem.Metric3
    Wscript.Echo "Metric 4: " & objItem.Metric4
    Wscript.Echo "Metric 5: " & objItem.Metric5
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Next Hop: " & objItem.NextHop
    Wscript.Echo "Protocol: " & objItem.Protocol
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Adapter Configuration Properties

Description
Lists configuration information for all the network adapters installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")

For Each objItem in colItems
    Wscript.Echo "ARP Always Source Route: " & objItem.ArpAlwaysSourceRoute
    Wscript.Echo "ARP Use EtherSNAP: " & objItem.ArpUseEtherSNAP
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Database Path: " & objItem.DatabasePath
    Wscript.Echo "Dead GW Detection Enabled: " & objItem.DeadGWDetectEnabled
    Wscript.Echo "Default IP Gateway: " & objItem.DefaultIPGateway
    Wscript.Echo "Default TOS: " & objItem.DefaultTOS
    Wscript.Echo "Default TTL: " & objItem.DefaultTTL
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DHCP Enabled: " & objItem.DHCPEnabled
    Wscript.Echo "DHCP Lease Expires: " & objItem.DHCPLeaseExpires
    Wscript.Echo "DHCP Lease Obtained: " & objItem.DHCPLeaseObtained
    Wscript.Echo "DHCP Server: " & objItem.DHCPServer
    Wscript.Echo "DNS Domain: " & objItem.DNSDomain
    Wscript.Echo "DNS Domain Suffix Search Order: " & _
        objItem.DNSDomainSuffixSearchOrder
    Wscript.Echo "DNS Enabled For WINS Resolution: " & _
        objItem.DNSEnabledForWINSResolution
    Wscript.Echo "DNS Host Name: " & objItem.DNSHostName
    Wscript.Echo "DNS Server Search Order: " & objItem.DNSServerSearchOrder
    Wscript.Echo "Domain DNS Registration Enabled: " & _
        objItem.DomainDNSRegistrationEnabled
    Wscript.Echo "Forward Buffer Memory: " & objItem.ForwardBufferMemory
    Wscript.Echo "Full DNS Registration Enabled: " & _
        objItem.FullDNSRegistrationEnabled
    Wscript.Echo "Gateway Cost Metric: " & objItem.GatewayCostMetric
    Wscript.Echo "IGMP Level: " & objItem.IGMPLevel
    Wscript.Echo "Index: " & objItem.Index
    Wscript.Echo "IP Address: " & objItem.IPAddress
    Wscript.Echo "IP Connection Metric: " & objItem.IPConnectionMetric
    Wscript.Echo "IP Enabled: " & objItem.IPEnabled
    Wscript.Echo "IP Filter Security Enabled: " & _
        objItem.IPFilterSecurityEnabled
    Wscript.Echo "IP Port Security Enabled: " & objItem.IPPortSecurityEnabled
    Wscript.Echo "IPSec Permit IP Protocols: " & objItem.IPSecPermitIPProtocols
    Wscript.Echo "IPSec Permit TCP Ports: " & objItem.IPSecPermitTCPPorts
    Wscript.Echo "IPSec Permit UDP Ports: " & objItem.IPSecPermitUDPPorts
    Wscript.Echo "IP Subnet: " & objItem.IPSubnet
    Wscript.Echo "IP Use Zero Broadcast: " & objItem.IPUseZeroBroadcast
    Wscript.Echo "IPX Address: " & objItem.IPXAddress
    Wscript.Echo "IPX Enabled: " & objItem.IPXEnabled
    Wscript.Echo "IPX Frame Type: " & objItem.IPXFrameType
    Wscript.Echo "IPX Media Type: " & objItem.IPXMediaType
    Wscript.Echo "IPX Network Number: " & objItem.IPXNetworkNumber
    Wscript.Echo "IPX Virtual Net Number: " & objItem.IPXVirtualNetNumber
    Wscript.Echo "Keep Alive Interval: " & objItem.KeepAliveInterval
    Wscript.Echo "Keep Alive Time: " & objItem.KeepAliveTime
    Wscript.Echo "MAC Address: " & objItem.MACAddress
    Wscript.Echo "MTU: " & objItem.MTU
    Wscript.Echo "Number of Forward Packets: " & objItem.NumForwardPackets
    Wscript.Echo "PMTUBH Detect Enabled: " & objItem.PMTUBHDetectEnabled
    Wscript.Echo "PMTU Discovery Enabled: " & objItem.PMTUDiscoveryEnabled
    Wscript.Echo "Service Name: " & objItem.ServiceName
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "TCPIP Netbios Options: " & objItem.TcpipNetbiosOptions
    Wscript.Echo "TCP Maximum Connect Retransmissions: " & _
        objItem.TcpMaxConnectRetransmissions
    Wscript.Echo "TCP Maximum Data Retransmissions: " & _
        objItem.TcpMaxDataRetransmissions
    Wscript.Echo "TCP NumC onnections: " & objItem.TcpNumConnections
    Wscript.Echo "TCP Use RFC1122 Urgent Pointer: " & _
        objItem.TcpUseRFC1122UrgentPointer
    Wscript.Echo "TCP Window Size: " & objItem.TcpWindowSize
    Wscript.Echo "WINS Enable LMHosts Lookup: " & _
        objItem.WINSEnableLMHostsLookup
    Wscript.Echo "WINS Host Lookup File: " & objItem.WINSHostLookupFile
    Wscript.Echo "WINS Primary Server: " & objItem.WINSPrimaryServer
    Wscript.Echo "WINS Scope ID: " & objItem.WINSScopeID
    Wscript.Echo "WINS Secondary Server: " & objItem.WINSSecondaryServer
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Adapter Properties

Description
Lists property values for all the network adapters installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")

For Each objItem in colItems
    Wscript.Echo "Adapter Type: " & objItem.AdapterType

    Select Case objItem.AdapterTypeID
        Case 0 strAdapterType = "Ethernet 802.3"
        Case 1 strAdapterType = "Token Ring 802.5"
        Case 2 strAdapterType = "Fiber Distributed Data Interface (FDDI)"
        Case 3 strAdapterType = "Wide Area Network (WAN)"
        Case 4 strAdapterType = "LocalTalk"
        Case 5 strAdapterType = "Ethernet using DIX header format"
        Case 6 strAdapterType = "ARCNET"
        Case 7 strAdapterType = "ARCNET (878.2)"
        Case 8 strAdapterType = "ATM"
        Case 9 strAdapterType = "Wireless"
        Case 10 strAdapterType = "Infrared Wireless"
        Case 11 strAdapterType = "Bpc"
        Case 12 strAdapterType = "CoWan"
        Case 13 strAdapterType = "1394"
    End Select

    Wscript.Echo "Adapter Type Id: " & strAdapterType
    Wscript.Echo "AutoSense: " & objItem.AutoSense
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Index: " & objItem.Index
    Wscript.Echo "MAC Address: " & objItem.MACAddress
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Maximum Number Controlled: " & objItem.MaxNumberControlled
    Wscript.Echo "Maximum Speed: " & objItem.MaxSpeed
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Net Connection ID: " & objItem.NetConnectionID
    Wscript.Echo "Net Connection Status: " & objItem.NetConnectionStatus
    For Each strNetworkAddress in objItem.NetworkAddresses
        Wscript.Echo "NetworkAddress: " & strNetworkAddress
    Next
    Wscript.Echo "Permanent Address: " & objItem.PermanentAddress
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Product Name: " & objItem.ProductName
    Wscript.Echo "Service Name: " & objItem.ServiceName
    Wscript.Echo "Speed: " & objItem.Speed
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Client Information

Description
Returns information about all the network clients installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkClient")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Login Profiles

Description
Returns network login information for all the users of a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkLoginProfile")

For Each objItem in colItems
    dtmWMIDate = objItem.AccountExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Account Expires: " & strReturn
    Wscript.Echo "Authorization Flags: " & objItem.AuthorizationFlags
    Wscript.Echo "Bad Password Count: " & objItem.BadPasswordCount
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "CodePage: " & objItem.CodePage
    Wscript.Echo "Comment: " & objItem.Comment
    Wscript.Echo "Country Code: " & objItem.CountryCode
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Full Name: " & objItem.FullName
    Wscript.Echo "Home Directory: " & objItem.HomeDirectory
    Wscript.Echo "Home Directory Drive: " & objItem.HomeDirectoryDrive
    dtmWMIDate = objItem.LastLogoff
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Last Logoff: " & strReturn
    dtmWMIDate = objItem.LastLogon
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Last Logon: " & strReturn
    Wscript.Echo "Logon Hours: " & objItem.LogonHours
    Wscript.Echo "Logon Server: " & objItem.LogonServer
    Wscript.Echo "Maximum Storage: " & objItem.MaximumStorage
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons
    Wscript.Echo "Password Age: " & objItem.PasswordAge
    dtmWMIDate = objItem.PasswordExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Password Expires: " & strReturn
    Wscript.Echo "Primary Group ID: " & objItem.PrimaryGroupId
    Wscript.Echo "Privileges: " & objItem.Privileges
    Wscript.Echo "Profile: " & objItem.Profile
    Wscript.Echo "Script Path: " & objItem.ScriptPath
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Units Per Week: " & objItem.UnitsPerWeek
    Wscript.Echo "User Comment: " & objItem.UserComment
    Wscript.Echo "User Id: " & objItem.UserId
    Wscript.Echo "User Type: " & objItem.UserType
    Wscript.Echo "Workstations: " & objItem.Workstations
    Wscript.Echo
Next

Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2))
    End If
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Proxy Server Information

Description
Returns information about the Internet proxy server used by a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Proxy")

For Each objItem in colItems
    Wscript.Echo "Proxy Port Number: " & objItem.ProxyPortNumber
    Wscript.Echo "Proxy Server: " & objItem.ProxyServer
    Wscript.Echo "Server Name: " & objItem.ServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Network Protocols on a Computer

Description
Uses WMI to return information about all the network protocols installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkProtocol")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Connectionless Service: " & objItem.ConnectionlessService
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Guarantees Delivery: " & objItem.GuaranteesDelivery
    Wscript.Echo "Guarantees Sequencing: " & objItem.GuaranteesSequencing
    strInstallDate = WMIDateStringToDate(objItem.InstallDate)
    Wscript.Echo "Install Date: " & strInstallDate
    Wscript.Echo "Maximum Address Size: " & objItem.MaximumAddressSize
    Wscript.Echo "Maximum Message Size: " & objItem.MaximumMessageSize
    Wscript.Echo "Message Oriented: " & objItem.MessageOriented
    Wscript.Echo "Minimum Address Size: " & objItem.MinimumAddressSize
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Pseudo Stream Oriented: " & objItem.PseudoStreamOriented
    Wscript.Echo "Supports Broadcasting: " & objItem.SupportsBroadcasting
    Wscript.Echo "Supports Connect Data: " & objItem.SupportsConnectData
    Wscript.Echo "Supports Disconnect Data: " & objItem.SupportsDisconnectData
    Wscript.Echo "Supports Encryption: " & objItem.SupportsEncryption
    Wscript.Echo "Supports Expedited Data: " & objItem.SupportsExpeditedData
    Wscript.Echo "Supports Fragmentation: " & objItem.SupportsFragmentation
    Wscript.Echo "Supports Graceful Closing: " & _
        objItem.SupportsGracefulClosing
    Wscript.Echo "Supports Guaranteed Bandwidth: " & _
        objItem.SupportsGuaranteedBandwidth
    Wscript.Echo "Supports Multicasting: " & objItem.SupportsMulticasting
    Wscript.Echo "Supports Quality of Service: " & _
        objItem.SupportsQualityofService
Next

Function WMIDateStringToDate(dtmDate)
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
        Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
            & " " & Mid (dtmDate, 9, 2) & ":" & _
                Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Ping Multiple Computers

Description
Uses the Win32_PingStatus class to ping four computers and identify any computers that could not be reached over the network. This script was contributed by Maxim Stepin of Microsoft.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strMachines = "atl-dc-01;atl-win2k-01;atl-nt4-01;atl-dc-02"
aMachines = split(strMachines, ";")

For Each machine in aMachines
    Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
        ExecQuery("select * from Win32_PingStatus where address = '"_
            & machine & "'")
    For Each objStatus in objPing
        If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
            WScript.Echo("Computer " & machine & " is not reachable")
        End If
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Cluster Node Information

Description
Returns information about all the cluster nodes found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_Node")

For Each objItem in colItems
    Wscript.Echo "Build number: " & objItem.BuildNumber
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "CSD version: " & objItem.CSDVersion
    Wscript.Echo "Dedicated: " & objItem.Dedicated
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Enable event log replication: " & _
        objItem.EnableEventLogReplication
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Identifying descriptions: " & objItem.IdentifyingDescriptions
    Wscript.Echo "Initial load info: " & objItem.InitialLoadInfo
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Last load info: " & objItem.LastLoadInfo
    Wscript.Echo "Major version: " & objItem.MajorVersion
    Wscript.Echo "Minor version: " & objItem.MinorVersion
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Name format: " & objItem.NameFormat
    Wscript.Echo "Node highest version: " & objItem.NodeHighestVersion
    Wscript.Echo "Node lowest version: " & objItem.NodeLowestVersion
    Wscript.Echo "Other identifying info: " & objItem.OtherIdentifyingInfo
    Wscript.Echo "Power state: " & objItem.PowerState
    Wscript.Echo "Primary owner contact: " & objItem.PrimaryOwnerContact
    Wscript.Echo "Primary owner name: " & objItem.PrimaryOwnerName
    Wscript.Echo "Reset capability: " & objItem.ResetCapability
    Wscript.Echo "Roles: " & objItem.Roles
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Cluster Resource Group Information

Description
Returns information about all the cluster resource groups on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_ResourceGroup")

For Each objItem in colItems
    Wscript.Echo "Auto-failback type: " & objItem.AutoFailbackType
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Failback window end: " & objItem.FailbackWindowEnd
    Wscript.Echo "Failback window start: " & objItem.FailbackWindowStart
    Wscript.Echo "Failover period: " & objItem.FailoverPeriod
    Wscript.Echo "Failover threshold: " & objItem.FailoverThreshold
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Load balance state: " & objItem.LoadBalState
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Persistent state: " & objItem.PersistentState
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Cluster Resource Type Information

Description
Returns information about all the cluster resource types on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_ResourceType")

For Each objItem in colItems
    Wscript.Echo "Administrator extensions: " & objItem.AdminExtensions
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "Delete requires all nodes: " & objItem.DeleteRequiresAllNodes
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Display name: " & objItem.DisplayName
    Wscript.Echo "DLL name: " & objItem.DllName
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Is alive poll interval: " & objItem.IsAlivePollInterval
    Wscript.Echo "Local quorum capable: " & objItem.LocalQuorumCapable
    Wscript.Echo "Looks alive poll interval: " & objItem.LooksAlivePollInterval
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Quorum capable: " & objItem.QuorumCapable
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Cluster Service Information

Description
Returns information about the cluster service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_Service")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Enable event log replication: " & _
        objItem.EnableEventLogReplication
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Node highest version: " & objItem.NodeHighestVersion
    Wscript.Echo "Node lowest version: " & objItem.NodeLowestVersion
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start mode: " & objItem.StartMode
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "System name: " & objItem.SystemName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Information

Description
Returns network information for a cluster server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_Network")

For Each objItem in colItems
    Wscript.Echo "Address: " & objItem.Address
    Wscript.Echo "Address mask: " & objItem.AddressMask
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Role: " & objItem.Role
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Interface Information

Description
Returns information about the network interfaces on a cluster server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MSCluster_NetworkInterface")

For Each objItem in colItems
    Wscript.Echo "Adapter: " & objItem.Adapter
    Wscript.Echo "Address: " & objItem.Address
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Identifying descriptions: " & objItem.IdentifyingDescriptions
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Network: " & objItem.Network
    Wscript.Echo "Other identifying info: " & objItem.OtherIdentifyingInfo
    Wscript.Echo "Power-on hours: " & objItem.PowerOnHours
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Status info: " & objItem.StatusInfo
    Wscript.Echo "System name: " & objItem.SystemName
    Wscript.Echo "Total power-on hours: " & objItem.TotalPowerOnHours
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Listing Cluster Resource Information

Description
Returns cluster resource information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_Resource")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Characteristics: " & objItem.Characteristics
    Wscript.Echo "Core resource: " & objItem.CoreResource
    Wscript.Echo "Cryptographic checkpoints: " & objItem.CryptoCheckpoints
    Wscript.Echo "Debug prefix: " & objItem.DebugPrefix
    Wscript.Echo "Delete requires all nodes: " & _
        objItem.DeleteRequiresAllNodes
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Is alive poll interval: " & objItem.IsAlivePollInterval
    Wscript.Echo "Load balance analysis interval: " & _
        objItem.LoadBalAnalysisInterval
    Wscript.Echo "Load balance minimum memory units: " & _
        objItem.LoadBalMinMemoryUnits
    Wscript.Echo "Load balance minimum processor units: " & _
        objItem.LoadBalMinProcessorUnits
    Wscript.Echo "Load balance sample interval: " & _
        objItem.LoadBalSampleInterval
    Wscript.Echo "Load balance startup interval: " & _
        objItem.LoadBalStartupInterval
    Wscript.Echo "Local quorum capable: " & objItem.LocalQuorumCapable
    Wscript.Echo "Looks alive poll interval: " & _
        objItem.LooksAlivePollInterval
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Pending timeout: " & objItem.PendingTimeout
    Wscript.Echo "Persistent state: " & objItem.PersistentState
    Wscript.Echo "Private properties: " & objItem.PrivateProperties
    Wscript.Echo "Quorum capable: " & objItem.QuorumCapable
    Wscript.Echo "Registry checkpoints: " & objItem.RegistryCheckpoints
    Wscript.Echo "Resource class: " & objItem.ResourceClass
    Wscript.Echo "Restart action: " & objItem.RestartAction
    Wscript.Echo "Restart period: " & objItem.RestartPeriod
    Wscript.Echo "Restart threshold: " & objItem.RestartThreshold
    Wscript.Echo "Retry period on failure: " & _
        objItem.RetryPeriodOnFailure
    Wscript.Echo "Separate monitor: " & objItem.SeparateMonitor
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "Subclass: " & objItem.Subclass
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Retrieving Clustering Information

Description
Returns basic information about a cluster.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\mscluster")

Set colItems = objWMIService.ExecQuery("Select * from MSCluster_Cluster")

For Each objItem in colItems
    Wscript.Echo "Administrator extensions: " & objItem.AdminExtensions
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Dedicated: " & objItem.Dedicated
    Wscript.Echo "Default network role: " & objItem.DefaultNetworkRole
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Enable event log replication: " & _
        objItem.EnableEventLogReplication
    Wscript.Echo "Group administrator extensions: " & _
        objItem.GroupAdminExtensions
    Wscript.Echo "Identifying descriptions: " & objItem.IdentifyingDescriptions
    Wscript.Echo "Installation date: " & objItem.InstallDate
    Wscript.Echo "Maintenance file: " & objItem.MaintenanceFile
    Wscript.Echo "Maximum number of nodes: " & objItem.MaxNumberOfNodes
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Name format: " & objItem.NameFormat
    Wscript.Echo "Network administrator extensions: " & _
        objItem.NetworkAdminExtensions
    Wscript.Echo "Network interface administrator extensions: " & _
        objItem.NetworkInterfaceAdminExtensions
    Wscript.Echo "Network priorities: " & objItem.NetworkPriorities
    Wscript.Echo "Node administrator xtensions: " & objItem.NodeAdminExtensions
    Wscript.Echo "Other identifying info: " & objItem.OtherIdentifyingInfo
    Wscript.Echo "Primary owner contact: " & objItem.PrimaryOwnerContact
    Wscript.Echo "Primary owner name: " & objItem.PrimaryOwnerName
    Wscript.Echo "Quorum log file size: " & objItem.QuorumLogFileSize
    Wscript.Echo "Resource administrator extensions: " & _
        objItem.ResourceAdminExtensions
    Wscript.Echo "Resource type administrator extensions: " & _
        objItem.ResourceTypeAdminExtensions
    Wscript.Echo "Roles: " & objItem.Roles
    Wscript.Echo "Security: " & objItem.Security
    Wscript.Echo "Security descriptor: " & objItem.Security_Descriptor
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mail Agent for Domain DNS Record

Description
Creates a mail agent for domain (MD) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "workstation5.fabrikam.com"
intRecordClass = 1
intTTL = 600
strMailAgent = "mailagent.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MDType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        strMailAgent)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mail Exchanger DNS Record

Description
Creates a mail exchanger (MX) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
intPreference = 0
strMailExchanger = "mailexchanger.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MXType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        intPreference, strMailExchanger)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mail Forwarding Agent DNS Record

Description
Creates a mail forwarding agent (MF) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
strMailForwarder = "mailforwarder.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MFType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, _
        intTTL, strMailForwarder)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mail Group DNS Record

Description
Creates a mail group (MG) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "admin.fabrikam.com"
intRecordClass = 1
intTTL = 600
strMailbox = "netadmins.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MGType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, strMailbox)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mail Information DNS Record

Description
Creates a mail information (MI) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "administrator.fabrikam.com"
intRecordClass = 1
intTTL = 600
strAdminMailbox = "dnsadmin.fabrikam.com"
strErrorMailbox = "support.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MInfoType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        strAdminMailbox, strErrorMailbox)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mailbox DNS Record

Description
Creates a mailbox (MB) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
strMailboxHost = "admin.mailserver.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MBType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, _
        intTTL, strMailboxHost)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Mailbox Rename DNS Record

Description
Creates a mailbox rename (MR) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "old-mailbox.fabrikam.com"
intRecordClass = 1
intTTL = 600
strMailbox = "newmailbox.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_MRType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, strMailbox)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Name Server DNS Record

Description
Creates a name server (NS) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
strNSHost = "nameserver.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_NSType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, strNSHost)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Responsible Person DNS Record

Description
Creates a responsible person (RP) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
strRPMAilbox = "admin.fabrikam.com"
strText = "Network Administrator, (555) 555-1219"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_RPType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, _
        intTTL, strRPMailbox, strText)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Route Through DNS Record

Description
Creates a route through (RT) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
intPreference = 1
strRouter = "router.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_RTType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, _
        intTTL, intPreference, strRouter)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Text DNS Record

Description
Creates a text (TXT) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-dc-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
strText = "This domain is reserved for employees of Fabrikam."

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_TXTType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, strText)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Well-Known Services DNS Record

Description
Creates a well-known services (WKS) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "ftp.fabrikam.com"
intRecordClass = 1
intTTL = 600
strIPAddress = "192.168.1.150"
strProtocol = "TCP"
strServices = "FTP"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_WKSType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        strIPAddress, strProtocol, strServices)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Andrew File System Database Server DNS Record

Description
Creates an Andrew File System Database Server (AFSDB) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atl-srv-01.fabrikam.com"
intRecordClass = 1
intTTL = 600
intSubtype = 1
strServerName = "afs.fabrikam.com"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_AFSDBType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        intSubType, strServerName)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ATM Address to Name DNS Record

Description
Creates an ATM address to name (ATMA) record on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "atm.fabrikam.com"
intRecordClass = 1
intTTL = 600
intFormat = 1
strATMAddress = "47.0079.00010200000000000000.00a03e000002.00"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_ATMAType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, intTTL, _
        intFormat, strATMAddress)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an IPv6 Address DNS Record

Description
Creates an IPv6 address record (AAAA) on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDNSServer = "atl-dc-03.fabrikam.com"
strContainer = "fabrikam.com"
strOwner = "ipv6.fabrikam.com"
intRecordClass = 1
intTTL = 600
strIPv6Address = "4321:0:1:2:3:4:567:89ab"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_AAAAType")
errResult = objItem.CreateInstanceFromPropertyData _
    (strDNSServer, strContainer, strOwner, intRecordClass, _
        intTTL, strIPv6Address)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Andrew File System Database Server DNS Records

Description
Returns information about the Andrew File System database server (AFSDB) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
SSet objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AFSDBType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Server Name: " & objItem.ServerName
    Wscript.Echo "Subtype: " & objItem.Subtype
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List ATM Address to Name DNS Records

Description
Returns information about the ATM address to name (ATMA) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_ATMAType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "ATM Address: " & objItem.ATMAddress
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Format: " & objItem.Format
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Canonical Name DNS Records

Description
Returns information about the canonical name (CNAME) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_CNAMEType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Primary Name: " & objItem.PrimaryName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Host Address DNS Records

Description
Returns information about the host address (A) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AType")

For Each objItem in colItems
    Wscript.Echo "IP Address: " & objItem.IPAddress
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Host Information DNS Records

Description
Returns data about the host information (HINFO) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_HINFOType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "CPU: " & objItem.CPU
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Operating System: " & objItem.OS
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IPv6 Address DNS Records

Description
Returns information about all the IPv6 address (AAAA) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_AAAAType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "IPv6 Address: " & objItem.IPv6Address
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List ISDN DNS Records

Description
Returns information about the ISDN resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_ISDNType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Serve Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "ISDN Number: " & objItem.ISDNNumber
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "SubAddress: " & objItem.SubAddress
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List KEY DNS Records

Description
Returns information about the KEY resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_KEYType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Algorithm: " & objItem.Algorithm
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Flags: " & objItem.Flags
    Wscript.Echo "Protocol: " & objItem.Protocol
    Wscript.Echo "Public Key: " & objItem.PublicKey
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mail Agent DNS Records

Description
Returns information about the mail agent for domain (MD) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MDType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "MD Host: " & objItem.MDHost
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mail Exchanger DNS Records

Description
Returns information about the mail exchanger (MX) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MXType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS sServer Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Mail Exchange: " & objItem.MailExchange
    Wscript.Echo "Preference: " & objItem.Preference
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mail Forwarding Agent DNS Records

Description
Returns information about the mail forwarding agent (MF) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MFType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "MF Host: " & objItem.MFHost
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mail Group DNS Records

Description
Returns information about the mail group (MG) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MGType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "MG Mailbox: " & objItem.MGMailbox
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mail Information DNS Records

Description
Returns data about the mail information (MINFO) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MINFOType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Error Mailbox: " & objItem.ErrorMailbox
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Responsible Mailbox: " & objItem.ResponsibleMailbox
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mailbox DNS Records

Description
Returns information about all the mailbox (MB) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MBType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "MB Host: " & objItem.MBHost
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mailbox Rename DNS Records

Description
Returns information about the mailbox rename (MR) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_MRType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS ServerName: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "MR Mailbox: " & objItem.MRMailbox
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Name Server DNS Records

Description
Returns information about the name server (NS) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_NSType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "NS Host: " & objItem.NSHost
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Next DNS Records

Description
Returns information about the next (NXT) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_NXTType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Next Domain Name: " & objItem.NextDomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo "Types: " & objItem.Types
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Pointer DNS Records

Description
Returns information about all the pointer (PTR) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_PTRType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "PTR Domain Name: " & objItem.PTRDomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Responsible PersonDNS Records

Description
Returns information about the responsible person (RP) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_RPType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS sServer Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "RP Mailbox: " & objItem.RPMailbox
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo "TXT Domain Name: " & objItem.TXTDomainName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Route Through DNS Records

Description
Returns information about the route through (RT) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_RTType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Intermediate Host: " & objItem.IntermediateHost
    Wscript.Echo "Preference: " & objItem.Preference
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service DNS Records

Description
Returns information about all the service (SRV) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_SRVType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Port: " & objItem.Port
    Wscript.Echo "Priority: " & objItem.Priority
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo "Weight: " & objItem.Weight
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Signature DNS Records

Description
Returns information about all the signature (SIG) resource records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_SIGType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Algorithm: " & objItem.Algorithm
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Key Tag: " & objItem.KeyTag
    Wscript.Echo "Labels: " & objItem.Labels
    Wscript.Echo "Original Time-to-Live: " & objItem.OriginalTTL
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Signature: " & objItem.Signature
    Wscript.Echo "Signature Expiration: " & objItem.SignatureExpiration
    Wscript.Echo "Signature Inception: " & objItem.SignatureInception
    Wscript.Echo "Signer Name: " & objItem.SignerName
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo "Type Covered: " & objItem.TypeCovered
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Start of Authority DNS Records

Description
Returns information about all the start of authority (SOA) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_SOAType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Expire Limit: " & objItem.ExpireLimit
    Wscript.Echo "Minimum Time-to-Live: " & objItem.MinimumTTL
    Wscript.Echo "Primary Server: " & objItem.PrimaryServer
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Refresh Interval: " & objItem.RefreshInterval
    Wscript.Echo "Responsible Party: " & objItem.ResponsibleParty
    Wscript.Echo "Retry Delay: " & objItem.RetryDelay
    Wscript.Echo "Serial Number: " & objItem.SerialNumber
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Text DNS Records

Description
Returns information about all the text (TXT) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_TXTType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "Descriptive Text: " & objItem.DescriptiveText
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Well-Known Services DNS Records

Description
Returns information about all the well-known services (WKS) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_WKSType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Internet Address: " & objItem.InternetAddress
    Wscript.Echo "IP Protocol: " & objItem.IPProtocol
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Services: " & objItem.Services
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List WINS DNS Records

Description
Returns information about all the Windows Internet Name Service (WINS) records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_WINSType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Cache Timeout: " & objItem.CacheTimeout
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Lookup Timeout: " & objItem.LookupTimeout
    Wscript.Echo "Mapping Flag: " & objItem.MappingFlag
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live : " & objItem.TTL
    Wscript.Echo "WINS Servers: " & objItem.WinsServers
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List WINS Reverse Lookup DNS Records

Description
Returns information about all the Windows Internet Name Service (WINS) reverse lookup records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_WINSRType")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Cache Timeout: " & objItem.CacheTimeout
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "Lookup Timeout: " & objItem.LookupTimeout
    Wscript.Echo "Mapping Flag: " & objItem.MappingFlag
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Result Domain: " & objItem.ResultDomain
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List X.25 DNS Records

Description
Returns information about all the X.25 records on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_X25Type")

For Each objItem in colItems
    Wscript.Echo "Owner Name: " & objItem.OwnerName
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Domain Name: " & objItem.DomainName
    Wscript.Echo "PSDN Address: " & objItem.PSDNAddress
    Wscript.Echo "Record Class: " & objItem.RecordClass
    Wscript.Echo "Record Data: " & objItem.RecordData
    Wscript.Echo "Text Representation: " & objItem.TextRepresentation
    Wscript.Echo "Timestamp: " & objItem.Timestamp
    Wscript.Echo "Time-to-Live: " & objItem.TTL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Age All DNS Records

Description
Enables aging of all records (except name server and start of authority records) in the DNS zone accounting.fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    errResult = objItem.AgeAllRecords(,1)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear the DNS Server Cache

Description
Clears the DNS server cache of resource records.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Cache")

For Each objItem in colItems
    objItem.ClearCache()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Primary DNS Zone

Description
Creates a primary DNS zone named accounting.fabrikam.com on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strZoneName = "accounting.fabrikam.com"
intPrimaryZone = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set objItem = objWMIService.Get("MicrosoftDNS_Zone")
errResult = objItem.CreateZone(strZoneName, intPrimaryZone)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Force a Refresh of a DNS Zone

Description
Forces the refresh of the secondary DNS zone accounting.fabrikam.com from its master zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.ForceRefresh()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Domain Properties

Description
Returns information about the domains in a DNS hierarchy.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Domain")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Server Cache Properties

Description
Returns information about the DNS cache on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Cache")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DNSServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Server Properties

Description
Returns detailed information about a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Server")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Address Answer Limit: " & objItem.AddressAnswerLimit
    Wscript.Echo "Allow Update: " & objItem.AllowUpdate
    Wscript.Echo "Autocache Update: " & objItem.AutoCacheUpdate
    Wscript.Echo "Autoconfig File Zones: " & objItem.AutoConfigFileZones
    Wscript.Echo "Bind Secondaries: " & objItem.BindSecondaries
    Wscript.Echo "Boot Method: " & objItem.BootMethod
    Wscript.Echo "Default Aging State: " & objItem.DefaultAgingState
    Wscript.Echo "Default No-Refresh Interval: " & _
        objItem.DefaultNoRefreshInterval
    Wscript.Echo "Default Refresh Interval: " & objItem.DefaultRefreshInterval
    Wscript.Echo "Disable AutoReverse Zones: " & _
        objItem.DisableAutoReverseZones
    Wscript.Echo "Disjoint Nets: " & objItem.DisjointNets
    Wscript.Echo "Directory Service Available: " & objItem.DsAvailable
    Wscript.Echo "Directory Service Polling Interval: " & _
        objItem.DsPollingInterval
    Wscript.Echo "Directory Service Tombstone Interval: " & _
        objItem.DsTombstoneInterval
    Wscript.Echo "EDNS Cache Timeout: " & objItem.EDnsCacheTimeout
    Wscript.Echo "Enable Directory Partitions: " & _
        objItem.EnableDirectoryPartitions
    Wscript.Echo "Enable DNSSec: " & objItem.EnableDnsSec
    Wscript.Echo "Enable EDNS Probes: " & objItem.EnableEDnsProbes
    Wscript.Echo "Event Log Level: " & objItem.EventLogLevel
    Wscript.Echo "Forward Delegations: " & objItem.ForwardDelegations
    Wscript.Echo "Forwarders: " & objItem.Forwarders
    Wscript.Echo "Forwarding Timeout: " & objItem.ForwardingTimeout
    Wscript.Echo "Is Slave: " & objItem.IsSlave
    Wscript.Echo "Listen Addresses: " & objItem.ListenAddresses
    Wscript.Echo "Local Net Priority: " & objItem.LocalNetPriority
    Wscript.Echo "Logfile Maximum Size: " & objItem.LogFileMaxSize
    Wscript.Echo "Logfile Path: " & objItem.LogFilePath
    Wscript.Echo "Log IPFilter List: " & objItem.LogIPFilterList
    Wscript.Echo "Log Level: " & objItem.LogLevel
    Wscript.Echo "Loose Wildcarding: " & objItem.LooseWildcarding
    Wscript.Echo "Maximum Cache Time-to-Live: " & objItem.MaxCacheTTL
    Wscript.Echo "Maximum Negative Cache Time-to-Live: " & _
        objItem.MaxNegativeCacheTTL
    Wscript.Echo "Name Check Flag: " & objItem.NameCheckFlag
    Wscript.Echo "No Recursion: " & objItem.NoRecursion
    Wscript.Echo "Recursion Retry: " & objItem.RecursionRetry
    Wscript.Echo "Recursion Timeout: " & objItem.RecursionTimeout
    Wscript.Echo "RoundRobin: " & objItem.RoundRobin
    Wscript.Echo "Rpc Protocol: " & objItem.RpcProtocol
    Wscript.Echo "Scavenging Interval: " & objItem.ScavengingInterval
    Wscript.Echo "Secure Responses: " & objItem.SecureResponses
    Wscript.Echo "Send Port: " & objItem.SendPort
    For Each strAddress in objItem.ServerAddresses
        Wscript.Echo "Server Address: " & strAddress
    Next
    Wscript.Echo "Started: " & objItem.Started
    Wscript.Echo "Start Mode: " & objItem.StartMode
    Wscript.Echo "Strict File Parsing: " & objItem.StrictFileParsing
    Wscript.Echo "Update Options: " & objItem.UpdateOptions
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Write Authority NS: " & objItem.WriteAuthorityNS
    Wscript.Echo "Xfr Connect Timeout: " & objItem.XfrConnectTimeout
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Server Root Hints Properties

Description
Returns information about the root hints stored in the cache file on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_RootHints")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Server Statistics

Description
Returns statistics collected on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Statistic")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Collection Name: " & objItem.CollectionName
    Wscript.Echo "Collection ID: " & objItem.CollectionId
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "String Value: " & objItem.StringValue
    Wscript.Echo "Value: " & objItem.Value
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DNS Zones

Description
Returns information about all the DNS zones on a DNS server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * from MicrosoftDNS_Zone")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Zone Type: " & objItem.ZoneType
    Wscript.Echo "Aging: " & objItem.Aging
    Wscript.Echo "Allow Update: " & objItem.AllowUpdate
    Wscript.Echo "Autocreated: " & objItem.AutoCreated
    Wscript.Echo "Available For Scavenge Time: " & _
        objItem.AvailForScavengeTime
    Wscript.Echo "Container Name: " & objItem.ContainerName
    Wscript.Echo "Data File: " & objItem.DataFile
    Wscript.Echo "Disable WINS Record Replication: " & _
        objItem.DisableWINSRecordReplication
    Wscript.Echo "DNS Server Name: " & objItem.DnsServerName
    Wscript.Echo "Directory Service-Integrated: " & objItem.DsIntegrated
    Wscript.Echo "Forwarder Slave: " & objItem.ForwarderSlave
    Wscript.Echo "Forwarder Timeout: " & objItem.ForwarderTimeout
    Wscript.Echo "Last Successful SOA Check: " & _
        objItem.LastSuccessfulSoaCheck
    Wscript.Echo "LastSuccessful Xfr: " & objItem.LastSuccessfulXfr
    Wscript.Echo "Local Master Servers: " & objItem.LocalMasterServers
    Wscript.Echo "Master Servers: " & objItem.MasterServers
    Wscript.Echo "No-Refresh Interval: " & objItem.NoRefreshInterval
    Wscript.Echo "Notify: " & objItem.Notify
    Wscript.Echo "Notify Servers: " & objItem.NotifyServers
    Wscript.Echo "Paused: " & objItem.Paused
    Wscript.Echo "Refresh Interval: " & objItem.RefreshInterval
    Wscript.Echo "Reverse: " & objItem.Reverse
    Wscript.Echo "Scavenge Servers: " & objItem.ScavengeServers
    Wscript.Echo "Secondary Servers: " & objItem.SecondaryServers
    Wscript.Echo "Secure Secondaries: " & objItem.SecureSecondaries
    Wscript.Echo "Shutdown: " & objItem.Shutdown
    Wscript.Echo "Use Wins: " & objItem.UseWins
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the DNS Zone Type

Description
Changes the DNS zone type of the zone accounting.fabrikam.com to a primary DNS zone.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

intPrimaryZone = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    errResult = objItem.ChangeZoneType(intPrimaryZone, true)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause a DNS Zone

Description
Pauses the DNS zone accounting.fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.PauseZone()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Reload a DNS Zone

Description
Reloads the DNS zone fabrikam.com from its database.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'fabrikam.com'")

For Each objItem in colItems
    objItem.ReloadZone()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume a Paused DNS Zone

Description
Resumes the DNS zone accounting.fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.ResumeZone()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start DNS Server Scavenging

Description
Instructs a DNS server to begin scavenging stale records in the appropriate DNS zones.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StartScavenging()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start the DNS Server Service

Description
Starts the DNS server service on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StartService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop the DNS Server Service

Description
Stops the DNS server service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_Server")

For Each objItem in colItems
    objItem.StopService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Update a DNS Zone

Description
Forces an update of the DNS zone accounting.fabrikam.com from Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.UpdateFromDS()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Write-Back a DNS Zone

Description
Saves zone data for the DNS zone accounting.fabrikam.com to the appropriate zone file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\MicrosoftDNS")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MicrosoftDNS_Zone Where Name = 'accounting.fabrikam.com'")

For Each objItem in colItems
    objItem.WriteBackZone()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Connection Properties

Description
Enumerates Internet Connection Firewall connection properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_ConnectionProperties")

For Each objItem in colItems
    Wscript.Echo "Connection: " & objItem.Connection
    Wscript.Echo "Is Bridge: " & objItem.IsBridge
    Wscript.Echo "Is Bridge Member: " & objItem.IsBridgeMember
    Wscript.Echo "Is Firewalled: " & objItem.IsFirewalled
    Wscript.Echo "Is ICS Private: " & objItem.IsICSPrivate
    Wscript.Echo "Is ICS Public: " & objItem.IsICSPublic
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Connections

Description
Returns the properties of each Internet Connection Firewall connection.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery("Select * from HNet_Connection")

For Each objItem in colItems
    Wscript.Echo "GUID: " & objItem.GUID
    Wscript.Echo "Is LAN Connection: " & objItem.IsLANConnection
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Phone Book Path: " & objItem.PhoneBookPath
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Firewall Logging Settings

Description
Enumerates the configuration settings for Internet Connection Firewall logging.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_FirewallLoggingSettings")

For Each objItem in colItems
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Log Connections: " & objItem.LogConnections
    Wscript.Echo "Log Dropped Packets: " & objItem.LogDroppedPackets
    Wscript.Echo "Max File Size: " & objItem.MaxFileSize
    Wscript.Echo "Path: " & objItem.Path
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Firewall Settings

Description
Enumerates the inbound and outbound configuration settings for Internet Connection Firewall.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery("Select * from HNet_FwIcmpSettings")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Allow Inbound Echo request: " & _
        objItem.AllowInboundEchoRequest
    Wscript.Echo "Allow Inbound Mask Requestt: " & _
        objItem.AllowInboundMaskRequest
    Wscript.Echo "Allow Inbound Router Request: " & _
        objItem.AllowInboundRouterRequest
    Wscript.Echo "Allow Inbound Timestamp Request: " & _
        objItem.AllowInboundTimestampRequest
    Wscript.Echo "Allow Outbound Destination Unreachable: " & _
        objItem.AllowOutboundDestinationUnreachable
    Wscript.Echo "Allow Outbound Parameter Problem: " & _
        objItem.AllowOutboundParameterProblem
    Wscript.Echo "Allow Outbound Source Quench: " & _
        objItem.AllowOutboundSourceQuench
    Wscript.Echo "Allow Outbound Time Exceeded: " & _
        objItem.AllowOutboundTimeExceeded
    Wscript.Echo "Allow redirect: " & objItem.AllowRedirect
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking ICMP Settings

Description
Enumerates the ICMP settings for Internet Connection Firewall.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_ConnectionICMPSetting")

For Each objItem in colItems
    Wscript.Echo "Connection: " & objItem.Connection
    Wscript.Echo "ICMP Settings: " & objItem.ICMPSettings
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking ICS Settings

Description
Reports whether the Internet Connection Firewall settings have been configured to allow DHCP and DNS.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery("Select * from HNet_ICSSettings")

For Each objItem in colItems
    Wscript.Echo "DHCP Enabled: " & objItem.DHCPEnabled
    Wscript.Echo "DNS Enabled: " & objItem.DNSEnabled
    Wscript.Echo "ID: " & objItem.ID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Port Mapping Protocols

Description
Enumerates all the Internet Connection Firewall port mapping protocols on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_PortMappingProtocol")

For Each objItem in colItems
    Wscript.Echo "Built In: " & objItem.BuiltIn
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "IP Protocol: " & objItem.IPProtocol
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Port: " & objItem.Port
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Home Networking Port Mappings

Description
Returns a list of all the Internet Connection Firewall port mappings on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_ConnectionPortMapping2")

For Each objItem in colItems
    Wscript.Echo "Connection: " & objItem.Connection
    Wscript.Echo "Enabled: " & objItem.Enabled
    Wscript.Echo "Name Active: " & objItem.NameActive
    Wscript.Echo "Protocol: " & objItem.Protocol
    Wscript.Echo "Target IP Address: " & objItem.TargetIPAddress
    Wscript.Echo "Target Name: " & objItem.TargetName
    Wscript.Echo "Target Port: " & objItem.TargetPort
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Home Networking Firewall Logging Settings

Description
Disables the logging of dropped packets with Internet Connection Firewall. To enable logging of dropped packets, simply set the value of the property LogDroppedPackets to True.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery _
    ("Select * from HNet_FirewallLoggingSettings")

For Each objItem in colItems
    objItem.LogDroppedPackets = False
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Home Networking Firewall Settings

Description
Disables the ability of the Internet Connection Firewall to allow inbound echo requests. To enable the ability to allow inbound echo requests, simply set the value of the property AlllowInboundEchoRequest to True.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & _
        "\root\microsoft\homenet")

Set colItems = objWMIService.ExecQuery("Select * from HNet_FwIcmpSettings")

For Each objItem in colItems
    objItem.AllowInboundEchoRequest = False
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor HTTP Indexing Service Performance

Description
Uses cooked performance counters to return performance data from the HTTP Indexing Service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService," & _
    "Win32_PerfFormattedData_ISAPISearch_HTTPIndexingService").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Active Queries: " & objItem.Activequeries
        Wscript.Echo "Cache Items: " & objItem.Cacheitems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Current Requests Queued: " & _
            objItem.Currentrequestsqueued
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Cache Hits: " & objItem.PercentCachehits
        Wscript.Echo "Percent Cache Misses: " & objItem.PercentCachemisses
        Wscript.Echo "Queries Per Minute: " & objItem.Queriesperminute
        Wscript.Echo "Total Queries: " & objItem.Totalqueries
        Wscript.Echo "Total Requests Rejected: " & _
            objItem.Totalrequestsrejected
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor IPSec 4 Driver Performance

Description
Uses cooked performance counters to monitor IPSec v4 driver performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_IPSec4Driver").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Pending key exchange operations: " & _
            objItem.PendingKeyExchangeOperations
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor IPSec 4 IKE Performance

Description
Uses cooked performance counters to monitor IPSec v4 IKE performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_IPSec4Driver").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Acquire heap size: " & _
            objItem.AcquireHeapSize
        Wscript.Echo "Main mode SA list entries: " & _
            objItem.MainModeSAListEntries
        Wscript.Echo "Quick mode SA list entries: " & _
            objItem.QuickModeSAListEntries
        Wscript.Echo "Receive heap size: " & _
            objItem.ReceiveHeapSize
        Wscript.Echo "Total authentication failures: " & _
            objItem.TotalAuthenticationFailures
        Wscript.Echo "Total main mode SAs: " & _
            objItem.TotalMainModeSAs
        Wscript.Echo "Total negotiation failures: " & _
            objItem.TotalNegotiationFailures
        Wscript.Echo "Total quick mode SAs: " & _
            objItem.TotalQuickModeSAs
        Wscript.Echo "Total soft associations: " & _
            objItem.TotalSoftAssociations
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor MSDTC Distributed Transaction Coordinator Performance

Description
Uses cooked performance counters to measure Microsoft Distributed Transaction Coordinator performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService," & _
    "Win32_PerfFormattedData_MSDTC_DistributedTransactionCoordinator"). _
        objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Aborted Transactions: " & objItem.AbortedTransactions
        Wscript.Echo "Aborted Transactions Per Second: " & _
            objItem.AbortedTransactionsPersec
        Wscript.Echo "Active Transactions: " & objItem.ActiveTransactions
        Wscript.Echo "Active Transactions Maximum: " & _
            objItem.ActiveTransactionsMaximum
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Committed Transactions: " & objItem.CommittedTransactions
        Wscript.Echo "Committed Transactions Per Second: " & _
            objItem.CommittedTransactionsPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Force Aborted Transactions: " & _
            objItem.ForceAbortedTransactions
        Wscript.Echo "Force Committed Transactions: " & _
            objItem.ForceCommittedTransactions
        Wscript.Echo "In-Doubt Transactions: " & objItem.InDoubtTransactions
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Response Time Average: " & objItem.ResponseTimeAverage
        Wscript.Echo "Response Time Maximum: " & objItem.ResponseTimeMaximum
        Wscript.Echo "Response Time Minimum: " & objItem.ResponseTimeMinimum
        Wscript.Echo "Transactions Per Second: " & objItem.TransactionsPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor PSched Flow Performance

Description
Uses cooked performance counters to measure flow statistics from the packet scheduler

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PSched_PSchedFlow").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Average Packets in Netcard: " & _
            objItem.AveragePacketsinnetcard
        Wscript.Echo "Average Packets in Sequencer: " & _
            objItem.Averagepacketsinsequencer
        Wscript.Echo "Average Packets in Shaper: " & _
            objItem.Averagepacketsinshaper
        Wscript.Echo "Bytes Scheduled: " & objItem.Bytesscheduled
        Wscript.Echo "Bytes Scheduled Per Second: " & _
            objItem.BytesscheduledPersec
        Wscript.Echo "Bytes Transmitted: " & objItem.Bytestransmitted
        Wscript.Echo "Bytes Transmitted Per Second: " & _
            objItem.BytestransmittedPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Maximum Packets in Netcard: " & _
            objItem.MaximumPacketsinnetcard
        Wscript.Echo "Maximum Packets in Sequencer: " & _
            objItem.Maxpacketsinsequencer
        Wscript.Echo "Maximum Packets in Shaper: " & _
            objItem.Maxpacketsinshaper
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Non-conforming Packets Scheduled: " & _
            objItem.Nonconformingpacketsscheduled
        Wscript.Echo "Non-conforming Packets ScheduledPersec: " & _
            objItem.NonconformingpacketsscheduledPersec
        Wscript.Echo "Non-conforming Packets Transmitted: " & _
            objItem.Nonconformingpacketstransmitted
        Wscript.Echo "Non-conforming Packets TransmittedPersec: " & _
            objItem.NonconformingpacketstransmittedPersec
        Wscript.Echo "Packets Dropped: " & objItem.Packetsdropped
        Wscript.Echo "Packets Dropped Per Second: " & _
            objItem.PacketsdroppedPersec
        Wscript.Echo "Packets Scheduled: " & objItem.Packetsscheduled
        Wscript.Echo "Packets Scheduled Per Second: " & _
            objItem.PacketsscheduledPersec
        Wscript.Echo "Packets Transmitted: " & objItem.Packetstransmitted
        Wscript.Echo "Packets Transmitted Per Second: " & _
            objItem.PacketstransmittedPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor PSched Pipe Performance

Description
Uses cooked performance counters to measure pipe statistics from the packet scheduler

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PSched_PSchedPipe").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Average Packets in Netcard: " & _
            objItem.Averagepacketsinnetcard
        Wscript.Echo "Average Packets in Sequencer: " & _
            objItem.Averagepacketsinsequencer
        Wscript.Echo "Average Packets in Shaper: " & _
            objItem.Averagepacketsinshaper
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Flow Mods Rejected: " & objItem.Flowmodsrejected
        Wscript.Echo "Flows Closed: " & objItem.Flowsclosed
        Wscript.Echo "Flows Modified: " & objItem.Flowsmodified
        Wscript.Echo "Flows Opened: " & objItem.Flowsopened
        Wscript.Echo "Flows Rejected: " & objItem.Flowsrejected
        Wscript.Echo "Maximum Packets in Netcard: " & _
            objItem.Maxpacketsinnetcard
        Wscript.Echo "Maximum Packets in Sequencer: " & _
            objItem.Maxpacketsinsequencer
        Wscript.Echo "Maximum Packets in Shaper: " & _
            objItem.Maxpacketsinshaper
        Wscript.Echo "Maximum Simultaneous Flows: " & _
            objItem.Maxsimultaneousflows
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Non-conforming Packets Scheduled: " & _
            objItem.Nonconformingpacketsscheduled
        Wscript.Echo "Non-conforming Packets ScheduledPersec: " & _
            objItem.NonconformingpacketsscheduledPersec
        Wscript.Echo "Non-conforming Packets Transmitted: " & _
            objItem.Nonconformingpacketstransmitted
        Wscript.Echo "Non-conforming Packets TransmittedPersec: " & _
            objItem.NonconformingpacketstransmittedPersec
        Wscript.Echo "Out-of-packets: " & objItem.Outofpackets
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Redirector Service Performance

Description
Uses cooked performance counters to monitor network connections originating at the local computer

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfNet_Redirector").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPersec
        Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
        Wscript.Echo "Bytes Transmitted Per Second: " & _
            objItem.BytesTransmittedPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Connects Core: " & objItem.ConnectsCore
        Wscript.Echo "Connects Lan Manager 2.0: " & _
            objItem.ConnectsLanManager20
        Wscript.Echo "Connects Lan Manager 2.1: " & _
            objItem.ConnectsLanManager21
        Wscript.Echo "Connects Windows NT: " & objItem.ConnectsWindowsNT
        Wscript.Echo "Current Commands: " & objItem.CurrentCommands
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "File Data Operations Per Second: " & _
            objItem.FileDataOperationsPersec
        Wscript.Echo "File Read Operations Per Second: " & _
            objItem.FileReadOperationsPersec
        Wscript.Echo "File Write Operations Per Second: " & _
            objItem.FileWriteOperationsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Network Errors Per Second: " & _
            objItem.NetworkErrorsPersec
        Wscript.Echo "Packets Per Second: " & objItem.PacketsPersec
        Wscript.Echo "Packets Received Per Second: " & _
            objItem.PacketsReceivedPersec
        Wscript.Echo "Packets Transmitted Per Second: " & _
            objItem.PacketsTransmittedPersec
        Wscript.Echo "Read Bytes Cache Per Second: " & _
            objItem.ReadBytesCachePersec
        Wscript.Echo "Read Bytes Network Per Second: " & _
            objItem.ReadBytesNetworkPersec
        Wscript.Echo "Read Bytes NonPaging Per Second: " & _
            objItem.ReadBytesNonPagingPersec
        Wscript.Echo "Read Bytes Paging Per Second: " & _
            objItem.ReadBytesPagingPersec
        Wscript.Echo "Read Operations Random Per Second: " & _
            objItem.ReadOperationsRandomPersec
        Wscript.Echo "Read Packets Per Second: " & objItem.ReadPacketsPersec
        Wscript.Echo "Read Packets Small Per Second: " & _
            objItem.ReadPacketsSmallPersec
        Wscript.Echo "Reads Denied Per Second: " & objItem.ReadsDeniedPersec
        Wscript.Echo "Reads Large Per Second: " & objItem.ReadsLargePersec
        Wscript.Echo "Server Disconnects: " & objItem.ServerDisconnects
        Wscript.Echo "Server Reconnects: " & objItem.ServerReconnects
        Wscript.Echo "Server Sessions: " & objItem.ServerSessions
        Wscript.Echo "Server Sessions Hung: " & objItem.ServerSessionsHung
        Wscript.Echo "Write Bytes Cache Per Second: " & _
            objItem.WriteBytesCachePersec
        Wscript.Echo "Write Bytes Network Per Second: " & _
            objItem.WriteBytesNetworkPersec
        Wscript.Echo "Write Bytes NonPaging Per Second: " & _
            objItem.WriteBytesNonPagingPersec
        Wscript.Echo "Write Bytes Paging Per Second: " & _
            objItem.WriteBytesPagingPersec
        Wscript.Echo "Write Operations Random Per Second: " & _
            objItem.WriteOperationsRandomPersec
        Wscript.Echo "Write Packets Per Second: " & _
            objItem.WritePacketsPersec
        Wscript.Echo "Write PacketsSmall Per Second: " & _
            objItem.WritePacketsSmallPersec
        Wscript.Echo "Writes Denied Per Second: " & objItem.WritesDeniedPersec
        Wscript.Echo "Writes Large Per Second: " & objItem.WritesLargePersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Remote Access Performance

Description
Uses cooked performance counters to monitor values for all ports of the Remote Access service (RAS) device on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService," & _
    "Win32_PerfFormattedData_PerfProc_RemoteAccess_RASTotal").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Alignment Errors: " & objItem.AlignmentErrors
        Wscript.Echo "Buffer Overrun Errors: " & objItem.BufferOverrunErrors
        Wscript.Echo "Bytes Received: " & objItem.BytesReceived
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPerSec
        Wscript.Echo "Bytes Transmitted: " & objItem.BytesTransmitted
        Wscript.Echo "Bytes Transmitted Per Second: " & _
            objItem.BytesTransmittedPerSec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "CRC Errors: " & objItem.CRCErrors
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Frames Received: " & objItem.FramesReceived
        Wscript.Echo "Frames Received Per Second: " & _
            objItem.FramesReceivedPerSec
        Wscript.Echo "Frames Transmitted: " & objItem.FramesTransmitted
        Wscript.Echo "Frames Transmitted Per Second: " & _
            objItem.FramesTransmittedPerSec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Compression In: " & objItem.PercentCompressionIn
        Wscript.Echo "Percent Compression Out: " & _
            objItem.PercentCompressionOut
        Wscript.Echo "Serial Overrun Errors: " & objItem.SerialOverrunErrors
        Wscript.Echo "Timeout Errors: " & objItem.TimeoutErrors
        Wscript.Echo "Total Connections: " & objItem.TotalConnections
        Wscript.Echo "Total Errors: " & objItem.TotalErrors
        Wscript.Echo "Total Errors Per Second: " & objItem.TotalErrorsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Remote Access RAS Port Performance

Description
Uses cooked performance counters to monitor individual Remote Access Service ports of the RAS device on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService," & _
    "Win32_PerfFormattedData_PerfProc_RemoteAccess_RASPort").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Alignment Errors: " & objItem.AlignmentErrors
        Wscript.Echo "Buffer Overrun Errors: " & objItem.BufferOverrunErrors
        Wscript.Echo "Bytes Received: " & objItem.BytesReceived
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPerSec
        Wscript.Echo "Bytes Transmitted: " & objItem.BytesTransmitted
        Wscript.Echo "Bytes Transmitted Per Second: " & _
            objItem.BytesTransmittedPerSec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "CRC Errors: " & objItem.CRCErrors
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Frames Received: " & objItem.FramesReceived
        Wscript.Echo "Frames Received Per Second: " & _
            objItem.FramesReceivedPerSec
        Wscript.Echo "Frames Transmitted: " & objItem.FramesTransmitted
        Wscript.Echo "Frames Transmitted Per Second: " & _
            objItem.FramesTransmittedPerSec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Compression In: " & objItem.PercentCompressionIn
        Wscript.Echo "Percent Compression Out: " & _
            objItem.PercentCompressionOut
        Wscript.Echo "Serial Overrun Errors: " & objItem.SerialOverrunErrors
        Wscript.Echo "Timeout Errors: " & objItem.TimeoutErrors
        Wscript.Echo "Total Errors: " & objItem.TotalErrors
        Wscript.Echo "Total Errors Per Second: " & objItem.TotalErrorsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor RSVP ACSRVP Interfaces Performance

Description
Uses cooked performance counters to monitor RSVP or ACS service performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_RSVP_RSVPService").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Bytes in QoS Notifications: " & _
            objItem.BytesinQoSnotifications
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Failed QoS Requests: " & objItem.FailedQoSrequests
        Wscript.Echo "Failed QoS Sends: " & objItem.FailedQoSsends
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Network Interfaces: " & objItem.NetworkInterfaces
        Wscript.Echo "Network Sockets: " & objItem.Networksockets
        Wscript.Echo "QoS Clients: " & objItem.QoSclients
        Wscript.Echo "QoS-Enabled Receivers: " & objItem.QoSenabledreceivers
        Wscript.Echo "QoS-Enabled Senders: " & objItem.QoSenabledsenders
        Wscript.Echo "QoS Notifications: " & objItem.QoSnotifications
        Wscript.Echo "RSVP Sessions: " & objItem.RSVPsessions
        Wscript.Echo "Timers: " & objItem.Timers
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor RSVP ACSRVPS Service Performance

Description
Uses cooked performance counters to monitor the number of local network interfaces visible to, and used by the RSVP service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_RSVP_RVPInterfaces").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Blocked RESVs: " & objItem.BlockedRESVs
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "General Failures: " & objItem.Generalfailures
        Wscript.Echo "Maximum Admitted Bandwidth: " & _
            objItem.Maximumadmittedbandwidth
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Number of Active Flows: " & objItem.Numberofactiveflows
        Wscript.Echo "Number of Incoming Messages Dropped: " & _
            objItem.Numberofincomingmessagesdropped
        Wscript.Echo "Number of Outgoing Messages Dropped: " & _
            objItem.Numberofoutgoingmessagesdropped
        Wscript.Echo "PATH Error Messages Received: " & _
            objItem.PATHERRmessagesreceived
        Wscript.Echo "PATH Error Messages Sent: " & _
            objItem.PATHERRmessagessent
        Wscript.Echo "PATH Messages Received: " & objItem.PATHmessagesreceived
        Wscript.Echo "PATH Messages Sent: " & objItem.PATHmessagessent
        Wscript.Echo "PATH State Block Timeouts: " & _
            objItem.PATHstateblocktimeouts
        Wscript.Echo "PATH TEAR Messages Received: " & _
            objItem.PATHTEARmessagesreceived
        Wscript.Echo "PATH TEAR Messages Sent: " & _
            objItem.PATHTEARmessagessent
        Wscript.Echo "Policy Control Failures: " & _
        objItem.Policycontrolfailures
        Wscript.Echo "Receive Messages Errors Big Messages: " & _
            objItem.ReceivemessageserrorsBigmessages
        Wscript.Echo "Receive Messages Errors No Memory: " & _
             objItem.ReceivemessageserrorsNomemory
        Wscript.Echo "Reserved Bandwidth: " & objItem.Reservedbandwidth
        Wscript.Echo "Resource Control Failures: " & _
            objItem.Resourcecontrolfailures
        Wscript.Echo "RESV CONFIRM Messages Received: " & _
            objItem.RESVCONFIRMmessagesreceived
        Wscript.Echo "RESV CONFIRM Messages Sent: " & _
            objItem.RESVCONFIRMmessagessent
        Wscript.Echo "RESV Error Messages Received: " & _
            objItem.RESVERRmessagesreceived
        Wscript.Echo "RESV Error Messages Sent: " & _
            objItem.RESVERRmessagessent
        Wscript.Echo "RESV Messages Received: " & objItem.RESVmessagesreceived
        Wscript.Echo "RESV Messages Sent: " & objItem.RESVmessagessent
        Wscript.Echo "RESV State Block Timeouts: " & _
            objItem.RESVstateblocktimeouts
        Wscript.Echo "RESV TEAR Messages Received: " & _
            objItem.RESVTEARmessagesreceived
        Wscript.Echo "RESV TEAR Messages Sent: " & _
            objItem.RESVTEARmessagessent
        Wscript.Echo "Send Messages Errors Big Messages: " & _
            objItem.SendmessageserrorsBigmessages
        Wscript.Echo "Send Messages Errors No Memory: " & _
            objItem.SendmessageserrorsNomemory
        Wscript.Echo "Signaling Bytes Received: " & _
            objItem.Signalingbytesreceived
        Wscript.Echo "Signaling Bytes Sent: " & objItem.Signalingbytessent
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TAPI Server Telephony Performance

Description
Uses cooked performance counters to monitor the telephony service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TAPISrv_Telephony").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Active Lines: " & objItem.ActiveLines
        Wscript.Echo "Active Telephones: " & objItem.ActiveTelephones
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Client Applications: " & objItem.ClientApps
        Wscript.Echo "Current Incoming Calls: " & objItem.CurrentIncomingCalls
        Wscript.Echo "Current Outgoing Calls: " & objItem.CurrentOutgoingCalls
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Incoming Calls Per Second: " & _
            objItem.IncomingCallsPersec
        Wscript.Echo "Lines: " & objItem.Lines
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Outgoing Calls Per Second: " & _
        objItem.OutgoingCallsPersec
        Wscript.Echo "Telephone Devices: " & objItem.TelephoneDevices
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP NBT Connection Performance

Description
Uses cooked performance counters to monitor the rates at which bytes are sent and received over the NetBIOS over TCP/IP (NBT) connection between the local computer and a remote computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCP_NBTConnection").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPersec
        Wscript.Echo "Bytes Sent Per Second: " & objItem.BytesSentPersec
        Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP ICMP Performance

Description
Uses cooked performance counters to monitor the rates at which messages are sent and received by using ICMP protocols.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_Tcpip_ICMP").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Messages Outbound Errors: " & _
            objItem.MessagesOutboundErrors
        Wscript.Echo "Messages Per Second: " & objItem.MessagesPersec
        Wscript.Echo "Messages Received Errors: " & _
            objItem.MessagesReceivedErrors
        Wscript.Echo "Messages Received Per Second: " & _
            objItem.MessagesReceivedPersec
        Wscript.Echo "Messages Sent Per Second: " & objItem.MessagesSentPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Received Address Mask: " & objItem.ReceivedAddressMask
        Wscript.Echo "Received Address Mask Reply: " & _
            objItem.ReceivedAddressMaskReply
        Wscript.Echo "Received Destination Unreachable: " & _
            objItem.ReceivedDestUnreachable
        Wscript.Echo "Received Echo Per Second: " & objItem.ReceivedEchoPersec
        Wscript.Echo "Received Echo Reply Per Second: " & _
            objItem.ReceivedEchoReplyPersec
        Wscript.Echo "Received Parameter Problem: " & _
            objItem.ReceivedParameterProblem
        Wscript.Echo "Received Redirect Per Second: " & _
            objItem.ReceivedRedirectPersec
        Wscript.Echo "Received Source Quench: " & _
            objItem.ReceivedSourceQuench
        Wscript.Echo "Received Time Exceeded: " & _
        objItem.ReceivedTimeExceeded
        Wscript.Echo "Received Timestamp Per Second: " & _
            objItem.ReceivedTimestampPersec
        Wscript.Echo "Received Timestamp Reply Per Second: " & _
            objItem.ReceivedTimestampReplyPersec
        Wscript.Echo "Sent Address Mask: " & objItem.SentAddressMask
        Wscript.Echo "Sent Address Mask Reply: " & _
            objItem.SentAddressMaskReply
        Wscript.Echo "Sent Destination Unreachable: " & _
            objItem.SentDestinationUnreachable
        Wscript.Echo "Sent Echo Per Second: " & objItem.SentEchoPersec
        Wscript.Echo "Sent Echo Reply Per Second: " & _
            objItem.SentEchoReplyPersec
        Wscript.Echo "Sent Parameter Problem: " & objItem.SentParameterProblem
        Wscript.Echo "Sent Redirect Per Second: " & objItem.SentRedirectPersec
        Wscript.Echo "Sent Source Quench: " & objItem.SentSourceQuench
        Wscript.Echo "Sent Time Exceeded: " & objItem.SentTimeExceeded
        Wscript.Echo "Sent Timestamp Per Second: " & _
            objItem.SentTimestampPersec
        Wscript.Echo "Sent Timestamp Reply Per Second: " & _
            objItem.SentTimestampReplyPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP ICMPv6 Performance

Description
Uses cooked performance counters to monitor the rates at which messages are sent and received by using ICMPv6 protocols.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_ICMPv6").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Messages per second: " & objItem.MessagesPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP IP Performance

Description
Uses cooked performance counters to monitor the rates at which IP datagrams are sent and received by using IP protocols.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_IP").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Datagrams Forwarded Per Second: " & _
            objItem.DatagramsForwardedPersec
        Wscript.Echo "Datagrams Outbound Discarded: " & _
            objItem.DatagramsOutboundDiscarded
        Wscript.Echo "Datagrams Outbound No Route: " & _
            objItem.DatagramsOutboundNoRoute
        Wscript.Echo "Datagrams Per Second: " & objItem.DatagramsPersec
        Wscript.Echo "Datagrams Received Address Errors: " & _
            objItem.DatagramsReceivedAddressErrors
        Wscript.Echo "Datagrams Received Delivered Per Second: " & _
            objItem.DatagramsReceivedDeliveredPersec
        Wscript.Echo "Datagrams Received Discarded: " & _
            objItem.DatagramsReceivedDiscarded
        Wscript.Echo "Datagrams Received Header Errors: " & _
            objItem.DatagramsReceivedHeaderErrors
        Wscript.Echo "Datagrams Received Per Second: " & _
            objItem.DatagramsReceivedPersec
        Wscript.Echo "Datagrams Received Unknown Protocol: " & _
            objItem.DatagramsReceivedUnknownProtocol
        Wscript.Echo "Datagrams Sent Per Second: " & _
            objItem.DatagramsSentPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Fragmentation Failures: " & _
            objItem.FragmentationFailures
        Wscript.Echo "Fragmented Datagrams Per Second: " & _
            objItem.FragmentedDatagramsPersec
        Wscript.Echo "Fragment Reassembly Failures: " & _
            objItem.FragmentReassemblyFailures
        Wscript.Echo "Fragments Created Per Second: " & _
            objItem.FragmentsCreatedPersec
        Wscript.Echo "Fragments Reassembled Per Second: " & _
            objItem.FragmentsReassembledPersec
        Wscript.Echo "Fragments Received Per Second: " & _
            objItem.FragmentsReceivedPersec
        Wscript.Echo "Name: " & objItem.Name
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP IPv4 Performance

Description
Uses cooked performance counters to monitor the rates at which IP datagrams are sent and received by using IPv4 protocols.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_IPv4").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Datagrams per second: " & objItem.DatagramsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP IPv6 Performance

Description
Uses cooked performance counters to monitor the rates at which IP datagrams are sent and received by using IPv6 protocols.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_IPv6").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Datagrams per second: " & objItem.DatagramsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP Network Interface Performance

Description
Uses cooked performance counters to monitor the rates at which bytes and packets are sent and received over a TCP/IP network connection.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_NetworkInterface").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Bytes Received Per Second: " & _
        objItem.BytesReceivedPersec
        Wscript.Echo "Bytes Sent Per Second: " & objItem.BytesSentPersec
        Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Current Bandwidth: " & objItem.CurrentBandwidth
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Output Queue Length: " & objItem.OutputQueueLength
        Wscript.Echo "Packets Outbound Discarded: " & _
            objItem.PacketsOutboundDiscarded
        Wscript.Echo "Packets Outbound Errors: " & _
            objItem.PacketsOutboundErrors
        Wscript.Echo "Packets Per Second: " & objItem.PacketsPersec
        Wscript.Echo "Packets Received Discarded: " & _
            objItem.PacketsReceivedDiscarded
        Wscript.Echo "Packets Received Errors: " & _
            objItem.PacketsReceivedErrors
        Wscript.Echo "Packets Received Non-Unicast Per Second: " & _
            objItem.PacketsReceivedNonUnicastPersec
        Wscript.Echo "Packets Received Per Second: " & _
            objItem.PacketsReceivedPersec
        Wscript.Echo "Packets Received Unicast Per Second: " & _
            objItem.PacketsReceivedUnicastPersec
        Wscript.Echo "Packets Received Unknown: " & _
            objItem.PacketsReceivedUnknown
        Wscript.Echo "Packets Sent Non-Unicast Per Second: " & _
            objItem.PacketsSentNonUnicastPersec
        Wscript.Echo "Packets Sent Per Second: " & objItem.PacketsSentPersec
        Wscript.Echo "Packets Sent Unicast Per Second: " & _
            objItem.PacketsSentUnicastPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP TCP Performance

Description
Uses cooked performance counters to monitor the rates at which TCP segments are sent and received by using the TCP protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_TCP").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Connection Failures: " & objItem.ConnectionFailures
        Wscript.Echo "Connections Active: " & objItem.ConnectionsActive
        Wscript.Echo "Connections Established: " & _
            objItem.ConnectionsEstablished
        Wscript.Echo "Connections Passive: " & objItem.ConnectionsPassive
        Wscript.Echo "Connections Reset: " & objItem.ConnectionsReset
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Segments Per Second: " & objItem.SegmentsPersec
        Wscript.Echo "Segments Received Per Second: " & _\
            objItem.SegmentsReceivedPersec
        Wscript.Echo "Segments Retransmitted Per Second: " & _
            objItem.SegmentsRetransmittedPersec
        Wscript.Echo "Segments Sent Per Second: " & _
             objItem.SegmentsSentPersec
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP TCPv4 Performance

Description
Uses cooked performance counters to monitor the rates at which TCP segments are sent and received by using the TCPv4 protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_TCPv4").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Connection failures: " & objItem.ConnectionFailures
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP TCPv6 Performance

Description
Uses cooked performance counters to monitor the rates at which TCP segments are sent and received by using the TCPv6 protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_TCPv6").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Connection failures: " & objItem.ConnectionFailures
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP UDP Performance

Description
Uses cooked performance counters to monitor the rates at which UDP datagrams are sent and received by using the UDP protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_UDP").objectSet
objRefresher.Refresh
For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Datagrams No Port Per Second: " & _
            objItem.DatagramsNoPortPersec
        Wscript.Echo "Datagrams Per Second: " & objItem.DatagramsPersec
        Wscript.Echo "Datagrams Received Errors: " & _
            objItem.DatagramsReceivedErrors
        Wscript.Echo "Datagrams Received Per Second: " & _
            objItem.DatagramsReceivedPersec
        Wscript.Echo "Datagrams Sent Per Second: " & _
            objItem.DatagramsSentPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP UDPv4 Performance

Description
Uses cooked performance counters to monitor the rates at which UDP datagrams are sent and received by using the UDPv4 protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_UDPv4").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Datagrams sent per second: " & _
            objItem.DatagramsSentPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor TCP-IP UDPv6 Performance

Description
Uses cooked performance counters to measure rates at which UDP datagrams are sent and received by using the UDPv6 protocol.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_TCPIP_UDPv6").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Datagrams sent per second: " & _
            objItem.DatagramsSentPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SNMP MIB-II Interface Table Information

Description
Retrieves and displays SNMP MIB-II (RFC 1213) Interface Table information from an SNMP managed node using the WMI SNMP Provider.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strTargetSnmpDevice = "192.168.0.1"

Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"

Set colIfTable = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_ifTable", , _
    objWmiNamedValueSet)

For Each objInterface In colIfTable
    WScript.Echo "ifIndex [Key]:        " & objInterface.ifIndex  & vbCrLf & _
        "   ifAdminStatus:     " & objInterface.ifAdminStatus     & vbCrLf & _
        "   ifDescr:           " & objInterface.ifDescr           & vbCrLf & _
        "   ifInDiscards:      " & objInterface.ifInDiscards      & vbCrLf & _
        "   ifInErrors:        " & objInterface.ifInErrors        & vbCrLf & _
        "   ifInNUcastPkts:    " & objInterface.ifInNUcastPkts    & vbCrLf & _
        "   ifInOctets:        " & objInterface.ifInOctets        & vbCrLf & _
        "   ifInUcastPkts:     " & objInterface.ifInUcastPkts     & vbCrLf & _
        "   ifInUnknownProtos: " & objInterface.ifInUnknownProtos & vbCrLf & _
        "   ifLastChange:      " & objInterface.ifLastChange      & vbCrLf & _
        "   ifMtu:             " & objInterface.ifMtu             & vbCrLf & _
        "   ifOperStatus:      " & objInterface.ifOperStatus      & vbCrLf & _
        "   ifOutDiscards:     " & objInterface.ifOutDiscards     & vbCrLf & _
        "   ifOutErrors:       " & objInterface.ifOutErrors       & vbCrLf & _
        "   ifOutNUcastPkts:   " & objInterface.ifOutNUcastPkts   & vbCrLf & _
        "   ifOutOctets:       " & objInterface.ifOutOctets       & vbCrLf & _
        "   ifOutQLen:         " & objInterface.ifOutQLen         & vbCrLf & _
        "   ifOutUcastPkts:    " & objInterface.ifOutUcastPkts    & vbCrLf & _
        "   ifPhysAddress:     " & objInterface.ifPhysAddress     & vbCrLf & _
        "   ifSpecific:        " & objInterface.ifSpecific        & vbCrLf & _
        "   ifSpeed:           " & objInterface.ifSpeed           & vbCrLf & _
        "   ifType:            " & objInterface.ifType            & vbCrLf
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SNMP MIB-II System Group Information

Description
Retrieves and displays SNMP MIB-II (RFC 1213) System Group information from an SNMP managed node using the WMI SNMP Provider.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strTargetSnmpDevice = "192.168.0.1"

Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"

Set colSystem = objWmiServices.InstancesOf("SNMP_RFC1213_MIB_system", , _
    objWmiNamedValueSet)

For Each objSystem In colSystem
    WScript.Echo "sysContact:  " & objSystem.sysContact  & vbCrLf & _
        "sysDescr:    " & objSystem.sysDescr    & vbCrLf & _
            "sysLocation: " & objSystem.sysLocation & vbCrLf & _
                "sysName:     " & objSystem.sysName     & vbCrLf & _
                    "sysObjectID: " & objSystem.sysObjectID & vbCrLf & _
                        "sysServices: " & objSystem.sysServices & vbCrLf & _
                            "sysUpTime:   " & objSystem.sysUpTime
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SNMP MIB-II TCP and UDP Connections and Listening Ports

Description
Retrieves and displays SNMP MIB-II (RFC 1213) TCP (and UDP) connections and listening ports from an SNMP managed node using the WMI SNMP Provider. Equivalent to running netstat -a -n (which displays all connections and listening ports in numerical form).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strTargetSnmpDevice = "192.168.0.1"

Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", "public"

Set colTcpConnTable = _
    objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpConnTable", , _
        objWmiNamedValueSet)

Set colUdpTable = _
    objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTable", , _
        objWmiNamedValueSet)

WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
    "-----------------------------------"

For Each objTcpConn In colTcpConnTable
    WScript.Echo objTcpConn.tcpConnLocalAddress & ":"    & _
        objTcpConn.tcpConnLocalPort    & " => " & _
            objTcpConn.tcpConnRemAddress   & ":"    & _
                objTcpConn.tcpConnRemPort      & " "    & _
                    "[State: " & objTcpConn.tcpConnState & "]"
Next

WScript.Echo vbCrLf & "UDP Ports" & vbCrLf & "---------"

For Each objUdp In colUdpTable
    WScript.Echo objUdp.udpLocalAddress & ":" & objUdp.UdpLocalPort
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add an Application to the Standard Profile

Description
Adds Freecell.exe to the list of authorized applications in the Windows Firewall standard profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy
Set objProfile = objPolicy.GetProfileByType(1)

Set objApplication = CreateObject("HNetCfg.FwAuthorizedApplication")
objApplication.Name = "Free Cell"
objApplication.IPVersion = 2
objApplication.ProcessImageFileName = "c:\windows\system32\freecell.exe"
objApplication.RemoteAddresses = "*"
objApplication.Scope = 0
objApplication.Enabled = True

Set colApplications = objProfile.AuthorizedApplications
colApplications.Add(objApplication)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add an Authorized Application

Description
Adds Freecell.exe to the list of authorized applications in the current Windows Firewall profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objApplication = CreateObject("HNetCfg.FwAuthorizedApplication")
objApplication.Name = "Free Cell"
objApplication.IPVersion = 2
objApplication.ProcessImageFileName = "c:\windows\system32\freecell.exe"
objApplication.RemoteAddresses = "*"
objApplication.Scope = 0
objApplication.Enabled = True

Set colApplications = objPolicy.AuthorizedApplications
colApplications.Add(objApplication)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a New Port

Description
Opens port 9999 in the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objPort = CreateObject("HNetCfg.FwOpenPort")
objPort.Port = 9999
objPort.Name = "Test Port"
objPort.Enabled = FALSE
Set colPorts = objPolicy.GloballyOpenPorts

errReturn = colPorts.Add(objPort)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Authorized Application

Description
Deletes Freecell.exe from the list of authorized applications in the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colApplications = objPolicy.AuthorizedApplications

errReturn = colApplications.Remove("c:\windows\system32\freecell.exe")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Open Port

Description
Closes port 9999 in the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colPorts = objPolicy.GloballyOpenPorts
errReturn = colPorts.Remove(9999,6)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable Remote Administration

Description
Disable Windows Firewall remote administration.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objAdminSettings = objPolicy.RemoteAdminSettings
objAdminSettings.Enabled = FALSE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable the Firewall

Description
Disables the Windows Firewall for the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = FALSE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable File and Printer Sharing Through Windows Firewall

Description
Enables File and Printer Sharing on a computer running Windows XP Service Pack 2.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.Services
Set objService = colServices.Item(0)
objService.Enabled = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Remote Administration

Description
Enables remote administration of Windows Firewall fro the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objAdminSettings = objPolicy.RemoteAdminSettings
objAdminSettings.Enabled = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable the Firewall

Description
Enables Windows Firewall for the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.FirewallEnabled = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Globally-Open Ports

Description
Lists all globally-open ports for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colPorts = objPolicy.GloballyOpenPorts

For Each objPort in colPorts
    Wscript.Echo "Port name: " & objPort.Name
    Wscript.Echo "Port number: " & objPort.Port
    Wscript.Echo "Port IP version: " & objPort.IPVersion
    Wscript.Echo "Port protocol: " & objPort.Protocol
    Wscript.Echo "Port scope: " & objPort.Scope
    Wscript.Echo "Port remote addresses: " & objPort.RemoteAddresses
    Wscript.Echo "Port enabled: " & objPort.Enabled
    Wscript.Echo "Port built-in: " & objPort.Builtin
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Authorized Applications

Description
Lists all authorized applications for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colApplications = objPolicy.AuthorizedApplications

For Each objApplication in colApplications
    Wscript.Echo "Authorized application: " & objApplication.Name
    Wscript.Echo "Application enabled: " & objApplication.Enabled
    Wscript.Echo "Application IP version: " & objApplication.IPVersion
    Wscript.Echo "Application process image file name: " & _
        objApplication.ProcessImageFileName
    Wscript.Echo "Application remote addresses: " & _
        objApplication.RemoteAddresses
    Wscript.Echo "Application scope: " & objApplication.Scope
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Authorized Applications in the Standard Profile

Description
Lists all authorized applications for the Windows Firewall standard profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy

Set objProfile = objPolicy.GetProfileByType(1)
Set colApplications = objProfile.AuthorizedApplications

For Each objApplication in colApplications
    Wscript.Echo "Authorized application: " & objApplication.Name
    Wscript.Echo "Application enabled: " & objApplication.Enabled
    Wscript.Echo "Application IP version: " & objApplication.IPVersion
    Wscript.Echo "Application process image file name: " & _
        objApplication.ProcessImageFileName
    Wscript.Echo "Application remote addresses: " & _
        objApplication.RemoteAddresses
    Wscript.Echo "Application scope: " & objApplication.Scope
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Firewall Properties

Description
Lists Windows Firewall properties for the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Wscript.Echo "Current profile type: " & objFirewall.CurrentProfileType

Wscript.Echo "Firewall enabled: " & objPolicy.FirewallEnabled
Wscript.Echo "Exceptions not allowed: " & objPolicy.ExceptionsNotAllowed
Wscript.Echo "Notifications disabled: " & objPolicy.NotificationsDisabled
Wscript.Echo "Unicast responses to multicast broadcast disabled: " & _
    objPolicy.UnicastResponsestoMulticastBroadcastDisabled

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Firewall Service Properties

Description
Lists service properties for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set colServices = objPolicy.Services

For Each objService in colServices
    Wscript.Echo "Service name: " & objService.Name
    Wscript.Echo "Service enabled: " & objService.Enabled
    Wscript.Echo "Service type: " & objService.Type
    Wscript.Echo "Service IP version: " & objService.IPVersion
    Wscript.Echo "Service scope: " & objService.Scope
    Wscript.Echo "Service remote addresses: " & objService.RemoteAddresses
    Wscript.Echo "Service customized: " & objService.Customized
    Set colPorts = objService.GloballyOpenPorts
    For Each objPort in colPorts
        Wscript.Echo "Port name: " & objPort.Name
        Wscript.Echo "Port number: " & objPort.Port
        Wscript.Echo "Port enabled: " & objPort.Enabled
        Wscript.Echo "Port built-in: " & objPort.BuiltIn
        Wscript.Echo "Port IP version: " & objPort.IPVersion
        Wscript.Echo "Port protocol: " & objPort.Protocol
        Wscript.Echo "Port remote addresses: " & objPort.RemoteAddresses
        Wscript.Echo "Port scope: " & objPort.Scope
    Next
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List ICMP Settings

Description
Lists ICMP settings for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objICMPSettings = objPolicy.ICMPSettings

Wscript.Echo "Allow inbound echo request: " & _
    objICMPSettings.AllowInboundEchoRequest
Wscript.Echo "Allow inbound mask request: " & _
    objICMPSettings.AllowInboundMaskRequest
Wscript.Echo "Allow inbound router request: " & _
    objICMPSettings.AllowInboundRouterRequest
Wscript.Echo "Allow inbound timestamp request: " & _
    objICMPSettings.AllowInboundTimestampRequest
Wscript.Echo "Allow outbound destination unreachable: " & _
    objICMPSettings.AllowOutboundDestinationUnreachable
Wscript.Echo "Allow outbound packet too big: " & _
    objICMPSettings.AllowOutboundPacketTooBig
Wscript.Echo "Allow outbound parameter problem: " & _
    objICMPSettings.AllowOutboundParameterProblem
Wscript.Echo "Allow outbound source quench: " & _
    objICMPSettings.AllowOutboundSourceQuench
Wscript.Echo "Allow outbound time exceeded: " & _
    objICMPSettings.AllowOutboundTimeExceeded
Wscript.Echo "Allow redirect: " & objICMPSettings.AllowRedirect

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Remote Administration Settings

Description
Lists remote administration settings for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objAdminSettings = objPolicy.RemoteAdminSettings
Wscript.Echo "Remote administration settings enabled: " & _
    objAdminSettings.Enabled
Wscript.Echo "Remote administration addresses: " & _
    objAdminSettings.RemoteAddresses
Wscript.Echo "Remote administration scope: " & objAdminSettings.Scope
Wscript.Echo "Remote administration IP version: " & objAdminSettings.IPVersion

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Standard Profile Properties

Description
Demonstration script that connects to and returns information about the Windows Firewall standard profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy
Set objProfile = objPolicy.GetProfileByType(1)

Wscript.Echo "Firewall enabled: " & objProfile.FirewallEnabled
Wscript.Echo "Exceptions not allowed: " & objProfile.ExceptionsNotAllowed
Wscript.Echo "Notifications disabled: " & objProfile.NotificationsDisabled
Wscript.Echo "Unicast responses to multicast broadcast disabled: " & -
    objProfile.UnicastResponsestoMulticastBroadcastDisabled

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Firewall Property

Description
Demonstration script that modifies Windows Firewall properties for the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

objPolicy.ExceptionsNotAllowed = TRUE
objPolicy.NotificationsDisabled = TRUE
objPolicy.UnicastResponsestoMulticastBroadcastDisabled = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ICMP Setting

Description
Demonstration script that modifies a Windows Firewall ICMP setting for the current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile

Set objICMPSettings = objPolicy.ICMPSettings
objICMPSettings.AllowRedirect = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Open a Closed Port

Description
Opens closed port 9999 for the Windows Firewall current profile.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
Set colPorts = objPolicy.GloballyOpenPorts

Set objPort = colPorts.Item(9999,6)
objPort.Enabled = TRUE

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore the Default Settings

Description
Restore the Windows Firewall default settings.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objFirewall = CreateObject("HNetCfg.FwMgr")
objFirewall.RestoreDefaults()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Classic COM Class Settings

Description
Returns configuration information for the “classic” COM classes installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_ClassicCOMClassSetting")

For Each objItem in colItems
    Wscript.Echo "Application ID: " & objItem.AppID
    Wscript.Echo "Component ID: " & objItem.ComponentId
    Wscript.Echo "Control: " & objItem.Control
    Wscript.Echo "Default Icon: " & objItem.DefaultIcon
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "In-process Server 32: " & objItem.InprocServer32
    Wscript.Echo "Insertable: " & objItem.Insertable
    Wscript.Echo "Java Class: " & objItem.JavaClass
    Wscript.Echo "ProgId: " & objItem.ProgId
    Wscript.Echo "Version Independent ProgId: " & _
        objItem.VersionIndependentProgId
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Classic COM Classes

Description
Retrieves information about all the “classic” COM classes installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ClassicCOMClass")

For Each objItem in colItems
    Wscript.Echo "Component ID: " & objItem.ComponentId
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Component Categories

Description
Retrieves information about the COM class component categories (COM classes that share common functionalities) found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComponentCategory")

For Each objItem in colItems
    Wscript.Echo "Category ID: " & objItem.CategoryId
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DCOM Application Settings

Description
Returns information about the configuration of each DCOM (distributed COM) application installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_DCOMApplicationSetting")

For Each objItem in colItems
    Wscript.Echo "Application ID: " & objItem.AppID
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Enable At Storage Activation: " & _
        objItem.EnableAtStorageActivation
    Wscript.Echo "Local Service: " & objItem.LocalService
    Wscript.Echo "Service Parameters: " & objItem.ServiceParameters
    Wscript.Echo "Use Surrogate: " & objItem.UseSurrogate
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List DCOM Applications

Description
Returns information about all the DCOM (distributed COM) applications installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_DCOMApplication")

For Each objItem in colItems
    Wscript.Echo "Application ID: " & objItem.AppID
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List ProgIDs

Description
Returns a list of ProgIDs (Programmatic Identifiers) found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_ProgIDSpecification")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Check ID: " & objItem.CheckID
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Parent: " & objItem.Parent
    Wscript.Echo "ProgID: " & objItem.ProgID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Local Time on a Computer

Description
Returns information about the local time configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")

For Each objItem in colItems
    Wscript.Echo "Day: " & objItem.Day
    Wscript.Echo "Day of Week: " & objItem.DayOfWeek
    Wscript.Echo "Hour: " & objItem.Hour
    Wscript.Echo "Minute: " & objItem.Minute
    Wscript.Echo "Month: " & objItem.Month
    Wscript.Echo "Quarter: " & objItem.Quarter
    Wscript.Echo "Second: " & objItem.Second
    Wscript.Echo "Week in Month: " & objItem.WeekInMonth
    Wscript.Echo "Year: " & objItem.Year
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Time Zone Offset from Greenwich Mean Time

Description
Determines the difference (in minutes) between the time zone in use on the specified computer and Greenwich Mean Time. The time zone offset can be extremely useful in WMI scripts that need to work with date-time values.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colTimeZone = objWMIService.ExecQuery("Select * from Win32_TimeZone")

For Each objTimeZone in colTimeZone
    Wscript.Echo "Offset: "& objTimeZone.Bias
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Time Zone Information for a Computer

Description
Retrieve information about the time zone configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TimeZone")

For Each objItem in colItems
    Wscript.Echo "Bias: " & objItem.Bias
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Daylight Bias: " & objItem.DaylightBias
    Wscript.Echo "Daylight Day: " & objItem.DaylightDay
    Wscript.Echo "Daylight Day of Week: " & objItem.DaylightDayOfWeek
    Wscript.Echo "Daylight Hour: " & objItem.DaylightHour
    Wscript.Echo "Daylight Millisecond: " & objItem.DaylightMillisecond
    Wscript.Echo "Daylight Minute: " & objItem.DaylightMinute
    Wscript.Echo "Daylight Month: " & objItem.DaylightMonth
    Wscript.Echo "Daylight Name: " & objItem.DaylightName
    Wscript.Echo "Daylight Second: " & objItem.DaylightSecond
    Wscript.Echo "Daylight Year: " & objItem.DaylightYear
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Standard Bias: " & objItem.StandardBias
    Wscript.Echo "Standard Day: " & objItem.StandardDay
    Wscript.Echo "Standard Day of Week: " & objItem.StandardDayOfWeek
    Wscript.Echo "Standard Hour: " & objItem.StandardHour
    Wscript.Echo "Standard Millisecond: " & objItem.StandardMillisecond
    Wscript.Echo "Standard Minute: " & objItem.StandardMinute
    Wscript.Echo "Standard Month: " & objItem.StandardMonth
    Wscript.Echo "Standard Name: " & objItem.StandardName
    Wscript.Echo "Standard Second: " & objItem.StandardSecond
    Wscript.Echo "Standard Year: " & objItem.StandardYear
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Browser Service Performance

Description
Uses cooked performance counters to monitor the rates of announcements, enumerations, and other browser transmissions

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfNet_Browser").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Announcements Domain Per Second: " & _
            objItem.AnnouncementsDomainPersec
        Wscript.Echo "Announcements Server Per Second: " & _
            objItem.AnnouncementsServerPersec
        Wscript.Echo "Announcements Total Per Second: " & _
            objItem.AnnouncementsTotalPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Duplicate Master Announcements: " & _
            objItem.DuplicateMasterAnnouncements
        Wscript.Echo "Election Packets Per Second: " & _
            objItem.ElectionPacketsPersec
        Wscript.Echo "Enumerations Domain Per Second: " & _
            objItem.EnumerationsDomainPersec
        Wscript.Echo "Enumerations Other Per Second: " & _
            objItem.EnumerationsOtherPersec
        Wscript.Echo "Enumerations Server Per Second: " & _
            objItem.EnumerationsServerPersec
        Wscript.Echo "Enumerations Total Per Second: " & _
            objItem.EnumerationsTotalPersec
        Wscript.Echo "Illegal Datagrams Per Second: " & _
            objItem.IllegalDatagramsPersec
        Wscript.Echo "Mailslot Allocations Failed: " & _
            objItem.MailslotAllocationsFailed
        Wscript.Echo "Mailslot Opens Failed Per Second: " & _
            objItem.MailslotOpensFailedPersec
        Wscript.Echo "Mailslot Receives Failed: " & _
            objItem.MailslotReceivesFailed
        Wscript.Echo "Mailslot Writes Failed: " & objItem.MailslotWritesFailed
        Wscript.Echo "Mailslot Writes Per Second: " & _
            objItem.MailslotWritesPersec
        Wscript.Echo "Missed Mailslot Datagrams: " & _
            objItem.MissedMailslotDatagrams
        Wscript.Echo "Missed Server Announcements: " & _
            objItem.MissedServerAnnouncements
        Wscript.Echo "Missed Server List Requests: " & _
            objItem.MissedServerListRequests
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Server Announce Allocations Failed Per Second: " & _
            objItem.ServerAnnounceAllocationsFailedPersec
        Wscript.Echo "Server List Requests Per Second: " & _
            objItem.ServerListRequestsPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Operating System Objects

Description
Uses cooked performance counters to return the count of the objects maintained by the operating system, including events, mutexes, processes, sections, semaphores, and threads.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_Objects").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Events: " & objItem.Events
        Wscript.Echo "Mutexes: " & objItem.Mutexes
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Processes: " & objItem.Processes
        Wscript.Echo "Sections: " & objItem.Sections
        Wscript.Echo "Semaphores: " & objItem.Semaphores
        Wscript.Echo "Threads: " & objItem.Threads
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Operating System Performance

Description
Uses cooked performance counters to monitor counters that apply to more than one instance of a component processors on the computer

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_System").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Alignment Fixups Per Second: " & _
            objItem.AlignmentFixupsPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Context Switches Per Second: " & _
            objItem.ContextSwitchesPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Exception Dispatches Per Second: " & _
            objItem.ExceptionDispatchesPersec
        Wscript.Echo "File Control Bytes Per Second: " & _
            objItem.FileControlBytesPersec
        Wscript.Echo "File Control Operations Per Second: " & _
            objItem.FileControlOperationsPersec
        Wscript.Echo "File Data Operations Per Second: " & _
            objItem.FileDataOperationsPersec
        Wscript.Echo "File Read Bytes Per Second: " & _
            objItem.FileReadBytesPersec
        Wscript.Echo "File Read Operations Per Second: " & _
            objItem.FileReadOperationsPersec
        Wscript.Echo "File Write Bytes Per Second: " & _
            objItem.FileWriteBytesPersec
        Wscript.Echo "File Write Operations Per Second: " & _
            objItem.FileWriteOperationsPersec
        Wscript.Echo "Floating Emulations Per Second: " & _
            objItem.FloatingEmulationsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Registry Quota In Use: " & _
            objItem.PercentRegistryQuotaInUse
        Wscript.Echo "Processes: " & objItem.Processes
        Wscript.Echo "Processor Queue Length: " & _
            objItem.ProcessorQueueLength
        Wscript.Echo "System Calls Per Second: " & _
            objItem.SystemCallsPersec
        Wscript.Echo "System UpTime: " & objItem.SystemUpTime
        Wscript.Echo "Threads: " & objItem.Threads
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Server Performance

Description
Uses cooked performance counters to monitor communications using the WINS Server service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfNet_Server").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Blocking Requests Rejected: " & _
            objItem.BlockingRequestsRejected
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPersec
        Wscript.Echo "Bytes Total Per Second: " & objItem.BytesTotalPersec
        Wscript.Echo "Bytes Transmitted Per Second: " & _
            objItem.BytesTransmittedPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Context Blocks Queued Per Second: " & _
            objItem.ContextBlocksQueuedPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Errors Access Permissions: " & _
            objItem.ErrorsAccessPermissions
        Wscript.Echo "Errors Granted Access: " & _
            objItem.ErrorsGrantedAccess
        Wscript.Echo "Errors Logon: " & objItem.ErrorsLogon
        Wscript.Echo "Errors System: " & objItem.ErrorsSystem
        Wscript.Echo "File Directory Searches: " & _
            objItem.FileDirectorySearches
        Wscript.Echo "Files Open: " & objItem.FilesOpen
        Wscript.Echo "Files Opened Total: " & objItem.FilesOpenedTotal
        Wscript.Echo "Logon Per Second: " & objItem.LogonPersec
        Wscript.Echo "Logon Total: " & objItem.LogonTotal
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Pool Nonpaged Bytes: " & objItem.PoolNonpagedBytes
        Wscript.Echo "Pool Nonpaged Failures: " & _
            objItem.PoolNonpagedFailures
        Wscript.Echo "Pool Nonpaged Peak: " & objItem.PoolNonpagedPeak
        Wscript.Echo "Pool Paged Bytes: " & objItem.PoolPagedBytes
        Wscript.Echo "Pool Paged Failures: " & objItem.PoolPagedFailures
        Wscript.Echo "Pool Paged Peak: " & objItem.PoolPagedPeak
        Wscript.Echo "Server Sessions: " & objItem.ServerSessions
        Wscript.Echo "Sessions Errored Out: " & objItem.SessionsErroredOut
        Wscript.Echo "Sessions Forced Off: " & objItem.SessionsForcedOff
        Wscript.Echo "Sessions Logged Off: " & objItem.SessionsLoggedOff
        Wscript.Echo "Sessions Timed Out: " & objItem.SessionsTimedOut
        Wscript.Echo "Work Item Shortages: " & objItem.WorkItemShortages
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Server Work Queues

Description
Uses cooked performance counters to monitor the length of the queues and objects in the queues

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_PerfNet_ServerWorkQueues").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Active Threads: " & objItem.ActiveThreads
        Wscript.Echo "Available Threads: " & objItem.AvailableThreads
        Wscript.Echo "Available Work Items: " & objItem.AvailableWorkItems
        Wscript.Echo "Borrowed Work Items: " & objItem.BorrowedWorkItems
        Wscript.Echo "Bytes Received Per Second: " & _
            objItem.BytesReceivedPersec
        Wscript.Echo "Bytes Sent Per Second: " & objItem.BytesSentPersec
        Wscript.Echo "Bytes Transferred Per Second: " & _
            objItem.BytesTransferredPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Context Blocks Queued Per Second: " & _
            objItem.ContextBlocksQueuedPersec
        Wscript.Echo "Current Clients: " & objItem.CurrentClients
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Queue Length: " & objItem.QueueLength
        Wscript.Echo "Read Bytes Per Second: " & objItem.ReadBytesPersec
        Wscript.Echo "Read Operations Per Second: " & _
            objItem.ReadOperationsPersec
        Wscript.Echo "Total Bytes Per Second: " & objItem.TotalBytesPersec
        Wscript.Echo "Total Operations Per Second: " & _
            objItem.TotalOperationsPersec
        Wscript.Echo "Work Item Shortages: " & objItem.WorkItemShortages
        Wscript.Echo "Write Bytes Per Second: " & objItem.WriteBytesPersec
        Wscript.Echo "Write Operations Per Second: " & _
            objItem.WriteOperationsPersec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Exceptions Performance

Description
Uses cooked performance counters to monitor CLR exceptions performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, " & _
    "Win32_PerfFormattedData_NETFramework_NETCLRExceptions").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Exceptions thrown: " & objItem.NumberOfExcepsThrown
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Interop Performance

Description
Uses cooked performance counters to monitor CLR interop performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_NETFramework_NETCLRInterop").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Number of stubs: " & objItem.NumberOfStubs
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR JIT Performance

Description
Uses cooked performance counters to monitor CLR JIT performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_NETFramework_NETCLRJit").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Percent time in JIT: " & objItem.PercentTimeInJIT
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Locks and Threads Performance

Description
Uses cooked performance counters to monitor CLR locks and threads performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_NETFramework_NETCLRLocksAndThreads").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Current queue length: " & objItem.CurrentQueueLength
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Memory Performance

Description
Uses cooked performance counters to monitor CLR memory performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_NETFramework_NETCLRMemory").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Total bytes committed: " & _
            objItem.NumberTotalCommittedBytes
    Wscript.Sleep 2000
    objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Remoting Performance

Description
Uses cooked performance counters to monitor CLR remoting performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_NETFRamework_NETCLRRemoting").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Remote calls per second: " & _
            objItem.RemoteCallsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NET Framework NETCLR Security Performance

Description
Uses cooked performance counters to monitor CLR security performance on a computer running .NET Frameworks 1.1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_NETFramework_NETCLRSecurity").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Total runtime checks: " & objItem.TotalRuntimeChecks
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Page File Performance

Description
Uses cooked performance counters to return page file performance information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_PagingFile").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Usage: " & objItem.PercentUsage
        Wscript.Echo "Percent Usage Peak: " & objItem.PercentUsagePeak
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Page File Properties

Description
Lists the properties of all the page files on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PageFile")

For Each objPageFile in colPageFiles
    Wscript.Echo "Creation Date: " & objPageFile.CreationDate
    Wscript.Echo "Description: " & objPageFile.Description
    Wscript.Echo "Drive: " & objPageFile.Drive
    Wscript.Echo "File Name: " & objPageFile.FileName
    Wscript.Echo "File Size: " & objPageFile.FileSize
    Wscript.Echo "Initial Size: " & objPageFile.InitialSize
    Wscript.Echo "Install Date: " & objPageFile.InstallDate
    Wscript.Echo "Maximum Size: " & objPageFile.MaximumSize
    Wscript.Echo "Name: " & objPageFile.Name
    Wscript.Echo "Path: " & objPageFile.Path
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Page File Use

Description
Retrieves page file usage statistics.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PageFileUsage")

For Each objPageFile in colPageFiles
    Wscript.Echo "Allocated Base Size: " & objPageFile.AllocatedBaseSize
    Wscript.Echo "Current Usage: " & objPageFile.CurrentUsage
    Wscript.Echo "Description: " & objPageFile.Description
    Wscript.Echo "Install Date: " & objPageFile.InstallDate
    Wscript.Echo "Name: " & objPageFile.Name
    Wscript.Echo "Peak Usage: " & objPageFile.PeakUsage
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Page File Properties

Description
Sets the initial size of a page file to 300 megabytes, and the maximum size to 600 megabytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery _
    ("Select * from Win32_PageFileSetting")

For Each objPageFile in colPageFiles
    objPageFile.InitialSize = 300
    objPageFile.MaximumSize = 600
    objPageFile.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Job Object Details Performance

Description
Uses cooked performance counters to return detailed performance information about the processes that make up a job object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_PerfProc_JobObjectDetails").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Creating Process ID: " & objItem.CreatingProcessID
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Elapsed Time: " & objItem.ElapsedTime
        Wscript.Echo "Handle Count: " & objItem.HandleCount
        Wscript.Echo "ID Process: " & objItem.IDProcess
        Wscript.Echo "I/O Data Bytes Per Second: " & objItem.IODataBytesPersec
        Wscript.Echo "I/O Data Operations Per Second: " & _
            objItem.IODataOperationsPersec
        Wscript.Echo "I/O Other Bytes Per Second: " & _
            objItem.IOOtherBytesPersec
        Wscript.Echo "I/O Other Operations Per Second: " & _
            objItem.IOOtherOperationsPersec
        Wscript.Echo "I/O Read Bytes Per Second: " & objItem.IOReadBytesPersec
        Wscript.Echo "I/O Read Operations Per Second: " & _
            objItem.IOReadOperationsPersec
        Wscript.Echo "I/O Write Bytes Per Second: " & _
            objItem.IOWriteBytesPersec
        Wscript.Echo "I/O Write Operations Per Second: " & _
            objItem.IOWriteOperationsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Page Faults Per Second: " & objItem.PageFaultsPersec
        Wscript.Echo "Page File Bytes: " & objItem.PageFileBytes
        Wscript.Echo "Page File Bytes Peak: " & objItem.PageFileBytesPeak
        Wscript.Echo "Percent Privileged Time: " & _
            objItem.PercentPrivilegedTime
        Wscript.Echo "Percent Processor Time: " & objItem.PercentProcessorTime
        Wscript.Echo "Percent User Time: " & objItem.PercentUserTime
        Wscript.Echo "Pool Nonpaged Bytes: " & objItem.PoolNonpagedBytes
        Wscript.Echo "Pool Paged Bytes: " & objItem.PoolPagedBytes
        Wscript.Echo "Priority Base: " & objItem.PriorityBase
        Wscript.Echo "Private Bytes: " & objItem.PrivateBytes
        Wscript.Echo "Thread Count: " & objItem.ThreadCount
        Wscript.Echo "Virtual Bytes: " & objItem.VirtualBytes
        Wscript.Echo "Virtual Bytes Peak: " & objItem.VirtualBytesPeak
        Wscript.Echo "Working Set: " & objItem.WorkingSet
        Wscript.Echo "Working Set Peak: " & objItem.WorkingSetPeak
        Wscript.Sleep 2000
    objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Job Object Performance

Description
Uses cooked performance counters to return information about accounting and processor usage data collected by each active named job object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfProc_JobObject").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Current Percent Kernel Mode Time: " & _
            objItem.CurrentPercentKernelModeTime
        Wscript.Echo "Current Percent Processor Time: " & _
            objItem.CurrentPercentProcessorTime
        Wscript.Echo "Current Percent User Mode Time: " & _\
            objItem.CurrentPercentUserModeTime
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Pages Per Second: " & objItem.PagesPerSec
        Wscript.Echo "Process Count Active: " & objItem.ProcessCountActive
        Wscript.Echo "Process Count Terminated: " & _
            objItem.ProcessCountTerminated
        Wscript.Echo "Process Count Total: " & objItem.ProcessCountTotal
        Wscript.Echo "This Period Milliseconds Kernel Mode: " & _
            objItem.ThisPeriodmSecKernelMode
        Wscript.Echo "This Period Milliseconds Processor: " & _
            objItem.ThisPeriodmSecProcessor
        Wscript.Echo "This Period Milliseconds User Mode: " & _
            objItem.ThisPeriodmSecUserMode
        Wscript.Echo "Total Milliseconds Kernel Mode: " & _
            objItem.TotalmSecKernelMode
        Wscript.Echo "Total Milliseconds Processor: " & _
            objItem.TotalmSecProcessor
        Wscript.Echo "Total Milliseconds User Mode: " & _
            objItem.TotalmSecUserMode
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Address Space Performance -- Costly

Description
Uses cooked performance counters to return information about memory allocation and use for a selected process

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_PerfProc_ProcessAddressSpace_Costly").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Bytes Free: " & objItem.BytesFree
        Wscript.Echo "Bytes Image Free: " & objItem.BytesImageFree
        Wscript.Echo "Bytes Image Reserved: " & objItem.BytesImageReserved
        Wscript.Echo "Bytes Reserved: " & objItem.BytesReserved
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "ID Process: " & objItem.IDProcess
        Wscript.Echo "Image Space Exec Read-Only: " & _
            objItem.ImageSpaceExecReadOnly
        Wscript.Echo "Image Space Exec Read Per Write: " & _
            objItem.ImageSpaceExecReadPerWrite
        Wscript.Echo "Image Space Executable: " & objItem.ImageSpaceExecutable
        Wscript.Echo "Image Space Exec Write Copy: " & _
            objItem.ImageSpaceExecWriteCopy
        Wscript.Echo "Image Space NoA ccess: " & objItem.ImageSpaceNoAccess
        Wscript.Echo "Image Space Read-Only: " & objItem.ImageSpaceReadOnly
        Wscript.Echo "Image Space Read Per Write: " & _
            objItem.ImageSpaceReadPerWrite
        Wscript.Echo "Image Space Write Copy: " & objItem.ImageSpaceWriteCopy
        Wscript.Echo "Mapped Space Exec Read-Only: " & _
            objItem.MappedSpaceExecReadOnly
        Wscript.Echo "Mapped Space Exec Read Per Write: " & _
            objItem.MappedSpaceExecReadPerWrite
        Wscript.Echo "Mapped Space Executable: " & _
            objItem.MappedSpaceExecutable
        Wscript.Echo "Mapped Space Exec Write Copy: " & _
            objItem.MappedSpaceExecWriteCopy
        Wscript.Echo "Mapped Space No Access: " & objItem.MappedSpaceNoAccess
        Wscript.Echo "Mapped Space Read Only: " & objItem.MappedSpaceReadOnly
        Wscript.Echo "Mapped Space Read Per Write: " & _
            objItem.MappedSpaceReadPerWrite
        Wscript.Echo "Mapped Space Write Copy: " & objItem.MappedSpaceWriteCopy
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Reserved Space Exec Read-Only: " & _
            objItem.ReservedSpaceExecReadOnly
        Wscript.Echo "Reserved Space Exec Read Per Write: " & _
            objItem.ReservedSpaceExecReadPerWrite
        Wscript.Echo "Reserved Space Executable: " & _
            objItem.ReservedSpaceExecutable
        Wscript.Echo "Reserved Space Exec Write Copy: " & _
            objItem.ReservedSpaceExecWriteCopy
        Wscript.Echo "Reserved Space No Access: " & _
            objItem.ReservedSpaceNoAccess
        Wscript.Echo "Reserved Space Read-Only: " & _
            objItem.ReservedSpaceReadOnly
        Wscript.Echo "Reserved Space Read Per Write: " & _
            objItem.ReservedSpaceReadPerWrite
        Wscript.Echo "Reserved Space Write Copy: " & _
            objItem.ReservedSpaceWriteCopy
        Wscript.Echo "Unassigned Space Exec Read-Only: " & _
            objItem.UnassignedSpaceExecReadOnly
        Wscript.Echo "Unassigned Space Exec Read Per Write: " & _
            objItem.UnassignedSpaceExecReadPerWrite
        Wscript.Echo "Unassigned Space Executable: " & _
            objItem.UnassignedSpaceExecutable
        Wscript.Echo "Unassigned Space Exec Write Copy: " & _
            objItem.UnassignedSpaceExecWriteCopy
        Wscript.Echo "Unassigned Space No Access: " & _
            objItem.UnassignedSpaceNoAccess
        Wscript.Echo "Unassigned Space Read-Only: " & _
            objItem.UnassignedSpaceReadOnly
        Wscript.Echo "Unassigned Space Read Per Write: " & _
            objItem.UnassignedSpaceReadPerWrite
        Wscript.Echo "Unassigned Space Write Copy: " & _
        objItem.UnassignedSpaceWriteCopy
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Creation

Description
Temporary event consumer that issues an alert each time a new process is created.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
    ExecNotificationQuery("select * from __instancecreationevent " _
        & " within 1 where TargetInstance isa 'Win32_Process'")
i = 0

Do While i = 0
    Set objLatestProcess = colMonitoredProcesses.NextEvent
    Wscript.Echo objLatestProcess.TargetInstance.Name
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Deletion

Description
Temporary event consumer that issues an alert each time a process terminates.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
    ExecNotificationQuery("select * from __instancedeletionevent " _
            & "within 1 where TargetInstance isa 'Win32_Process'")
i = 0

Do While i = 0
    Set objLatestProcess = colMonitoredProcesses.NextEvent
    Wscript.Echo objLatestProcess.TargetInstance.Name
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Full Image Performance -- Costly

Description
Uses cooked performance counters to return information about the virtual address usage of images executed by computer processes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_PerfProc_FullImage_Costly").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Exec Read-Only: " & objItem.ExecReadOnly
        Wscript.Echo "Exec Read Per Write: " & objItem.ExecReadPerWrite
        Wscript.Echo "Executable: " & objItem.Executable
        Wscript.Echo "Exec Write Copy: " & objItem.ExecWriteCopy
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "No Access: " & objItem.NoAccess
        Wscript.Echo "Read-Only: " & objItem.ReadOnly
        Wscript.Echo "Read Per Write: " & objItem.ReadPerWrite
        Wscript.Echo "Write Copy: " & objItem.WriteCopy
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Image Performance -- Costly

Description
Uses cooked performance counters to return information about the virtual address usage of images executed by computer processes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfProc_Image_Costly").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Exec Read-Only: " & objItem.ExecReadOnly
        Wscript.Echo "Exec Read Per Write: " & objItem.ExecReadPerWrite
        Wscript.Echo "Executable: " & objItem.Executable
        Wscript.Echo "Exec Write Copy: " & objItem.ExecWriteCopy
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "No Access: " & objItem.NoAccess
        Wscript.Echo "Read-Only: " & objItem.ReadOnly
        Wscript.Echo "Read Per Write: " & objItem.ReadPerWrite
        Wscript.Echo "Write Copy: " & objItem.WriteCopy
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Performance

Description
Reports statistics such as thread count and working set size for all the processes running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcessList
    Wscript.Echo "Process: " & objProcess.Name
    Wscript.Echo "Process ID: " & objProcess.ProcessID
    Wscript.Echo "Thread Count: " & objProcess.ThreadCount
    Wscript.Echo "Page File Size: " & objProcess.PageFileUsage
    Wscript.Echo "Page Faults: " & objProcess.PageFaults
    Wscript.Echo "Working Set Size: " & objProcess.WorkingSetSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Process Performance

Description
Uses cooked performance counters to return information about running application program and system processes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfProc_Process").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Creating Process ID: " & objItem.CreatingProcessID
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Elapsed Time: " & objItem.ElapsedTime
        Wscript.Echo "Handle Count: " & objItem.HandleCount
        Wscript.Echo "ID Process: " & objItem.IDProcess
        Wscript.Echo "I/O Data Bytes Per Second: " & _
            objItem.IODataBytesPersec
        Wscript.Echo "I/O Data Operations Per Second: " & _
            objItem.IODataOperationsPersec
        Wscript.Echo "I/O Other Bytes Per Second: " & _
            objItem.IOOtherBytesPersec
        Wscript.Echo "I/O Other Operations Per Second: " & _
            objItem.IOOtherOperationsPersec
        Wscript.Echo "I/O Read Bytes Per Second: " & _
            objItem.IOReadBytesPersec
        Wscript.Echo "I/O Read Operations Per Second: " & _
            objItem.IOReadOperationsPersec
        Wscript.Echo "I/O Write Bytes Per Second: " & _
            objItem.IOWriteBytesPersec
        Wscript.Echo "I/O Write Operations Per Second: " & _
            objItem.IOWriteOperationsPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Page Faults Per Second: " & objItem.PageFaultsPersec
        Wscript.Echo "Page File Bytes: " & objItem.PageFileBytes
        Wscript.Echo "Page File Bytes Peak: " & objItem.PageFileBytesPeak
        Wscript.Echo "Percent Privileged Time: " & _
            objItem.PercentPrivilegedTime
        Wscript.Echo "Percent Processor Time: " & _
            objItem.PercentProcessorTime
        Wscript.Echo "Percent User Time: " & objItem.PercentUserTime
        Wscript.Echo "Pool Nonpaged Bytes: " & objItem.PoolNonpagedBytes
        Wscript.Echo "Pool Paged Bytes: " & objItem.PoolPagedBytes
        Wscript.Echo "Priority Base: " & objItem.PriorityBase
        Wscript.Echo "Private Bytes: " & objItem.PrivateBytes
        Wscript.Echo "Thread Count: " & objItem.ThreadCount
        Wscript.Echo "Virtual Bytes: " & objItem.VirtualBytes
        Wscript.Echo "Virtual Bytes Peak: " & objItem.VirtualBytesPeak
        Wscript.Echo "Working Set: " & objItem.WorkingSet
        Wscript.Echo "Working Set Peak: " & objItem.WorkingSetPeak
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Processor Use by Process

Description
Reports processor use time, in seconds, for each process running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcesses
    sngProcessTime = (CSng(objProcess.KernelModeTime) + _
            CSng(objProcess.UserModeTime)) / 10000000
    Wscript.Echo objProcess.name & VbTab & sngProcessTime
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Thread Details Performance -- Costly

Description
Uses cooked performance counters to return information about thread behavior that are difficult or time-consuming to collect.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_PerfProc_ThreadDetails_Costly").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "User PC: " & objItem.UserPC
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Thread Performance

Description
Uses cooked performance counters to return information about thread behavior.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfProc_Thread").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Context Switches Per Second: " & _
            objItem.ContextSwitchesPersec
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Elapsed Time: " & objItem.ElapsedTime
        Wscript.Echo "ID Process: " & objItem.IDProcess
        Wscript.Echo "ID Thread: " & objItem.IDThread
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Privileged Time: " & _
            objItem.PercentPrivilegedTime
        Wscript.Echo "Percent Processor Time: " & objItem.PercentProcessorTime
        Wscript.Echo "Percent User Time: " & objItem.PercentUserTime
        Wscript.Echo "Priority Base: " & objItem.PriorityBase
        Wscript.Echo "Priority Current: " & objItem.PriorityCurrent
        Wscript.Echo "Start Address: " & objItem.StartAddress
        Wscript.Echo "Thread State: " & objItem.ThreadState
        Wscript.Echo "Thread Wait Reason: " & objItem.ThreadWaitReason
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Process Availability

Description
Identifies whether or not a hypothetical process Database.exe is running.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Database.exe'")

If colProcesses.Count = 0 Then
    Wscript.Echo "Database.exe is not running."
Else
    Wscript.Echo "Database.exe is running."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Higher Priority Process

Description
Starts Notepad.exe with an Above Normal priority.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ABOVE_NORMAL = 32768

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")

Set objConfig = objStartup.SpawnInstance_
objConfig.PriorityClass = ABOVE_NORMAL
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
objProcess.Create "Notepad.exe", Null, objConfig, intProcessID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Process in a Hidden Window

Description
Starts Notepad.exe on the local computer, but in a hidden window.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HIDDEN_WINDOW = 12

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")

Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("Notepad.exe", null, objConfig, intProcessID)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Process on a Remote Computer

Description
Starts Notepad.exe on a remote computer. On Windows XP and Windows Server 2003, Notepad will run in a hidden window.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "webserver"
Set objWMIService = GetObject _
    ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("notepad.exe", null, null, intProcessID)

If Error = 0 Then
    Wscript.Echo "Notepad was started with a process ID of " _
         & intProcessID & "."
Else
    Wscript.Echo "Notepad could not be started due to error " & _
        Error & "."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Process Owners

Description
Reports the account name under which each process on a computer is running.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process")

For Each objProcess in colProcessList
    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
    Wscript.Echo "Process " & objProcess.Name & " is owned by " _
        & strUserDomain & "\" & strNameOfUser & "."
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Scripts Running on a Computer

Description
Lists the file names of all Windows Script Host scripts currently running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_Process WHERE Name = " & _
        "'Wscript.exe' OR Name = 'Cscript.exe'")

If colProcesses.Count = 0 Then
    Wscript.Echo "No scripts are running."
Else
    For Each objProcess in colProcesses
        Wscript.Echo objProcess.CommandLine
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Priority Of a Running Process

Description
Changes the priority of a running instance of Notepad.exe from Normal to Above Normal.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ABOVE_NORMAL = 32768

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Notepad.exe'")

For Each objProcess in colProcesses
    objProcess.SetPriority(ABOVE_NORMAL)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Threads

Description
Returns a list of threads and thread states for each process running on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")

For each objProcess in colProcesses
    objDictionary.Add objProcess.ProcessID, objProcess.Name
Next

Set colThreads = objWMIService.ExecQuery _
    ("Select * from Win32_Thread")
For each objThread in colThreads
    intProcessID = CInt(objThread.ProcessHandle)
    strProcessName = objDictionary.Item(intProcessID)
    Wscript.Echo strProcessName & VbTab & objThread.ProcessHandle & _
        VbTab & objThread.Handle & VbTab & objThread.ThreadState
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Prevent a Process from Running

Description
Temporary event consumer that terminates any new instances of Notepad.exe as soon as those new instances are created.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colMonitoredProcesses = objWMIService. _
    ExecNotificationQuery("select * from __instancecreationevent " _
        & " within 1 where TargetInstance isa 'Win32_Process'")
i = 0

Do While i = 0
    Set objLatestProcess = colMonitoredProcesses.NextEvent
    If objLatestProcess.TargetInstance.Name = "notepad.exe" Then
        objLatestProcess.TargetInstance.Terminate
    End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Terminate a Process

Description
Terminates any running instances of Notepad.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Notepad.exe'")

For Each objProcess in colProcessList
    objProcess.Terminate()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a MultiString Value

Description
Uses WMI to create a multi-string registry value in the HKLM\SOFTWARE\System Admin Scripting Guide portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strValueName = "Multi String Value Name"
arrStringValues = Array("first string", "second string", _
    "third string", "fourth string")

oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,arrStringValues

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Registry Key

Description
Uses WMI to create a registry key in the HKLM\SOFTWARE\System Admin Scripting Guide portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create Expanded String Values

Description
Uses WMI to create an expanded string value under the HKLM\SOFTWARE\System Admin Scripting Guide portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strValueName = "Expanded String Value Name"
strValue = "%PATHEXT%"

oReg.SetExpandedStringValue _
    HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create String and DWORD Values

Description
Uses WMI to create string and DWORD values under the HKLM\SOFTWARE\System Admin Scripting Guide portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strValueName = "String Value Name"
strValue = "string value"
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

strValueName = "DWORD Value Name"
dwValue = 82
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Registry Key

Description
Uses WMI to delete the registry key HKLM\SOFTWARE\System Admin Scripting Guide.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"

oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Registry Values

Description
Uses WMI to delete all the registry values under HKLM\SOFTWARE\System Admin Scripting Guide.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\System Admin Scripting Guide"
strDWORDValueName = "DWORD Value Name"
strExpandedStringValueName = "Expanded String Value Name"
strMultiStringValueName = "Multi String Value Name"
strStringValueName = "String Value Name"

oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strDWORDValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strExpandedStringValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strMultiStringValueName
oReg.DeleteValue HKEY_LOCAL_MACHINE,strKeyPath,strStringValueName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Registry Files

Description
Uses WMI to list all the registry file and locations under HKLM\System\CurrentControlSet\Control\Hivelist.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
strKeyPath = "System\CurrentControlSet\Control\hivelist"
oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath,_
    arrValueNames, arrValueTypes

For i=0 To UBound(arrValueNames)
    StdOut.WriteLine "File Name: " & arrValueNames(i) & " -- "
    oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
        arrValueNames(i),strValue
    Wscript.Echo "Location: " & strValue
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Registry Key Access Rights

Description
Uses WMI to check access rights for the logged on user to the HKLM\SYSTEM\CurrentControlSet portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const KEY_QUERY_VALUE = &H0001
Const KEY_SET_VALUE = &H0002
Const KEY_CREATE_SUB_KEY = &H0004
Const DELETE = &H00010000

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet"

oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Query Value Access Rights on Key"
Else
    Wscript.Echo "Do Not Have Query Value Access Rights on Key"
End If

oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_SET_VALUE, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Set Value Access Rights on Key"
Else
    Wscript.Echo "Do Not Have Set Value Access Rights on Key"
End If

oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_CREATE_SUB_KEY, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Create SubKey Access Rights on Key"
Else
    StdOut.WriteLine "Do Not Have Create SubKey Access Rights on Key"
End If

oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, DELETE, bHasAccessRight
If bHasAccessRight = True Then
    StdOut.WriteLine "Have Delete Access Rights on Key"
Else
    StdOut.WriteLine "Do Not Have Delete Access Rights on Key"
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Registry Properties

Description
Returns information about the computer registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Registry")

For Each objItem in colItems
    Wscript.Echo "Current Size: " & objItem.CurrentSize
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Install Date: " & objItem.InstallDate
    Wscript.Echo "Maximum Size: " & objItem.MaximumSize
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Proposed Size: " & objItem.ProposedSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Registry Subkeys

Description
Uses WMI to enumerate all the registry subkeys under HKLM\SYSTEM\CurrentControlSet\Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Services"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys
    Wscript.Echo subkey
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Registry Values and Types

Description
Uses WMI to list all the registry values and their types under HKLM\SYSTEM\CurrentControlSet\Control\Lsa.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Control\Lsa"

oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, _
    arrValueNames, arrValueTypes

For i=0 To UBound(arrValueNames)
    Wscript.Echo "Value Name: " & arrValueNames(i)

    Select Case arrValueTypes(i)
        Case REG_SZ
            Wscript.Echo "Data Type: String"
            Wscript.Echo
        Case REG_EXPAND_SZ
            Wscript.Echo "Data Type: Expanded String"
            Wscript.Echo
        Case REG_BINARY
            Wscript.Echo "Data Type: Binary"
            Wscript.Echo
        Case REG_DWORD
            Wscript.Echo "Data Type: DWORD"
            Wscript.Echo
        Case REG_MULTI_SZ
            Wscript.Echo "Data Type: Multi String"
            Wscript.Echo
    End Select
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Registry Entry Level Events

Description
Temporary event consumer that monitors the registry for any changes to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set wmiServices = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set wmiSink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")

wmiServices.ExecNotificationQueryAsync wmiSink, _
    "SELECT * FROM RegistryValueChangeEvent WHERE " & _
        "Hive='HKEY_LOCAL_MACHINE' AND " & _
            "KeyPath='SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'" _
                & " AND ValueName='CSDVersion'"

WScript.Echo "Listening for Registry Change Events..." & vbCrLf

While(1)
    WScript.Sleep 1000
Wend

Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
    WScript.Echo "Received Registry Change Event" & vbCrLf & _
        wmiObject.GetObjectText_()
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Registry Subkey Events

Description
Temporary event consumer that monitors the registry for any changes to HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set wmiServices = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set wmiSink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")

wmiServices.ExecNotificationQueryAsync wmiSink, _
    "SELECT * FROM RegistryKeyChangeEvent WHERE Hive='HKEY_LOCAL_MACHINE' " & _
        "AND KeyPath='SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'"

WScript.Echo "Listening for Registry Change Events..." & vbCrLf

While(1)
    WScript.Sleep 1000
Wend

Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
    WScript.Echo "Received Registry Change Event" & vbCrLf & _
        wmiObject.GetObjectText_()
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Registry Subtree Events

Description
Temporary event consumer that monitors the registry for any changes to the HKLM portion of the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set wmiServices = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set wmiSink = WScript.CreateObject("WbemScripting.SWbemSink", "SINK_")

wmiServices.ExecNotificationQueryAsync wmiSink, _
    "SELECT * FROM RegistryTreeChangeEvent WHERE Hive= " _
        & "'HKEY_LOCAL_MACHINE' AND RootPath=''"

WScript.Echo "Listening for Registry Change Events..." & vbCrLf

While(1)
    WScript.Sleep 1000
Wend

Sub SINK_OnObjectReady(wmiObject, wmiAsyncContext)
    WScript.Echo "Received Registry Change Event" & vbCrLf & _
        wmiObject.GetObjectText_()
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Binary Registry Value

Description
Uses WMI to read a binary registry value.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set StdOut = WScript.StdOut

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "LicenseInfo"
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,strValue

For i = lBound(strValue) to uBound(strValue)
    StdOut.WriteLine  strValue(i)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a MultiString Value

Description
Uses WMI to read a multi-string registry value.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Services\Eventlog\System"
strValueName = "Sources"
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,arrValues

For Each strValue In arrValues
    Wscript.Echo  strValue
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read an Expanded String Registry Value

Description
Uses WMI to read an expanded string registry value.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon"
strValueName = "UIHost"
oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE,strKeyPath, _
    strValueName,strValue

Wscript.Echo  "The Windows logon UI host is: " & strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read String and DWORD Registry Values

Description
Uses WMI to read a string and a DWORD registry value.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "Console"
strValueName = "HistoryBufferSize"
oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
Wscript.Echo "Current History Buffer Size: " & dwValue

strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings"
strValueName = "TrustPolicy"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo "Current WSH Trust Policy Value: " & strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Service

Description
Removes a hypothetical service named DbService.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where Name = 'DbService'")

For Each objService in colListOfServices
    objService.StopService()
    objService.Delete()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install a Service

Description
Installs a hypothetical service named Db.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const OWN_PROCESS = 16
Const NOT_INTERACTIVE = False
Const NORMAL_ERROR_CONTROL = 2

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objService = objWMIService.Get("Win32_BaseService")

errReturn = objService.Create("DbService" ,"Personnel Database" , _
    "c:\windows\system32\db.exe", OWN_PROCESS, NORMAL_ERROR_CONTROL,_
        "Manual", NOT_INTERACTIVE, "NT AUTHORITY\LocalService", ""  )

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Antecedent Services for a Single Service

Description
Lists all the services that must be running before the SMTP service can be started.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery("Associators of " _
     & "{Win32_service.Name='SMTPSVC'} Where " _
         & "AssocClass=Win32_DependentService " & "Role=Dependent")

For Each objService in colServiceList
    Wscript.Echo objService.DisplayName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Dependent Services for a Single Service

Description
Enumerates all the services that cannot start until the Rasman service has started.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery("Associators of " _
    & "{Win32_Service.Name='rasman'} Where " _
        & "AssocClass=Win32_DependentService " & "Role=Antecedent" )

For Each objService in colServiceList
    Wscript.Echo objService.DisplayName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Dependent Services for All Services

Description
Enumerates dependent services for all the services installed on a computer and writes that information to a text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = _
     objFSO.OpenTextFile("c:\scripts\service_dependencies.csv", _
         ForAppending, True)
objLogFile.Write("Service Dependencies")
objLogFile.Writeline

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service")

For Each objService in colListofServices
    objServiceRegistryName = objService.Name
    objServiceDisplayName = objService.DisplayName

Set colServiceList = objWMIService.ExecQuery("Associators of " _
   & "{Win32_Service.Name='" & objServiceRegistryName & "'} Where AssocClass=Win32_DependentService Role=Antecedent" )

 If colServiceList.Count = 0 then
        objLogFile.Write(objServiceDisplayName) & ", None"
        objLogFile.Writeline
    Else
        For Each objDependentService in colServiceList
            objLogFile.Write(objServiceDisplayName) & ","
            objLogFile.Write(objDependentService.DisplayName)
        Next
        objLogFile.WriteLine
    End If
Next
objLogFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Inactive Services

Description
Returns a list of all the services installed on a computer that are currently stopped.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & _
    "{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2")

Set colStoppedServices = objWMIService.ExecQuery _
    ("Select * From Win32_Service Where State <> 'Running'")

For Each objService in colStoppedServices
    Wscript.Echo objService.DisplayName  & " = " & objService.State
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Load Order Groups

Description
Returns a list of all the service load order groups found on a computer, and well as their load order.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_LoadOrderGroup")

For Each objItem in colItems
    Wscript.Echo "Driver Enabled: " & objItem.DriverEnabled
    Wscript.Echo "Group Order: " & objItem.GroupOrder
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Properties

Description
Retrieves a complete list of services and their associated properties. Information is saved to a text file: C:\Scripts\Service_List.cs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("c:\scripts\service_list.csv", _
    ForAppending, True)

objLogFile.Write _
    ("System Name,Service Name,Service Type,Service State, Exit " _
        & "Code,Process ID,Can Be Paused,Can Be Stopped,Caption," _
        & "Description,Can Interact with Desktop,Display Name,Error " _
        & "Control, Executable Path Name,Service Started," _
        & "Start Mode,Account Name ")
objLogFile.Writeline

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
        ("Select * from Win32_Service")

For Each objService in colListOfServices
    objLogFile.Write(objService.SystemName) & ","
    objLogFile.Write(objService.Name) & ","
    objLogFile.Write(objService.ServiceType) & ","
    objLogFile.Write(objService.State) & ","
    objLogFile.Write(objService.ExitCode) & ","
    objLogFile.Write(objService.ProcessID) & ","
    objLogFile.Write(objService.AcceptPause) & ","
    objLogFile.Write(objService.AcceptStop) & ","
    objLogFile.Write(objService.Caption) & ","
    objLogFile.Write(objService.Description) & ","
    objLogFile.Write(objService.DesktopInteract) & ","
    objLogFile.Write(objService.DisplayName) & ","
    objLogFile.Write(objService.ErrorControl) & ","
    objLogFile.Write(objService.PathName) & ","
    objLogFile.Write(objService.Started) & ","
    objLogFile.Write(objService.StartMode) & ","
    objLogFile.Write(objService.StartName) & ","
    objLogFile.writeline
Next
objLogFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Status

Description
Returns a list of all the services installed on a computer, and indicates their current status (typically, running or not running).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRunningServices = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colRunningServices
    Wscript.Echo objService.DisplayName  & VbTab & objService.State
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Status Changes as recorded in the System Event Log

Description
Retrieves events from the System event log that have an event ID of 7036. These events are recorded any time a service changes status.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceEvents = objWMIService.ExecQuery _
    ("Select * from Win32_NTLogEvent Where Logfile = 'System' and " _
        & "EventCode = '7036'")

For Each strEvent in colServiceEvents
    dtmConvertedDate.Value = strEvent.TimeWritten
    Wscript.Echo dtmConvertedDate.GetVarDate
    Wscript.Echo strEvent.Message
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Services Running in a Process

Description
Returns a list of services running in the Services.exe process.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where " & _
        "PathName = 'C:\WINDOWS\system32\services.exe'")

For Each objService in colListOfServices
    Wscript.Echo objService.DisplayName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Services Running in All Processes

Description
Returns a list of processes and all the services currently running in each process.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objIdDictionary = CreateObject("Scripting.Dictionary")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where State <> 'Stopped'")

For Each objService in colServices
    If objIdDictionary.Exists(objService.ProcessID) Then
    Else
        objIdDictionary.Add objService.ProcessID, objService.ProcessID
    End If
Next

colProcessIDs = objIdDictionary.Items

For i = 0 to objIdDictionary.Count - 1
    Set colServices = objWMIService.ExecQuery _
        ("Select * from Win32_Service Where ProcessID = '" & _
            colProcessIDs(i) & "'")
    Wscript.Echo "Process ID: " & colProcessIDs(i)
    For Each objService in colServices
        Wscript.Echo VbTab & objService.DisplayName
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Services that Can be Paused

Description
Returns a list of services that can be paused.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where AcceptPause = True")

For Each objService in colServices
    Wscript.Echo objService.DisplayName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Services that Can be Stopped

Description
Returns a list of services that can be stopped.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where AcceptStop = True")

For Each objService in colServices
    Wscript.Echo objService.DisplayName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Service Account Password

Description
Changes the service account password for any services running under the hypothetical service account Netsvc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where StartName = '.\netsvc'")

For Each objService in colServiceList
    errReturn = objService.Change( , , , , , , , "password")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Service Accounts

Description
Changes the service account to LocalService for any services running under the hypothetical service account Netsvc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where StartName = '.\netsvc'")

For each objService in colServices
    errServiceChange = objService.Change _
        ( , , , , , , "NT AUTHORITY\LocalService" , "")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Service Error Control Codes

Description
Configures all auto-start services to issue an alert if the service fails during startup.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const NORMAL_ERROR_CONTROL = 2

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where ErrorControl = 'Ignore'")

For Each objService in colServiceList
    errReturn = objService.Change( , , , NORMAL_ERROR_CONTROL)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Service Start Options

Description
Disables all services configured as manual start. Among other things, this prevents Power Users from being able to start these services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where StartMode = 'Manual'")

For Each objService in colServiceList
    errReturnCode = objService.Change( , , , , "Disabled")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Changes in Service Status

Description
Temporary event consumer that issues an alert any time a service changes status (for example, an active service that is paused or stopped).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService. _
    ExecNotificationQuery("Select * from __instancemodificationevent " _
        & "within 30 where TargetInstance isa 'Win32_Service'")
i = 0

Do While i = 0
    Set objService = colServices.NextEvent
    If objService.TargetInstance.State <> _
        objService.PreviousInstance.State Then
        Wscript.Echo objService.TargetInstance.Name _
            &  " is " & objService.TargetInstance.State _
                & ". The service previously was " & _
                    objService.PreviousInstance.State & "."
    End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Service Performance

Description
Uses formatted performance counters to retrieve performance data for the DHCP Server service.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colDHCPServer = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_DHCPServer_DHCPServer").ObjectSet
objRefresher.Refresh

For i = 1 to 60
    For Each objDHCPServer in colDHCPServer
        Wscript.Echo "Acknowledgements per second: " & _
            objDHCPServer.AcksPerSec
        Wscript.Echo "Declines per second: " & _
            objDHCPServer.DeclinesPerSec
        Wscript.Echo "Discovers per second: " & _
            objDHCPServer.DiscoversPerSec
        Wscript.Echo "Informs per second: " & objDHCPServer.InformsPerSec
        Wscript.Echo "Offers per second: " & objDHCPServer.OffersPerSec
        Wscript.Echo "Releases per second: " & _
            objDHCPServer.ReleasesPerSec
        Wscript.Echo "Requests per second: " & _
            objDHCPServer.RequestsPerSec
    Next
    Wscript.Sleep 10000
    objRefresher.Refresh
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause Services Running Under a Specific Account

Description
Pauses all services running under the hypothetical service account Netsvc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where StartName = '.\netsvc'")

For each objService in colServices
    errReturnCode = objService.PauseService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume AutoStart Services that are Paused

Description
Restarts any auto-start services that have been paused.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
 ("Select * from Win32_Service Where State = 'Paused' and StartMode = 'Auto'")

For Each objService in colListOfServices
    objService.ResumeService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start a Service and Its Dependents

Description
Starts the NetDDE service and all its dependent services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name='NetDDE'")

For Each objService in colServiceList
    errReturn = objService.StartService()
Next

Wscript.Sleep 20000

Set colServiceList = objWMIService.ExecQuery("Associators of " _
   & "{Win32_Service.Name='NetDDE'} Where " _
        & "AssocClass=Win32_DependentService " & "Role=Dependent" )
For Each objService in colServiceList
    objService.StartService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start AutoStart Services that have Stopped

Description
Restarts any auto-start services that have been stopped.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where State = 'Stopped' and StartMode = " _
        & "'Auto'")

For Each objService in colListOfServices
    objService.StartService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop a Service and Its Dependents

Description
Stops the NetDDE service and all its dependent services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery("Associators of " _
    & "{Win32_Service.Name='NetDDE'} Where " _
        & "AssocClass=Win32_DependentService " & "Role=Antecedent" )

For Each objService in colServiceList
    objService.StopService()
Next

Wscript.Sleep 20000

Set colServiceList = objWMIService.ExecQuery _
        ("Select * from Win32_Service where Name='NetDDE'")
For Each objService in colServiceList
    errReturn = objService.StopService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Stop Services Running Under a Specific Account

Description
Stops all services running under the hypothetical service account Netsvc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where StartName = '.\netsvc'")

For Each objService in colServices
    errReturnCode = objService.StopService()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Scheduled Task

Description
Schedules Notepad to run at 12:30 PM every Monday, Wednesday, and Friday.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

errJobCreated = objNewJob.Create _
    ("Notepad.exe", "********123000.000000-420", _
        True , 1 OR 4 OR 16, , , JobID)
Wscript.Echo errJobCreated

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Scheduled Task

Description
Deletes the scheduled task with the Job ID of 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objInstance = objWMIService.Get("Win32_ScheduledJob.JobID=1")

err = objInstance.Delete

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Scheduled Tasks

Description
Deletes all the scheduled tasks on a computer. Note: WMI can only delete scheduled tasks created using the Win32_ScheduledJob class or the At.exe utility. It cannot delete tasks created using the Task Scheduler.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colScheduledTasks = objWMIService.ExecQuery _
    ("Select * from Win32_ScheduledJob")

For Each objTask in colScheduledTasks
    intJobID = objTask.JobID
    Set objInstance = objWMIService.Get _
        ("Win32_ScheduledJob.JobID=" & intJobID)
    objInstance.Delete
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Scheduled Tasks

Description
Enumerates all the scheduled tasks on a computer. Note: WMI can only enumerate scheduled tasks created using the Win32_ScheduledJob class or the At.exe utility. It cannot enumerate tasks created using the Task Scheduler.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colScheduledJobs = objWMIService.ExecQuery _
    ("Select * from Win32_ScheduledJob")

For Each objJob in colScheduledJobs
    Wscript.Echo "Caption: " & objJob.Caption
    Wscript.Echo "Command: " & objJob.Command
    Wscript.Echo "Days of Month: " & objJob.DaysOfMonth
    Wscript.Echo "Days of Week: " & objJob.DaysOfWeek
    Wscript.Echo "Description: " & objJob.Description
    Wscript.Echo "Elapsed Time: " & objJob.ElapsedTime
    Wscript.Echo "Install Date: " & objJob.InstallDate
    Wscript.Echo "Interact with Desktop: " & objJob.InteractWithDesktop
    Wscript.Echo "Job ID: " & objJob.JobID
    Wscript.Echo "Job Status: " & objJob.JobStatus
    Wscript.Echo "Name: " & objJob.Name
    Wscript.Echo "Notify: " & objJob.Notify
    Wscript.Echo "Owner: " & objJob.Owner
    Wscript.Echo "Priority: " & objJob.Priority
    Wscript.Echo "Run Repeatedly: " & objJob.RunRepeatedly
    Wscript.Echo "Start Time: " & objJob.StartTime
    Wscript.Echo "Status: " & objJob.Status
    Wscript.Echo "Time Submitted: " & objJob.TimeSubmitted
    Wscript.Echo "Until Time: " & objJob.UntilTime
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Operating System Properties

Description
Retrieves information about the operating system installed on a computer, including language, encryption level, and build number.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo "Boot Device: " & objOperatingSystem.BootDevice
    Wscript.Echo "Build Number: " & objOperatingSystem.BuildNumber
    Wscript.Echo "Build Type: " & objOperatingSystem.BuildType
    Wscript.Echo "Caption: " & objOperatingSystem.Caption
    Wscript.Echo "Code Set: " & objOperatingSystem.CodeSet
    Wscript.Echo "Country Code: " & objOperatingSystem.CountryCode
    Wscript.Echo "Debug: " & objOperatingSystem.Debug
    Wscript.Echo "Encryption Level: " & objOperatingSystem.EncryptionLevel
    dtmConvertedDate.Value = objOperatingSystem.InstallDate
    dtmInstallDate = dtmConvertedDate.GetVarDate
    Wscript.Echo "Install Date: " & dtmInstallDate
    Wscript.Echo "Licensed Users: " & _
        objOperatingSystem.NumberOfLicensedUsers
    Wscript.Echo "Organization: " & objOperatingSystem.Organization
    Wscript.Echo "OS Language: " & objOperatingSystem.OSLanguage
    Wscript.Echo "OS Product Suite: " & objOperatingSystem.OSProductSuite
    Wscript.Echo "OS Type: " & objOperatingSystem.OSType
    Wscript.Echo "Primary: " & objOperatingSystem.Primary
    Wscript.Echo "Registered User: " & objOperatingSystem.RegisteredUser
    Wscript.Echo "Serial Number: " & objOperatingSystem.SerialNumber
    Wscript.Echo "Version: " & objOperatingSystem.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Operating System Running on a Computer

Description
Returns the name and version number of the operating system installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo objOperatingSystem.Caption & " " & _
        objOperatingSystem.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a User to an ADAM Group

Description
Adds the user Kenmyer to an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
objGroup.Add objUser.AdsPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a User to the ADAM Administrators Group

Description
Adds the user Kenmyer to the ADAM Administrators group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/CN=Administrators,CN=Roles,dc=fabrikam,dc=com")
Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
objGroup.Add objUser.AdsPath

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add All Users in an ADAM OU to a Group

Description
Adds all the users in the Accounting OU to an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("user")

For Each objUser in objOU
    objGroup.Add objUser.AdsPath
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Child ADAM OU

Description
Creates a new ADAM OU within the Management2 OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objParentOU = GetObject _
    ("LDAP://localhost:389/ou=Management2,ou=Management,dc=fabrikam,dc=com")

Set objChildOU = objParentOU.Create("organizationalUnit", "ou=Level3")
objChildOU.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM Contact Account

Description
Creates an ADAM contact named Jonathanhaas.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("contact", "cn=jonathanhaas")
objUser.Put "displayName", "Jonathan Haas"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM Container

Description
Creates an ADAM container named Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
Set objOU = objDomain.Create("container", "cn=Users")
objOU.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM Group

Description
Creates a new ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objGroup = objOU.Create("group", "cn=Accountants")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM inetOrgPerson Account

Description
Creates a new ADAM inetOrgPerson account named Syedabbas.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("inetOrgPerson", "cn=syedabbas")
objUser.Put "displayName", "Syed Abbas"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM OU

Description
Creates a new ADAM OU named Management.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
Set objOU = objDomain.Create("organizationalUnit", "ou=Management")
objOU.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an ADAM User Account

Description
Creates a new ADAM user account named Gailerickson.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUser = objOU.Create("user", "cn=gailerickson")
objUser.Put "displayName", "Gail Erickson"
objUser.Put "userPrincipalName", "gailerickson@fabrikam.com"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM Contact Account

Description
Deletes an ADAM contact account named Carolphilips.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "contact", "cn=carolphilips"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM Container

Description
Deletes an ADAM container named Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "container", "cn=Users"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM Group

Description
Deletes an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "group", "cn=Accountants"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM inetOrgPerson Account

Description
Deletes an ADAM inetOrgPerson account named Carolphilips.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "inetOrgPerson", "cn=carolphilips"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM OU

Description
Deletes an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
objOU.Delete "organizationalUnit", "ou=Accounting"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an ADAM User Account

Description
Deletes an ADAM user account named Carolphilips.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Delete "user", "cn=carolphilips"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Contacts in an ADAM OU

Description
Lists all the contacts in an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error ResumeNext

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("contact")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM Contact Account Property

Description
Modifies the description attribute for an ADAM contact named Carolphilips.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=carolphilips,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice contact account."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM Container Account Property

Description
Modifies the description attribute for an ADAM container named Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject("LDAP://localhost:389/cn=users,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice container."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM Group Account Property

Description
Modifies the description attribute for an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice group account."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM inetOrgPerson Account Property

Description
Modifies the description attribute for an ADAM inetOrgPerson account named Syedabbas.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=syedabbas,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice inetOrgPerson account."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM OU Property

Description
Modifies the description attribute for an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice organizational unit."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM User Account Expiration Date

Description
Modifies the account expiration date for an ADAM user named Kenmyer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")

objUser.AccountExpirationDate = "03/30/2005"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an ADAM User Account Property

Description
Modifies the description attribute for an ADAM user account named Kenmyer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")

objUser.Put "description", "This is a practice user account."
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove a User from an ADAM Group

Description
Removes a user named TestUser from the ADAM group Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const ADS_PROPERTY_DELETE = 4

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

objGroup.PutEx ADS_PROPERTY_DELETE, "member", Array("cn=TestUser,ou=Accounting,dc=fabrikam,dc=com")
objGroup.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename an ADAM User Account

Description
Renames the ADAM user account Kimabercrombie to Dylanmiller.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

objOU.MoveHere _
   "LDAP://cn=kimabercrombie, ou=Accounting,dc=fabrikam,dc=com", _
        "cn=dylanmiller"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM Contact Attributes and Values

Description
Lists all the attributes and values for the ADAM contact account Alexandrelobao.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=alexandrelobao,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/contact")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM Container Attributes and Values

Description
Lists all the attributes and values for the ADAM container named Users.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject("LDAP://localhost:389/cn=Users,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/container")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM Group Attributes and Values

Description
Lists all the attributes and values for an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/group")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM inetOrgPerson Attributes and Values

Description
Lists all the attributes and values for an ADAM inetOrgPersonAccount named Syedabbas.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=syedabbas,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/inetOrgPerson")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM OU Attributes and Values

Description
Lists all the attributes and values for an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = _
    GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject _
    ("LDAP://localhost:389/schema/organizationalUnit")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM OUs

Description
Lists all the OUs in an ADAM domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objDomain = GetObject("LDAP://localhost:389/dc=fabrikam,dc=com")
objDomain.Filter = Array("organizationalUnit")

For Each objOU in objDomain
    strNames = strNames & objOU.Name & vbcrlf
    ShowOUS objOU.AdsPath
Next

Sub ShowOUs(OUName)
    Set objNextOU = GetObject(OUname)
    objNextOU.Filter = Array("organizationalUnit")
    For Each objSubOU in objNextOU
        strNames = strNames & "     " & objSubOU.Name & vbcrlf
        ShowOUS objSubOU.AdsPath
    Next
End Sub

Wscript.Echo strNames

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All ADAM User Attributes and Values

Description
Lists all the attributes and values for an ADAM user account named Kenmyer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
Set objUserProperties = GetObject("LDAP://localhost:389/schema/user")

For Each strAttribute in objUserProperties.MandatoryProperties
    strValues = objUser.GetEx(strAttribute)
    For Each strItem in strValues
        Wscript.Echo strAttribute & " -- " & strItem
    Next
Next

For Each strAttribute in objUserProperties.OptionalProperties
    strValues = objUser.GetEx(strAttribute)
    If Err = 0 Then
        For Each strItem in strValues
            Wscript.Echo strAttribute & " -- " & strItem
        Next
    Else
        Wscript.Echo strAttribute & " --  No value set"
        Err.Clear
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Accounts in an ADAM OU

Description
Lists all the accounts (of any type) in an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Groups in an ADAM OU

Description
Lists all the group accounts in an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("group")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the inetOrgPersons in an ADAM OU

Description
Lists all the inetOrgPerson accounts in an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("inetOrgPerson")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Members of an ADAM Group

Description
Lists all the members of an ADAM group named Accountants.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objGroup = GetObject _
    ("LDAP://localhost:389/cn=Accountants,ou=Accounting,dc=fabrikam,dc=com")

For Each objUser in objGroup.Members
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Users in an ADAM OU

Description
Lists all the user accounts in an ADAM OU named Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objOU = GetObject("LDAP://localhost:389/ou=Accounting,dc=fabrikam,dc=com")
objOU.Filter = Array("user")

For Each objUser in objOU
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM Contact Schema

Description
Lists all the mandatory and optional attributes of the ADAM contact object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/contact")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM Container Schema

Description
Lists all the mandatory and optional attributes of the ADAM container object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/container")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM Group Schema

Description
Lists all the mandatory and optional attributes of the ADAM group object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/group")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM inetOrgPerson Schema

Description
Lists all the mandatory and optional attributes of the ADAM inetOrgPerson object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/inetOrgPerson")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM OU Schema

Description
Lists all the mandatory and optional attributes of the ADAM organizationalUnit object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/organizationalUnit")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the ADAM User Schema

Description
Lists all the mandatory and optional attributes of the ADAM user object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUserProperties = GetObject("LDAP://localhost:389/schema/user")
WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objUserProperties.MandatoryProperties
    WScript.Echo strAttribute
Next

Wscript.Echo

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objUserProperties.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Groups an ADAM User Belongs to

Description
Lists all the groups that the ADAM user Kenmyer is a member of.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objUser = GetObject _
    ("LDAP://localhost:389/cn=kenmyer,ou=Accounting,dc=fabrikam,dc=com")
arrMembersOf = objUser.GetEx("memberOf")

For Each strMemberOf in arrMembersOf
  WScript.Echo strMemberOf
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that ADAM is Installed

Description
Verifies that ADAM is installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service where Name Like '%ADAM_%'")

If colServices.Count = 0 Then
    Wscript.Echo "ADAM is not installed."
Else
    For Each objService in colServices
        Wscript.Echo objService.Name & " -- " & objService.State
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Local Group on a Computer

Description
Creates a local group named FinanceUsers on a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("group", "FinanceUsers")
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Local Group

Description
Deletes a local group named FinanceUsers from a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set objComputer = GetObject("WinNT://" & strComputer & "")
objComputer.Delete "group", "FinanceUsers"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a User from a Local Group

Description
Removes kenmyer from the local Administrators group on a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set objGroup = GetObject("WinNT://" & strComputer & "/Adminstrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")

objGroup.Remove(objUser.ADsPath)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Local Groups a User Belongs To

Description
Returns a list of all the local groups on the computer atl-win2k-01 that a user named kenmyer belongs to.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")

For Each objGroup In colGroups
    For Each objUser in objGroup.Members
        If objUser.name = "kenmyer" Then
            Wscript.Echo objGroup.Name
        End If
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Local Groups and Their Members

Description
Returns a list of local groups (and their members) found on a computer named atl-win2k-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-win2k-01"
Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("group")

For Each objGroup In colGroups
    Wscript.Echo objGroup.Name
    For Each objUser in objGroup.Members
        Wscript.Echo vbTab & objUser.Name
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a User to a Local Group

Description
Adds a user (kenmyer) to the local Administrators group on a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")

Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer,user")
objGroup.Add(objUser.ADsPath)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Change the Local Administrator Password

Description
Binds to the local Administrator account on the computer atl-ws-01, and changes the password for the account to 09iuy%4e.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")

objUser.SetPassword "09iuy%4e"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Local User Account

Description
Creates a local user account (Admin2) on a computer named atl-ws-01, and sets the password for the account to 09iu%4et.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", "Admin2")
objUser.SetPassword "09iu%4et"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Local User Account

Description
Deletes the local user account Admin2 from a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-ws-01"
strUser = "Admin2"

Set objComputer = GetObject("WinNT://" & strComputer & "")
objComputer.Delete "user", strUser

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Local User Account

Description
Disables the local Guest account on a computer named atl-ws-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "atl-ws-01"
Set objUser = GetObject("WinNT://" & strComputer & "/Guest")

objUser.AccountDisabled = True
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable the Guest Account

Description
Uses the Shell object to disable the Guest account on the local computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objComputer = CreateObject("Shell.LocalMachine")
objComputer.DisableGuest(0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable the Guest Account

Description
Uses the Shell object to enable the Guest account on the local computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objComputer = CreateObject("Shell.LocalMachine")
objComputer.EnableGuest(1)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Account Expiration Dates in a Windows NT 4.0 Domain

Description
Determines the expiration dates for all the user accounts in a Windows NT 4.0 domain named Fabrikam.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objDomain = GetObject("WinNT://fabrikam,domain")
objDomain.Filter = Array("User")

For Each objUser In objDomain
   If IsNull(objUser.AccountExpirationDate) Then
       Wscript.Echo objUser.Name, "Account has no expiration date."
   Else
       Wscript.Echo objUser.Name, objUser.AccountExpirationDate
   End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the User Accounts in an NT 4.0 Domain

Description
Returns a list of all the user accounts in a Windows NT 4.0 domain named Fabrikam.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("WinNT://fabrikam,domain")
objDomain.Filter = Array("User")

For Each objUser In objDomain
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Attribute Values for a Local User Account

Description
Displays mandatory and optional attributes (and their values) for a local user account named kenmyer on a computer named atl-win2k-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "atl-win2k-01"
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer ")
Set objClass = GetObject(objUser.Schema)

WScript.Echo "Mandatory properties for " & objUser.Name & ":"
For Each property in objClass.MandatoryProperties
    WScript.Echo property, objUser.Get(property)
Next

WScript.Echo "Optional properties for " & objUser.Name & ":"
For Each property in objClass.OptionalProperties
    WScript.Echo property, objUser.Get(property)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Local Groups Using WMI

Description
Returns information about the local groups found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Group  Where LocalAccount = True")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Domain: " & objItem.Domain
    Wscript.Echo "Local Account: " & objItem.LocalAccount
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "SID: " & objItem.SID
    Wscript.Echo "SID Type: " & objItem.SIDType
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Local User Accounts Using WMI

Description
Returns information about the local user accounts found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_UserAccount Where LocalAccount = True")

For Each objItem in colItems
    Wscript.Echo "Account Type: " & objItem.AccountType
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Disabled: " & objItem.Disabled
    Wscript.Echo "Domain: " & objItem.Domain
    Wscript.Echo "Full Name: " & objItem.FullName
    Wscript.Echo "Local Account: " & objItem.LocalAccount
    Wscript.Echo "Lockout: " & objItem.Lockout
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Password Changeable: " & objItem.PasswordChangeable
    Wscript.Echo "Password Expires: " & objItem.PasswordExpires
    Wscript.Echo "Password Required: " & objItem.PasswordRequired
    Wscript.Echo "SID: " & objItem.SID
    Wscript.Echo "SID Type: " & objItem.SIDType
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List User Accounts on the Local Computer

Description
Returns a list of all the user accounts found on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")

For Each objUser In colAccounts
    Wscript.Echo objUser.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List userFlag Values for a Local User Account

Description
Accesses the userAccountControl to retrieve attribute values for the local user account kenmyer on a computer named atl-win2k-01. These attribute values include such things as account status (enabled or disabled), whether the user requires a password and, if so, whether or not that password will ever expire.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_SCRIPT = &H0001
Const ADS_UF_ACCOUNTDISABLE = &H0002
Const ADS_UF_HOMEDIR_REQUIRED = &H0008
Const ADS_UF_LOCKOUT = &H0010
Const ADS_UF_PASSWD_NOTREQD = &H0020
Const ADS_UF_PASSWD_CANT_CHANGE = &H0040
Const ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &H0080
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Const ADS_UF_SMARTCARD_REQUIRED = &H40000
Const ADS_UF_PASSWORD_EXPIRED = &H800000

Set usr = GetObject("WinNT://atl-win2k-01/kenmyer")
flag = usr.Get("UserFlags")

If flag AND ADS_UF_SCRIPT Then
    Wscript.Echo "Logon script will be executed."
Else
    Wscript.Echo "Logon script will not be executed."
End If

If flag AND ADS_UF_ACCOUNTDISABLE Then
    Wscript.Echo "Account is disabled."
Else
    Wscript.Echo "Account is not disabled."
End If

If flag AND ADS_UF_HOMEDIR_REQUIRED Then
    Wscript.Echo "Home directory required."
Else
    Wscript.Echo "Home directory not required."
End If

If flag AND ADS_UF_PASSWD_NOTREQD Then
    Wscript.Echo "Password not required."
Else
    Wscript.Echo "Password required."
End If

If flag AND ADS_PASSWORD_CANT_CHANGE Then
    Wscript.Echo "User cannot change password."
Else
    Wscript.Echo "User can change password."
End If

If flag AND ADS_UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED Then
    Wscript.Echo "Encrypted password allowed."
Else
    Wscript.Echo "Encrypted password not allowed."
End If

If flag AND ADS_UF_DONT_EXPIRE_PASSWD Then
    Wscript.Echo "Password does not expire."
Else
    Wscript.Echo "Password expires."
End If

If flag AND ADS_UF_SMARTCARD_REQUIRED Then
    Wscript.Echo "Smartcard required for logon."
Else
    Wscript.Echo "Smart card not required for logon."
End If

If flag AND ADS_UF_PASSWORD_EXPIRED Then
    Wscript.Echo "Password has expired."
Else
    Wscript.Echo "Password has not expired."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Local User Account Password So It Never Expires

Description
Binds to a local user account on a computer named atl-win2k-01, and configures the account password so it never expires.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

strDomainOrWorkgroup = "Fabrikam"
strComputer = "atl-win2k-01"
strUser = "KenMeyer"

Set objUser = GetObject("WinNT://" & strDomainOrWorkgroup & "/" & _
    strComputer & "/" & strUser & ",User")

objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Local User Account So It Never Expires

Description
Binds to the local user account on a computer named atl-win2k-01, and configures the account so that it never expires.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

strComputer = "atl-win2k-01"
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer")

objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Expiration Date for a Local User Account

Description
Binds to a local user account (kenmyer) on a computer named atl-win2k-01, and configures the account to expire on March 1, 2005.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-win2k-01"
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer")

objUser.AccountExpirationDate = #03/01/2005#
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Require a Local User to Change His or Her Password

Description
Binds to a local user account on the computer named atl-win2k-01, and configures the account so that the user (kenmyer) must change his password the next time he logs on.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "atl-win2k-01"
Set objUser = GetObject("WinNT://" & strComputer & "/kenmyer")

objUser.Put "PasswordExpired", 1
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Whether an Account Exists in a Windows NT 4.0 Domain

Description
Checks to see if a user account (kenmyer) exists in a Windows NT 4.0 domain named Fabrikam.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strUserName = "kenmyer"
Set objDomain = GetObject("WinNT://fabrikam")
objDomain.Filter = Array("user")
intFound = 0

For Each User In objDomain
    If lcase(User.Name) = lcase(strUserName) Then
        intFound = 1
    End If
Next

If intFound = 1 Then
    WScript.Echo "The " & strUserName & " account already exists."
Else
    WScript.Echo "The " & strUserName & " account does not exist in the domain."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Printer Connection

Description
Adds a printer connection to a network printer. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
WshNetwork.SetDefaultPrinter "\\PrintServer1\Xerox300"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Default Printer

Description
Sets the default printer on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ScriptedPrinter'")

For Each objPrinter in colInstalledPrinters
    objPrinter.SetDefaultPrinter()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Default Printer Based on Queue Length

Description
Examines all the print queues on a computer, and sets the default printer to the queue with the fewest documents.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

intSmallestQueue = 1000

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintQueues =  objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_Spooler_PrintQueue " _
        & "Where Name <> '_Total'")

For Each objPrintQueue in colPrintQueues
    intCurrentQueue = objPrintQueue.Jobs + objPrintQueue.JobsSpooling
    If intCurrentQueue <= intSmallestQueue Then
        strNewDefault = objPrintQueue.Name
        intSmallestQueue = intCurrentQueue
    End If
Next

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = '" & strNewDefault & "'")

For Each objPrinter in colInstalledPrinters
    objPrinter.SetDefaultPrinter()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Printer

Description
Deletes a printer named ScriptedPrinter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer where DeviceID = 'ScriptedPrinter'")

For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Printer Connection

Description
Removes a printer connection to a network printer. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.RemovePrinterConnection "\\PrintServer\xerox3006"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Printer Connections

Description
Lists all the printer connections on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
    Wscript.Echo "Name: " & objPrinter.Name
    Wscript.Echo "Location: " & objPrinter.Location
    Wscript.Echo "Default: " & objPrinter.Default
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Printer

Description
Renames both a printer and its printer share name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where DeviceID = 'HP LaserJet 4Si M'")

For Each objPrinter in colPrinters
    objPrinter.RenamePrinter("ArtDepartmentPrinter")
Next

Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where DeviceID = 'ArtDepartmentPrinter' ")

For Each objPrinter in colPrinters
    objPrinter.ShareName = "ArtDepartmentPrinter"
    objPrinter.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Large Print Jobs

Description
Deletes all print jobs larger than 1 megabyte.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob Where Size > 1000000")

For Each objPrintJob in colPrintJobs
    objPrintJob.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Printers on a Print Server

Description
Deletes all the printers from a print server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Specific Printers

Description
Deletes all HP QuietJet printers installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where DriverName = 'HP QuietJet'")

For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install a Printer

Description
Installs a logical network printer on a print server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName   = "IP_169.254.110.160"
objPrinter.DeviceID   = "ScriptedPrinter"
objPrinter.Location = "USA/Redmond/Building 37/Room 114"
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.ShareName = "ScriptedPrinter"
objPrinter.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Multiple Printers for One Print Device

Description
Installs two logical network printers (with different printer priorities) for the same physical print device.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName   = "IP_169.254.110.160"
objPrinter.DeviceID   = "PublicPrinter"
objPrinter.Location = "USA/Redmond/Building 37/Room 114"
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.ShareName = "PublicPrinter"
objPrinter.Put_

objPrinter.DriverName = "HP LaserJet 4000 Series PS"
objPrinter.PortName   = "IP_169.254.110.160"
objPrinter.DeviceID   = "PrivatePrinter"
objPrinter.Location = "USA/Redmond/Building 37/Room 114"
objPrinter.Priority = 2
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.Hidden = True
objPrinter.ShareName = "PrivatePrinter"
objPrinter.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Published Printers

Description
Returns a list of all the printers published in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName from " _
    & " 'LDAP://DC=fabrikam,DC=com'  where objectClass='printQueue'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
    Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Print Queue Statistics

Description
Returns total number of jobs, total number of pages, and largest job for all print queues on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

For Each objPrintJob in colPrintJobs
    intTotalJobs = intTotalJobs + 1
    intTotalPages = intTotalPages + objPrintJob.TotalPages
    If objPrintJob.TotalPages > intMaxPrintJob Then
        intMaxPrintJob = objPrintJob.TotalPages
    End If
Next

Wscript.Echo "Total print jobs in queue: " & intTotalJobs
Wscript.Echo "Total pages in queue: " & intTotalPages
Wscript.Echo "Largest print job in queue: " & intMaxPrintJob

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Print Queue Statistics

Description
Uses cooked performance counters to retrieve data such as total number of jobs printed and total number of printing errors for each print queue on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintQueues =  objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_Spooler_PrintQueue Where " & _
        "Name <> '_Total'")

For Each objPrintQueue in colPrintQueues
    Wscript.Echo "Name: " & objPrintQueue.Name
    Wscript.Echo "Jobs: " & objPrintQueue.Jobs
    Wscript.Echo "Current jobs spooling: " & objPrintQueue.JobsSpooling
    Wscript.Echo "Maximum jobs spooling: " & objPrintQueue.MaxJobsSpooling
    Wscript.Echo "Total jobs printed: " & objPrintQueue.TotalJobsPrinted
    Wscript.Echo "Job errors: " & objPrintQueue.JobErrors
    Wscript.Echo "Not ready errors: " & objPrintQueue.NotReadyErrors
    Wscript.Echo "Out of paper errors: " & objPrintQueue.OutOfPaperErrors
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Printer Capabilities

Description
Lists properties and capabilities for all the printers installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_PrinterConfiguration")

For Each objPrinter in colInstalledPrinters
    Wscript.Echo "Name: " & objPrinter.Name
    Wscript.Echo "Collate: " & objPrinter.Collate
    Wscript.Echo "Copies: " & objPrinter.Copies
    Wscript.Echo "Driver Version: " & objPrinter.DriverVersion
    Wscript.Echo "Duplex: " & objPrinter.Duplex
    Wscript.Echo "Horizontal Resolution: " & _
        objPrinter.HorizontalResolution
    If objPrinter.Orientation = 1 Then
        strOrientation =  "Portrait"
    Else
        strOrientation = "Landscape"
    End If
    Wscript.Echo "Orientation : " & strOrientation
    Wscript.Echo "Paper Length: " & objPrinter.PaperLength / 254
    Wscript.Echo "Paper Width: " & objPrinter.PaperWidth / 254
    Wscript.Echo "Print Quality: " & objPrinter.PrintQuality
    Wscript.Echo "Scale: " & objPrinter.Scale
    Wscript.Echo "Specification Version: " & _
        objPrinter.SpecificationVersion
    If objPrinter.TTOption = 1 Then
        strTTOption = "Print TrueType fonts as graphics."
    Elseif objPrinter.TTOption = 2 Then
        strTTOption = "Download TrueType fonts as soft fonts."
    Else
        strTTOption = "Substitute device fonts for TrueType fonts."
    End If
    Wscript.Echo "True Type Option: " & strTTOption
    Wscript.Echo "Vertical Resolution: " & objPrinter.VerticalResolution
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Print Job Priority

Description
Uses ADSI to change the priority of current print jobs based on the size of those print jobs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPrinter = GetObject _
    ("WinNT://atl-dc-02/ArtDepartmentPrinter, printqueue")

For Each objPrintJob in objPrinter.PrintJobs
    If objPrintJob.Size > 400000 Then
        objPrintJob.Put "Priority" , 2
        objPrintJob.SetInfo
    Else
        objPrintJob.Put "Priority" , 3
        objPrintJob.SetInfo
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Print Job Start Time

Description
Uses ADSI to change the start time for all print jobs larger than 400K to 2:00 AM.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPrinter = GetObject("WinNT://atl-dc-02/ArtDepartmentPrinter,printqueue")

For Each objPrintQueue in objPrinter.PrintJobs
    If objPrintQueue.Size > 400000 Then
        objPrintQueue.Put "StartTime" , TimeValue("2:00:00 AM")
        objPrintQueue.SetInfo
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Printer Availability

Description
Configures a printer so that documents can only be printed between 8:00 AM and 6:00 PM.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

dtmStartTime= "********080000.000000+000"
dtmEndTime= "********180000.000000+000"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where DeviceID = 'ArtDepartmentPrinter' ")

For Each objPrinter in colPrinters
    objPrinter.StartTime = dtmStartTime
    objPrinter.UntilTime = dtmEndTime
    objPrinter.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Printer Locations

Description
Uses ADSI to configure the location attribute for all the printers in a specified OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://OU = Finance, DC = fabrikam, DC = com")
objOU.Filter = Array("printqueue")

For Each objPrintQueue In objOU
    objPrintQueue.Put "Location" , "USA/Redmond/Finance Building"
    objPrintQueue.SetInfo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Printer Priority

Description
Sets the priority for a printer to 2.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer where DeviceID = 'ArtDepartmentPrinter' ")

For Each objPrinter in colPrinters
    objPrinter.Priority = 2
    objPrinter.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Print Job Status

Description
Returns the job ID, user name, and total pages for each print job on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

Wscript.Echo "Print Queue, Job ID, Owner, Total Pages"

For Each objPrintJob in colPrintJobs
    strPrinter = Split(objPrintJob.Name,",",-1,1)
    Wscript.Echo strPrinter(0) & ", " & _
        objPrintJob.JobID & ", " &  objPrintJob.Owner & ", " _
            & objPrintJob.TotalPages
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Print Queue Times

Description
Identifies any print jobs that have been in the print queue for more than 15 minutes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const USE_LOCAL_TIME = True

Set DateTime = CreateObject("WbemScripting.SWbemDateTime")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

Wscript.Echo "Print Queue, Job ID, TimeSubmitted, Total Pages"

For Each objPrinter in colInstalledPrinters
    DateTime.Value = objPrinter.TimeSubmitted
    dtmActualTime = DateTime.GetVarDate(USE_LOCAL_TIME)
    TimeinQueue = DateDiff("n", actualTime, Now)
    If TimeinQueue > 15 Then
        strPrinterName = Split(objPrinter.Name,",",-1,1)
        Wscript.Echo strPrinterName(0) & ", " _
            & objPrinter.JobID & ", " & dtmActualTime & ", " & _
                objPrinter.TotalPages
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Print Queues

Description
Uses cooked performance counters to return the number of jobs currently in each print queue on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintQueues =  objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_Spooler_PrintQueue " & _
        "Where Name <> '_Total'")

For Each objPrintQueue in colPrintQueues
    Wscript.Echo "Name: " & objPrintQueue.Name
    Wscript.Echo "Current jobs: " & objPrintQueue.Jobs
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Printer Status

Description
Checks the status for each printer on a computer, and issues an alert if any of these printers have stopped.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where PrinterStatus = '1' " _
        & "or PrinterStatus = '2'")

If colInstalledPrinters.Count = 0 Then
    Wscript.Echo "All printers are functioning correctly."
Else
    For Each objPrinter in colInstalledPrinters
        Wscript.Echo "Printer " & objprinter.Name & " is not responding."
    Next
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Printer Status

Description
Displays current status for all printers on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
    Wscript.Echo  "Name: " & objPrinter.Name
    Wscript.Echo  "Location: " & objPrinter.Location
    Select Case objPrinter.PrinterStatus
        Case 1
            strPrinterStatus = "Other"
        Case 2
            strPrinterStatus = "Unknown"
        Case 3
            strPrinterStatus = "Idle"
        Case 4
            strPrinterStatus = "Printing"
        Case 5
            strPrinterStatus = "Warmup"
    End Select
    Wscript.Echo  "Printer Status: " & strPrinterStatus
    Wscript.Echo  "Server Name: " & objPrinter.ServerName
    Wscript.Echo  "Share Name: " & objPrinter.ShareName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Printers with a Temporary Event Subscription

Description
Uses a temporary event consumer to issues alerts any time a printer changes status.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters = objWMIService. _
    ExecNotificationQuery("Select * from __instancemodificationevent " _
        & "within 30 where TargetInstance isa 'Win32_Printer'")
i = 0

Do While i = 0
    Set objPrinter = colPrinters.NextEvent
    If objPrinter.TargetInstance.PrinterStatus <> _
        objPrinter.PreviousInstance.PrinterStatus Then
        Select Case objPrinter.TargetInstance.PrinterStatus
            Case 1 strCurrentState = "Other"
            Case 2 strCurrentState = "Unknown"
            Case 3 strCurrentState = "Idle"
            Case 4 strCurrentState = "Printing"
            Case 5 strCurrentState = "Warming Up"
        End Select
        Select Case objPrinter.PreviousInstance.PrinterStatus
            Case 1 strPreviousState = "Other"
            Case 2 strPreviousState = "Unknown"
            Case 3 strPreviousState = "Idle"
            Case 4 strPreviousState = "Printing"
            Case 5 strPreviousState = "Warming Up"
        End Select
        Wscript.Echo objPrinter.TargetInstance.Name _
            &  " is " & strCurrentState _
                & ". The printer previously was " & strPreviousState & "."
    End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Spooler Print Queue Performance

Description
Uses cooked performance counters to return information about print jobs spooled on a print server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_Spooler_PrintQueue").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Add Network Printer Calls: " & _
            objItem.AddNetworkPrinterCalls
        Wscript.Echo "Bytes Printed Per Second: " & objItem.BytesPrintedPersec
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Enumerate Network Printer Calls: " & _
        objItem.EnumerateNetworkPrinterCalls
        Wscript.Echo "Job Errors: " & objItem.JobErrors
        Wscript.Echo "Jobs: " & objItem.Jobs
        Wscript.Echo "Jobs Spooling: " & objItem.JobsSpooling
        Wscript.Echo "Maximum Jobs Spooling: " & objItem.MaxJobsSpooling
        Wscript.Echo "Maximum References: " & objItem.MaxReferences
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Not-Ready Errors: " & objItem.NotReadyErrors
        Wscript.Echo "Out-of-Paper Errors: " & objItem.OutofPaperErrors
        Wscript.Echo "References: " & objItem.References
        Wscript.Echo "Total Jobs Printed: " & objItem.TotalJobsPrinted
        Wscript.Echo "Total Pages Printed: " & objItem.TotalPagesPrinted
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor the Print Service

Description
Returns the status of the Spooler service (running, stopped, paused, etc.).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colRunningServices =  objWMIService.ExecQuery _
    ("Select * from Win32_Service Where Name = 'Spooler'")

For Each objService in colRunningServices
    Wscript.Echo objService.DisplayName & " -- " & objService.State
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Notify Users When a Print Queue is Purged

Description
Uses Msg.exe to send a network alert to any users who had documents in a print queue about to be purged. After sending the alerts, the script purges the print queue.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set objDictionary = CreateObject("Scripting.Dictionary")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

For Each objPrintJob in colInstalledPrintJobs
    strPrinterName = Split(objPrintJob.Name,",",-1,1)
    If objDictionary.Exists(objPrintJob.Notify) Then
    Else
        objDictionary.Add objPrintJob.Notify, strPrinterName(0)
    End If
Next

arrKeys = objDictionary.Keys
arrItems = objDictionary.Items

For i = 0 to objDictionary.Count - 1
    Message = "The documents you were printing on printer "
    Message = Message & arrItems(i)
    Message = Message & " had to be deleted from the print queue. "
    Message = Message & "You will need to reprint these documents."
    CommandString = "%comspec% /c msg " & arrKeys(i) & " " & Chr(34) _
        & Message & Chr(34)
    WshShell.Run CommandString, 0, True
Next

Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
    objPrinter.CancelAllJobs()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause a Printer

Description
Pauses a printer named ArtDepartmentPrinter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ArtDepartmentPrinter'")

For Each objPrinter in colInstalledPrinters
    ObjPrinter.Pause()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause All Print Jobs

Description
Pauses all the print jobs on a print server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

For Each objPrintJob in colPrintJobs
    objPrintJob.Pause
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause All Printers with Empty Print Queues

Description
Pauses any printers that have no pending print jobs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
    Set colPrintJobs = objWMIService.ExecQuery _
        ("Select * from Win32_PerfFormattedData_Spooler_PrintQueue " _
            & "Where Name = '" & objPrinter.Name & "'")
    For Each objPrintQueue in colPrintJobs
        If objPrintQueue.Jobs = 0 and objPrintQueue.Name <> "_Total" Then
            objPrinter.Pause()
        End If
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Purge a Print Queue

Description
Deletes all the print jobs for a printer named HP QuietJet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'HP QuietJet'")

For Each objPrinter in colInstalledPrinters
    objPrinter.CancelAllJobs()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Printer Published in Active Directory

Description
Uses the MoveHere method to rename a published printer in an OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")

objOU.MoveHere _
    "LDAP://cn=Printer1,ou=HR,dc=NA,dc=fabrikam,dc=com", "cn=HRPrn1"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume a Paused Printer

Description
Resumes a paused printer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer Where Name = 'ArtDepartmentPrinter'")

For Each objPrinter in colInstalledPrinters
    ObjPrinter.Resume()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume All Paused Printers

Description
Resumes all the paused printers on a print server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PRINTER_IS_PAUSED = 8

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer where ExtendedPrinterStatus = 8")

For Each objPrinter in colInstalledPrinters
    ObjPrinter.Resume()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume All Print Jobs

Description
Resumes all the print jobs on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrintJobs =  objWMIService.ExecQuery _
    ("Select * from Win32_PrintJob")

For Each objPrintJob in colPrintJobs
    objPrintJob.Resume
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search Active Directory for Specific Printers

Description
Searches Active Directory for all printers with a priority of 2.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName from " _
    & "'LDAP://DC=fabrikam,DC=com'  where objectClass='printQueue' and " _
        & " Priority = 2 "
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
    Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Transfer Print Jobs to a Different Print Queue

Description
Changes the TCP/IP printer port for a logical printer, which has the net effect of transferring existing print jobs to the new printer port, and thus to a different printer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objPrinter = objWMIService.Get _
    ("Win32_Printer.DeviceID='ArtDepartmentPrinter'")

objPrinter.PortName = "IP_192.168.1.10"
objPrinter.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Update Printer Locations

Description
Uses ADSI to update the location attribute for all printers in a specified OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objOU = GetObject("LDAP://OU=Finance, DC=fabrikam, DC=com")
objOU.Filter = Array("printqueue")

For Each objPrintQueue In objOU
    strNewLocation = "Redmond/" & objPrintQueue.Location
    objPrintQueue.Put "Location" , strNewLocation
    objPrintQueue.SetInfo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete A Printer Port

Description
Deletes a TCP/IP printer port from a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colInstalledPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort Where Name = 'IP_169.254.110.14'")

For Each objPort in colInstalledPorts
    objPort.Delete
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Unused Printer Ports

Description
Deletes any printer ports that have been installed on a computer but are not in use.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colPrinters
    objDictionary.Add objPrinter.PortName, objPrinter.PortName
Next

Set colPorts = objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")
For Each objPort in colPorts
    If objDictionary.Exists(objPort.Name) Then
    Else
        ObjPort.Delete_
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install a Printer Driver not Found in Drivers Cab

Description
Installs a hypothetical printer using a print driver not found in Drivers.cab.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "NewPrinter Model 2900"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriverPath = "C:\Scripts\NewPrinter.dll"
objInfname = "C:\Scripts\NewPrinter.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Printer Drivers

Description
Installs the printer driver for an Apple LaserWriter 8500 printer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

objDriver.Name = "Apple LaserWriter 8500"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
errResult = objDriver.AddPrinterDriver(objDriver)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Printer Ports

Description
Installs a TCP/IP printer port on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
    ("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_169.254.110.14"
objNewPort.Protocol = 1
objNewPort.HostAddress = "169.254.110.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Printer Drivers

Description
Lists all the printer drivers that have been installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_PrinterDriver")

For each objPrinter in colInstalledPrinters
    Wscript.Echo "Configuration File: " & objPrinter.ConfigFile
    Wscript.Echo "Data File: " & objPrinter.DataFile
    Wscript.Echo "Description: " & objPrinter.Description
    Wscript.Echo "Driver Path: " & objPrinter.DriverPath
    Wscript.Echo "File Path: " & objPrinter.FilePath
    Wscript.Echo "Help File: " & objPrinter.HelpFile
    Wscript.Echo "INF Name: " & objPrinter.InfName
    Wscript.Echo "Monitor Name: " & objPrinter.MonitorName
    Wscript.Echo "Name: " & objPrinter.Name
    Wscript.Echo "OEM Url: " & objPrinter.OEMUrl
    Wscript.Echo "Supported Platform: " & objPrinter.SupportedPlatform
    Wscript.Echo "Version: " & objPrinter.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Printer Port Availability

Description
Identifies all the TCP/IP printer ports on a computer, and indicates which ports are being used and which ports are available.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPrinters =  objWMIService.ExecQuery _
    ("Select * from Win32_Printer")

For Each objPrinter in colPrinters
    objDictionary.Add objPrinter.PortName, objPrinter.PortName
Next

Set colPorts = objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")
For Each objPort in colPorts
    If objDictionary.Exists(objPort.Name) Then
        strUsedPorts = strUsedPorts & _
            objDictionary.Item(objPort.Name) & VbCrLf
    Else
        strFreePorts = strFreePorts & objPort.Name & vbCrLf
    End If
Next

Wscript.Echo "The following ports are in use: " & VbCrLf & strUsedPorts
Wscript.Echo "The following ports are available: " & VbCrLf & strFreePorts

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Printer Port Properties

Description
Lists properties of all the TCP/IP printer ports installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPorts =  objWMIService.ExecQuery _
    ("Select * from Win32_TCPIPPrinterPort")

For Each objPort in colPorts
    Wscript.Echo "Description: " & objPort.Description
    Wscript.Echo "Host Address: " & objPort.HostAddress
    Wscript.Echo "Name: " & objPort.Name
    Wscript.Echo "Port Number: " & objPort.PortNumber
    Wscript.Echo "Protocol: " & objPort.Protocol
    Wscript.Echo "SNMP Community: " & objPort.SNMPCommunity
    Wscript.Echo "SNMP Dev Index: " & objPort.SnMPDevIndex
    Wscript.Echo "SNMP Enabled: " & objPort.SNMPEnabled
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Bind to Active Directory using rootDSE

Description
Demonstration script that uses rootDSE to bind to various objects in the local Active Directory domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objRootDSE = GetObject("LDAP://rootDSE")

strSchema = "LDAP://" & objRootDSE.Get("schemaNamingContext")
WScript.echo "ADsPath to schema: " & strSchema
Set objSchema = GetObject(strSchema)
WScript.Echo "Schema Object:"
WScript.Echo "Name: " & objSchema.Name
WScript.Echo "Class: " & objSchema.Class & VbCrLf

strConfiguration = "LDAP://" & objRootDSE.Get("configurationNamingContext")
WScript.Echo "ADsPath to configuration container: " & strConfiguration
Set objConfiguration = GetObject(strConfiguration)
WScript.Echo "Configuration Object:"
WScript.Echo "Name: " & objConfiguration.Name
WScript.Echo "Class: " & objConfiguration.Class & VbCrLf

strDomain = "LDAP://" & objRootDSE.Get("defaultNamingContext")
WScript.Echo "ADsPath to current domain container: " & strDomain
Set objDomain = GetObject(strDomain)
WScript.Echo "Current Domain Object:"
WScript.Echo "Name: " & objDomain.Name
WScript.Echo "Class: " & objDomain.Class & VbCrLf

strRootDomain = "LDAP://" & objRootDSE.Get("rootDomainNamingContext")
WScript.Echo "ADsPath to root domain container: " & strDomain
Set objRootDomain = GetObject(strRootDomain)
WScript.Echo "Current Domain Object:"
WScript.Echo "Name: " & objRootDomain.Name
WScript.Echo "Class: " & objRootDomain.Class & VbCrLf

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory Auxiliary Classes

Description
Returns a list of all the Active Directory auxiliary classes directly applied to the User class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strClassName = "cn=user"

Set objSchemaClass = GetObject _
    ("LDAP://" & strClassName & _
        ",cn=schema,cn=configuration,dc=fabrikam,dc=com")

arrSystemAuxiliaryClass = _
objSchemaClass.GetEx("systemAuxiliaryClass")

If isEmpty(arrSystemAuxiliaryClass) Then
    WScript.Echo "There are no auxiliary classes" & _
        " applied directly to this class."
    Else
        WScript.StdOut.Write "Auxiliary classes: "
    For Each strAuxiliaryClass in arrSystemAuxiliaryClass
        WScript.StdOut.Write strAuxiliaryClass & " | "
    Next
    WScript.Echo
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Active Directory System Information

Description
Uses the ADSystemInfo interface to return domain information for a computer, including computer name, site name, and various domain names (short name, domain DNS name, and forest DNS name).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")

Wscript.Echo "User name: " & objSysInfo.UserName
Wscript.Echo "Computer name: " & objSysInfo.ComputerName
Wscript.Echo "Site name: " & objSysInfo.SiteName
Wscript.Echo "Domain short name: " & objSysInfo.DomainShortName
Wscript.Echo "Domain DNS name: " & objSysInfo.DomainDNSName
Wscript.Echo "Forest DNS name: " & objSysInfo.ForestDNSName
Wscript.Echo "PDC role owner: " & objSysInfo.PDCRoleOwner
Wscript.Echo "Schema role owner: " & objSysInfo.SchemaRoleOwner
Wscript.Echo "Domain is in native mode: " & objSysInfo.IsNativeMode

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Attributes of an Active Directory Class

Description
Returns all the attributes associated with the Computer class in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objSchemaComputer = GetObject("LDAP://schema/computer")

WScript.Echo "Mandatory (Must-Contain) attributes"
For Each strAttribute in objSchemaComputer.MandatoryProperties
    WScript.Echo strAttribute
Next

WScript.Echo VbCrLf & "Optional (May-Contain) attributes"
For Each strAttribute in objSchemaComputer.OptionalProperties
    WScript.Echo strAttribute
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Domain Object Property Values

Description
Retrieves the ADsPath, Class, GUID, Name, Parent, and Schema properties for a domain.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDomain = GetObject("LDAP://dc=NA,dc=fabrikam,dc=com")

WScript.Echo "Ads Path:" & objDomain.ADsPath
WScript.Echo "Class:" & objDomain.Class
WScript.Echo "GUID:" & objDomain.GUID
WScript.Echo "Name:" & objDomain.Name
WScript.Echo "Parent:" & objDomain.Parent
WScript.Echo "Schema:" & objDomain.Schema

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Active Directory Class Type for an Object

Description
Determines the Active Directory class type for the organizational-person object.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strClassName = "cn=organizational-person"

Set objSchemaClass = GetObject _
    ("LDAP://" & strClassName & _
        ",cn=schema,cn=configuration,dc=fabrikam,dc=com")

intClassCategory = objSchemaClass.Get("objectClassCategory")

Select Case intClassCategory
    Case 0
        strCategory = "88"
    Case 1
        strCategory = "structural"
    Case 2
        strCategory = "abstract"
    Case 3
        strCategory = "auxiliary"
End Select

Wscript.Echo strClassName & " is categorized as " & strCategory & "."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Names of All Objects in the Configuration Container

Description
Retrieves the names of the first-level objects in the Configuration container.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConfiguration = GetObject _
    ("LDAP://cn=Configuration,dc=fabrikam,dc=com")

For Each objContainer in objConfiguration
    WScript.Echo objContainer.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Parent Class of an Active Directory Object

Description
Determines the parent class of the Computer object within Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strClassName = "cn=computer"

Set objSchemaClass = GetObject _
    ("LDAP://" & strClassName & _
        ",cn=schema,cn=configuration,dc=fabrikam,dc=com")

strSubClassOf = objSchemaClass.Get("subClassOf")
WScript.Echo "The " & strClassName & _
    " class is a child of the " & strSubClassOf & " class."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use a Search to Move Similar Active Directory Objects

Description
Searches for all user account objects whose department attribute is Human Resources. The script then moves the user accounts that are not already in the HR OU to this OU.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
    ";" & _
        "(&(&(objectCategory=person)(objectClass=user)" & _
            "(department=Human Resources)));" & _
                "ADsPath,distinguishedName, name;subtree"

Set objRecordSet = objCommand.Execute
Set objOU = GetObject("LDAP://ou=HR,dc=NA,dc=fabrikam,dc=com")

Do Until objRecordset.EOF
    strADsPath = objRecordset.Fields("ADsPath")

    strDNRecord=lcase(objRecordset.Fields("distinguishedName"))
    strDNCompare=lcase("cn=" & objRecordset.Fields("name") & _
        ",ou=HR,dc=NA,dc=fabrikam,dc=com")

    If strDNRecord <> strDNCompare Then
        objOU.MoveHere strADsPath, vbNullString
        WScript.Echo objRecordset.Fields("distinguishedName") & " Moved."
    Else
        Wscript.Echo objRecordset.Fields("distinguishedName") & " Not Moved."
    End If
    objRecordSet.MoveNext
Loop

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use a Search to Modify Similar Active Directory Objects

Description
Searches for all computers that begin with the letters "ATL" in a domain and any child domain, and then modifies the location attribute of all computers found.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
    ";" & _
        "(&(objectCategory=Computer)(cn=ATL*));" & _
            "ADsPath;subtree"

Set objRecordSet = objCommand.Execute

Do Until objRecordset.EOF
    strADsPath = objRecordset.Fields("ADsPath")
    Set objComputer = GetObject(strADsPath)
    objComputer.Put "location", "Atlanta, Georgia"
    objComputer.SetInfo
    objRecordSet.MoveNext
Loop

WScript.Echo objRecordSet.RecordCount & _
   " computers objects modified."

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify That an Attribute is in the Global Catalog

Description
Determines whether or not a specified attribute (given-name) is included in the Active Directory global catalog.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strAttributeName = "cn=given-name"

Set objSchemaAttribute = GetObject _
    ("LDAP://" & strAttributeName & _
        ",cn=schema,cn=configuration,dc=fabrikam,dc=com")

blnInGC = objSchemaAttribute.Get("isMemberOfPartialAttributeSet")

If blnInGC Then
    WScript.Echo "The " & strAttributeName & _
        " attribute is replicated to the Global Catalog."
Else
    WScript.Echo "The " & strAttributeName & _
        " attribute is not replicated to the Global Catalog."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify That an Attribute is Operational

Description
Determines whether or not a specified attribute (Canonical-Name) is operational within Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SYSTEMFLAG_ATTR_IS_CONSTRUCTED = &h00000004

strAttributeName = "cn=Canonical-Name"

Set objSchemaAttribute = GetObject _
    ("LDAP://" & strAttributeName & _
        ",cn=schema,cn=configuration,dc=fabrikam,dc=com")

intSystemFlags = objSchemaAttribute.Get("systemFlags")

If intSystemFlags AND ADS_SYSTEMFLAG_ATTR_IS_CONSTRUCTED Then
    WScript.Echo strAttributeName & " is operational."
Else
    WScript.Echo strAttributeName & " is not operational."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Whether Attributes are Indexed and-or in the Global Catalog

Description
Determines which Active Directory attributes are indexed and which attributes are in the global catalog.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const IS_INDEXED = 1

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.Properties("Sort On") = "isMemberOfPartialAttributeSet"

objCommand.CommandText = _
    ";" & _
        "(objectClass=attributeSchema);" & _
            "lDAPDisplayName, isMemberOfPartialAttributeSet,searchFlags;onelevel"

Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
    WScript.Echo objRecordset.Fields("lDAPDisplayName")
    If objRecordset.Fields("isMemberOfPartialAttributeSet")Then
        WScript.Echo "In the global catalog."
    Else
        WScript.Echo "Not in the global catlog."
    End If

    If IS_INDEXED AND objRecordset.Fields("searchFlags") Then
        WScript.Echo "Is indexed."
    Else
        WScript.Echo "Is not indexed."
    End If
    Wscript.Echo VbCrLf
    objRecordSet.MoveNext
Loop

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create Documentation Based on Script Comments

Description
Demonstrates the use of the FileSystemObject as a way to copy comments from a script to a separate text file. Requires comments to have been marked using '*.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objScriptFile = objFSO.OpenTextFile("c:\scripts\Service_Monitor.vbs", _
    ForReading)
Set objCommentFile = objFSO.OpenTextFile("c:\scripts\Comments.txt", _
    ForWriting, TRUE)

Do While objScriptFile.AtEndOfStream <> TRUE
    strCurrentLine = objScriptFile.ReadLine
    intIsComment = Instr(1,strCurrentLine,"'*")
    If intIsComment > 0 Then
        objCommentFile.Write strCurrentLine & VbCrLf
    End If
Loop

objScriptFile.Close
objCommentFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Debugging Comments

Description
Demonstrates the use of the FileSystemObject as a way to remove debugging comments from a script. Requires comments to have been marked as '* BUG.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1
Const ForWriting = 2

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Scripts\CreateUser.vbs", ForReading)

Do While objTextFile.AtEndOfStream <> true
    strNextLine = objTextFile.Readline
    intCheckForBugComment = Instr(strNextLine, "'* BUG")
    If intCheckForBugComment = 0 Then
        strSavedLines = strSavedLines & strNextLine & VbCrLf
    End If
Loop

Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\CreateUser.vbs ", ForWriting)
objTextFile.Write strSavedLines
objTextFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Convert WMI Date-Time Values

Description
Demonstrates a method for converting the Universal Time Coordinate (UTC) values used by WMI to standard date-time values. The script retrieves the date that the operating system was installed, and passes that UTC value to a function named WMIDateStringToDate. This function converts the UTC value (such as 20011029113047.000000-480) to a standard date-time value (such as 10/29/200111:30:47 AM).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objOS = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

For Each strOS in objOS
    dtmInstallDate = strOS.InstallDate
    strReturn = WMIDateStringToDate(dtmInstallDate)
    Wscript.Echo strReturn
Next

Function WMIDateStringToDate(dtmInstallDate)
    WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) & "/" & _
        Mid(dtmInstallDate, 7, 2) & "/" & Left(dtmInstallDate, 4) _
            & " " & Mid (dtmInstallDate, 9, 2) & ":" & _
                Mid(dtmInstallDate, 11, 2) & ":" & Mid(dtmInstallDate, _
                    13, 2))
End Function

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the UTC Time on a Computer

Description
Reports the Universal Time Coordinate (UTC) time on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_UTCTime")

For Each objItem in colItems
    Wscript.Echo "Day: " & objItem.Day
    Wscript.Echo "Day of the Week: " & objItem.DayOfWeek
    Wscript.Echo "Hour: " & objItem.Hour
    Wscript.Echo "Milliseconds: " & objItem.Milliseconds
    Wscript.Echo "Minute: " & objItem.Minute
    Wscript.Echo "Month: " & objItem.Month
    Wscript.Echo "Quarter: " & objItem.Quarter
    Wscript.Echo "Second: " & objItem.Second
    Wscript.Echo "Week in the Month: " & objItem.WeekInMonth
    Wscript.Echo "Year: " & objItem.Year
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Locate a File Using a File Open Dialog Box

Description
Demonstration script that displays a File Open dialog box (open to the folder C:\Scripts), and then echoes back the name of the selected file.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "VBScript Scripts|*.vbs|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\Scripts"
intResult = objDialog.ShowOpen

If intResult = 0 Then
    Wscript.Quit
Else
    Wscript.Echo objDialog.FileName
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save a File Using a File Save Dialog Box

Description
Demonstration script that allows you to enter a file name in a File Save dialog box, and then saves a sample text file (consisting entirely of the current date) under that file name.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objDialog = CreateObject("SAFRCFileDlg.FileSave")

objDialog.FileName = "C:\Scripts\Script1.vbs"
objDialog.FileType = "VBScript Script"
intReturn = objDialog.OpenFileSaveDlg

If intReturn Then
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile(objDialog.FileName)
    objFile.WriteLine Date
    objFile.Close
Else
    Wscript.Quit
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Elements to a Dictionary

Description
Demonstration script that adds three key-item pairs to a Script Runtime Dictionary. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Elements from a Dictionary

Description
Demonstration script that deletes all the key-item pairs from a Script Runtime Dictionary. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"
colKeys = objDictionary.Keys

Wscript.Echo "First run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

objDictionary.RemoveAll
colKeys = objDictionary.Keys

Wscript.Echo VbCrLf & "Second run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete One Element from a Dictionary

Description
Demonstration script that deletes a specific key-item pair from a Script Runtime Dictionary. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"

colKeys = objDictionary.Keys

Wscript.Echo "First run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

objDictionary.Remove("Printer 2")
colKeys = objDictionary.Keys

Wscript.Echo VbCrLf & "Second run: "
For Each strKey in colKeys
    Wscript.Echo strKey
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Number of Items in a Dictionary

Description
Demonstration script that counts the number of key-item pairs in a Script Runtime Dictionary. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"
Wscript.Echo objDictionary.Count

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the Existence of a Dictionary Key

Description
Demonstration script that verifies the existence of a particular key within a Script Runtime Dictionary. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

objDictionary.Add "Printer 1", "Printing"
objDictionary.Add "Printer 2", "Offline"
objDictionary.Add "Printer 3", "Printing"

If objDictionary.Exists("Printer 4") Then
    Wscript.Echo "Printer 4 is in the Dictionary."
Else
    Wscript.Echo "Printer 4 is not in the Dictionary."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Real Time Events in a Command Window

Description
Creates a temporary event consumer that monitors the event log for error events. When an error event occurs, the script displays the event information in the command window.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Security)}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("Select * from __InstanceCreationEvent within 5 where TargetInstance " & _
        isa 'Win32_NTLogEvent' and TargetInstance.EventType = '1'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
        Wscript.Echo "Record No.: " & _
            objLatestEvent.TargetInstance.RecordNumber
        Wscript.Echo "Event ID: " & objLatestEvent.TargetInstance.EventCode
        Wscript.Echo "Time: " & objLatestEvent.TargetInstance.TimeWritten
        Wscript.Echo "Source: " & objLatestEvent.TargetInstance.SourceName
        Wscript.Echo "Category: " & _
            objLatestEvent.TargetInstance.CategoryString
        Wscript.Echo "Event Type: " & objLatestEvent.TargetInstance.Type
        Wscript.Echo "Computer: " & _
            objLatestEvent.TargetInstance.ComputerName
        Wscript.Echo "User: " & objLatestEvent.TargetInstance.User
        Wscript.echo "Text: " & objLatestEvent.TargetInstance.Message
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Tabular Output in a Command Window

Description
Retrieves service data from a computer, and then outputs that data in tabular format in a command window.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colServices
    intPadding = 50 - Len(objService.DisplayName)
    intPadding2 = 17 - Len(objService.StartMode)
    strDisplayName = objService.DisplayName & Space(intPadding)
    strStartMode = objService.StartMode & Space(intPadding2)
    Wscript.Echo strDisplayName & strStartMode & objService.State
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sort WMI Data

Description
Demonstration script showing how WMI data can be sorted using a disconnected recordset (by itself, WMI does not allow you to specify a sort order for returned data). In this script, service information is retrieved using WMI and is stored in a disconnected recordset, a recordset that is not tied to a physical data source. The Sort method is then used to sort the service data by service state rather than by service name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

dtmStartTime = Now

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

For Each objDrive in objDiskDrives
    If objDrive.FreeSpace < 10000000 Then
        Wscript.Echo "Drive is low on disk space."
    End If
Next

Do
    Set objDiskDrives = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    For Each objDrive in objDiskDrives
        If objDrive.FreeSpace < 10000000 Then
            intElapsedHours = DateDiff("h", dtmStartTime, Now)
                If intElapsedHours >= 1 Then
                    Wscript.Echo "Drive is low on disk space."
                dtmStartTime = Now
            End If
        End If
    Next
    Wscript.Sleep 1000
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Suppress Multiple Event Notifications

Description
Issues an alert if available space on a disk drive falls below 100 megabytes. Will wait one hour before issuing the next alert.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

dtmStartTime = Now
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

For Each objDrive in objDiskDrives
    If objDrive.FreeSpace < 10000000 Then
        Wscript.Echo "Drive is low on disk space."
    End If
Next

Do
    Set objDiskDrives = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk")
    For Each objDrive in objDiskDrives
        If objDrive.FreeSpace < 10000000 Then
            intElapsedHours = DateDiff("h", dtmStartTime, Now)
            If intElapsedHours >= 1 Then
                Wscript.Echo "Drive is low on disk space."
                dtmStartTime = Now
            End If
        End If
    Next
    Wscript.Sleep 1000
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Mask Command Line Passwords

Description
Demonstration script that uses ScriptPW.dll to mask passwords entered at the command line.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objPassword = CreateObject("ScriptPW.Password")
WScript.StdOut.Write "Please enter your password:"

strPassword = objPassword.GetPassword()
Wscript.Echo
Wscript.Echo "Your password is: " & strPassword

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Mask Passwords Using Internet Explorer

Description
Demonstration script that creates an instance of Internet Explorer, and retrieves a password typed into a password-style text box. Requires a Web page named password.htm with the appropriate text box.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExplorer = WScript.CreateObject _
    ("InternetExplorer.Application", "IE_")

objExplorer.Navigate "file:///c:\scripts\password.htm"
objExplorer.Visible = 1
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 250
objExplorer.Left = 0
objExplorer.Top = 0

Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
    Wscript.Sleep 250
Loop

strPassword = objExplorer.Document.Body.All.PasswordBox.Value
objExplorer.Quit

Wscript.Sleep 250
Wscript.Echo strPassword

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Track Script Progress in a Command Window

Description
Demonstrates the use of StdOut as a method for indicating the progress being made by a script.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Wscript.Echo "Processing information. This might take several minutes."

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServices = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colServices
    Wscript.StdOut.Write(".")
Next

Wscript.StdOut.WriteLine
Wscript.Echo "Service information processed."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Track Script Progress Using Internet Explorer

Description
Demonstrates how to use Internet Explorer as a method for indicating the progress being made by a script.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=400
objExplorer.Height = 200
objExplorer.Left = 0
objExplorer.Top = 0

Do While (objExplorer.Busy)
    Wscript.Sleep 200
Loop

objExplorer.Visible = 1
objExplorer.Document.Body.InnerHTML = "Retrieving service information. " _
    & "This might take several minutes to complete."

strComputer = "."
Set colServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2"). _
    ExecQuery("Select * from Win32_Service")
For Each objService in colServices
    Wscript.Sleep 200
Next

objExplorer.Document.Body.InnerHTML = "Service information retrieved."
Wscript.Sleep 3000
objExplorer.Quit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read Arguments from a Text File

Description
Demonstration script that opens a hypothetical text file consisting of server names, then retrieves service information from each on the servers in the file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\servers.txt", ForReading)
i = 0

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    objDictionary.Add i, strNextLine
    i = i + 1
Loop

For Each objItem in objDictionary
    Set colServices = GetObject("winmgmts://" & _
        objDictionary.Item(objItem) _
            & "").ExecQuery("Select * from Win32_Service")
    Wscript.Echo colServices.Count
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read Arguments from an Active Directory Container

Description
Demonstration script that retrieves the names of all the computers in an Active Directory container, and then returns service information from each of those computers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objDictionary = CreateObject("Scripting.Dictionary")

i = 0
Set objOU = GetObject("LDAP://CN=Computers, DC=fabrikam, DC=com")
objOU.Filter = Array("Computer")

For Each objComputer in objOU
    objDictionary.Add i, objComputer.CN
    i = i + 1
Next

For Each objItem in objDictionary
    Set colServices = GetObject("winmgmts://" & _
        objDictionary.Item(objItem) _
            & "").ExecQuery("Select * from Win32_Service")
    Wscript.Echo colServices.Count
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use a Text File as a Command Line Argument

Description
Demonstration script that allows you to drag a text file (consisting of server names) onto the script icon in Windows Explorer. The script then opens the text file, then retrieves service information from each on the servers in the file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1
Set objArgs = WScript.Arguments

Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)
i = 0

Do While objTextFile.AtEndOfStream <> True
  strNextLine = objTextFile.Readline
  objDictionary.Add i, strNextLine
  i = i + 1
Loop

For Each objItem in objDictionary
  Set colServices = GetObject("winmgmts://" & objDictionary.Item(objItem) _
      & "").ExecQuery("Select * from Win32_Service")
  Wscript.Echo colServices.Count
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Contents of a Web Page

Description
Retrieves the HTML source for the Web page http://www.microsoft.com. This script contributed by Maxim Stepin of Microsoft.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

url="http://www.microsoft.com"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")

Call objHTTP.Open("GET", url, FALSE)
objHTTP.Send

WScript.Echo(objHTTP.ResponseText)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save an RSS Feed to a Text File

Description
Sample script that connects to a Web site that supports RSS feeds and then saves the returned data to an XML file named C:\Scripts\Scripting_guys.xml.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ForWriting = 2

strURL="http://blogs.msdn.com/gstemp/Rss.aspx"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", strURL, FALSE)
objHTTP.Send

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile _
    ("C:\Scripts\scripting_guys.xml", ForWriting)
objFile.Write objHTTP.ResponseText
objFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add Specific Users to a Group

Description
Demonstration script that searches for all Accountants in the fabrikam.com domain and then adds all those user accounts to the Accountants security group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://DC=fabrikam,DC=com' " _
        & "WHERE objectCategory='User' AND Title='Accountant'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute

Set objGroup = GetObject _
    ("LDAP://cn=Accountants,ou=NA,dc=fabrikam,dc=com")
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    objGroup.Add(objRecordSet.Fields("ADsPath").Value)
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Department Phone List

Description
Demonstration script that develops a department phone list for the Finance Department of fabrikam.com.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
    "SELECT givenName,SN,telephoneNumber FROM " & _
        "'LDAP://DC=fabrikam,DC=com' " _
            & "WHERE objectCategory='User' AND department='Finance'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("SN").Value & ", " & _
        objRecordSet.Fields("givenName").Value & " " & _
            objRecordSet.Fields("telephoneNumber").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Perform a Search Using Alternate Credentials

Description
Demonstration script that searches Active Directory under alternate credentials.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "Administrator"
objConnection.Properties("Password") = "+77m5trgJo!"
objConnection.Properties("Encrypt Password") = TRUE
objConnection.Properties("ADSI Flag") = 1
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT Name FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a SAM Account Name

Description
Demonstration script that determines whether the samAccountName kenmyer has already been assigned in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT samAccountName FROM " & _
    "'LDAP://dc=fabrikam,dc=com' " & _
        "WHERE samAccountName = 'kenmyer'"
objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute

If objRecordSet.RecordCount = 0 Then
    Wscript.Echo "The samAccount name is not being used."
Else
    Wscript.Echo "The samAccount name is being used."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for All Groups in Active Directory

Description
Demonstration script that returns the names of all the groups in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT cn FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
        & "objectCategory='group'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("cn").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for All Non-User Accounts

Description
Demonstration script that returns all the accounts in fabrikam.com except user accounts. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(!(objectCategory=User));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for All Users in Active Directory

Description
Demonstration script that returns the names of all the user accounts in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT Name FROM 'LDAP://dc=fabrikam,dc=com' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for All Users That Have a Phone Number

Description
Demonstration script that returns the names of all Active Directory users who have a phone number. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(telephoneNumber=*));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for All Users Using an LDAP Query

Description
Demonstration script that uses the LDAP search syntax to return the names of all the Active Directory user accounts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(objectCategory=User);Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Attributes in the Global Catalog

Description
Demonstration script that returns the names of the attributes that are found in the global catalog, and indicates whether those attributes are indexed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const IS_INDEXED = 1
Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
    "SELECT lDAPDisplayName,isMemberOfPartialAttributeSet,searchFlags " _
        & "FROM 'LDAP://CN=Schema,CN=Configuration,DC=fabrikam,DC=com'"_
            & " WHERE objectClass='attributeSchema'"
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
    WScript.Echo objRecordset.Fields("lDAPDisplayName")
    If objRecordset.Fields("isMemberOfPartialAttributeSet") Then
        WScript.Echo "In the global catalog."
    End If
    If IS_INDEXED AND objRecordset.Fields("searchFlags") Then
        WScript.Echo "Indexed."
    End If
    Wscript.Echo
    objRecordSet.MoveNext
Loop
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Computers Running Windows 2003

Description
Demonstration script that searches Active Directory for all computers running Windows Server 2003.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
    "SELECT Name, operatingSystemVersion FROM " _
        & "'LDAP://DC=fabrikam,DC=com'" _
            & " WHERE objectClass='computer' AND " _
                &"operatingSystemVersion = '5.2 (3790)'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Name: " & objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Global Security Groups

Description
Demonstration script that returns the names of all the global security groups in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT cn FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
        & "objectCategory='group' AND " _
            & "groupType= -2147483646 "
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("cn").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Multiple Attributes

Description
Demonstration script that returns multiple attributes from an Active Directory search.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT AdsPath,givenName,SN,title,telephoneNumber " _
        & "FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
            & "objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("ADsPath").Value
    Wscript.Echo objRecordSet.Fields("givenName").Value
    Wscript.Echo objRecordSet.Fields("SN").Value
    Wscript.Echo objRecordSet.Fields("title").Value
    Wscript.Echo _
        objRecordSet.Fields("telephoneNumber").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for User Accounts That Have Been Disabled

Description
Demonstration script that returns the names of all disabled user accounts in Active Directory. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(userAccountControl:1.2.840.113556.1.4.803:=2));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for User Phone Numbers Beginning with 425

Description
Demonstration script that returns all the user accounts with phone numbers in the 425 area code. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(telephoneNumber=425*));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Users Accounts That are Locked Out

Description
Demonstration script that returns a list of all locked-out user accounts. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(userAccountControl:1.2.840.113556.1.4.803:=10));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Users in a Specific Department

Description
Demonstration script that returns the names of all the users in the Finance Department. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(department=Finance));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Users in One of Two Departments

Description
Demonstration script that returns a list of all the users in either the Finance or the Research departments. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(|(department=Finance)" & _
        "(department=Research));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Users Not in a Specific Department

Description
Demonstration script that returns a list of all the users who are not members of the Finance Department. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(!(department=Finance)));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search For Users with Non-Expiring Passwords

Description
Demonstration script that returns a list of all users who have a password that does not expire. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(userAccountControl:1.2.840.113556.1.4.803:=65536));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Users Without a Phone Number

Description
Demonstration script that returns a list of all users who do not have a telephone number. Uses the LDAP search syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(!(telephoneNumber=*)));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sort a Recordset by User Name

Description
Demonstration script that returns a list of all the users in the fabrikam.com domain, and then sorts that list alphabetically by name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Sort on") = "Name"

objCommand.CommandText = _
    "SELECT Name FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
        & "objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use a Search to Modify Objects

Description
Demonstration script that returns a list of all the users in the Accounting Department, and then changes their department name to Finance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT ADsPath FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
        & "objectCategory='user' AND Department='Accounting'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strPath = objRecordSet.Fields("AdsPath").Value
    Set objUser = GetObject(strPath)
    objUser.Department = "Finance"
    objUser.SetInfo
objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use a Wildcard in a SQL Query

Description
Demonstration script that uses a wildcard search to return a list of all Active Directory groups whose common name begins with the letters HR.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT cn FROM 'LDAP://dc=fabrikam,dc=com' WHERE " _
        & "objectCategory='group' AND cn = 'HR*' "
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("cn").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Use an LDAP OR Filter in a Search

Description
Demonstration script showing the use of an OR filter in a LDAP query.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = _
    ";(&(objectCategory=User)" & _
        "(|(department=Finance)(department=Research)));Name;Subtree"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Auto-Generate a File Name

Description
Demonstration script that uses the FileSystemObject's GetTempName method to generate random file names. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")

For i = 1 to 10
    strTempFile = objFSO.GetTempName
    Wscript.Echo strTempFile
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Text File

Description
Demonstration script that creates a new, empty text file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\FSO\ScriptLog.txt")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create and Auto-Name a Text File

Description
Demonstration script that uses the FileSystemObject's GetTempName method to generate a file name, and then creates a file by that name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")

strPath = "C:\FSO"
strFileName = objFSO.GetTempName
strFullName = objFSO.BuildPath(strPath, strFileName)
Set objFile = objFSO.CreateTextFile(strFullName)
objFile.Close
objFSO.DeleteFile(strFullName)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the ODBC Default Value to Comma-Delimited When Reading Text Files

Description
Modifies the registry so that ODBC assumes that text files -- unless otherwise indicated -- are saved in comma-delimited format.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Jet\4.0\Engines\Text"
strValueName = "Format"
strValue = "CSVDelimited"
objReg.SetStringValue _
    HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the ODBC Default Value to Tab-Delimited When Reading Text Files

Description
Modifies the registry so that ODBC assumes that text files -- unless otherwise indicated -- are saved in tab-delimited format.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Jet\4.0\Engines\Text"
strValueName = "Format"
strValue = "TabDelimited"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a CSV File Using Database Techniques

Description
Demonstration script that uses ADO (Active Database Objects) to read a comma-separated-values text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = "C:\Databases\"

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & strPathtoTextFile & ";" & _
          "Extended Properties=""text;HDR=YES;FMT=Delimited"""

objRecordset.Open "SELECT * FROM PhoneList.csv", _
          objConnection, adOpenStatic, adLockOptimistic, adCmdText

Do Until objRecordset.EOF
    Wscript.Echo "Name: " & objRecordset.Fields.Item("Name")
    Wscript.Echo "Department: " & _
        objRecordset.Fields.Item("Department")
    Wscript.Echo "Extension: " & objRecordset.Fields.Item("Extension")
    objRecordset.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Fixed-Width Text File Using Database Techniques

Description
Demonstration script that uses ADO (Active Database Objects) to read a fixed-width text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = "C:\Databases\"

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=" & strPathtoTextFile & ";" & _
          "Extended Properties=""text;HDR=YES;FMT=FixedLength"""

objRecordset.Open "SELECT * FROM PhoneList.txt", _
          objConnection, adOpenStatic, adLockOptimistic, adCmdText

Do Until objRecordset.EOF
    Wscript.Echo "Name: " & objRecordset.Fields.Item("FirstName")
    Wscript.Echo "Department: " & objRecordset.Fields.Item("LastName")
    Wscript.Echo "Extension: " & objRecordset.Fields.Item("ID")
    objRecordset.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Text File Character-by-Character

Description
Demonstration script that uses the FileSystemObject to read a text file character-by-character, and individually echo those characters to the screen. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("C:\FSO\New Text Document.txt", 1)
Do Until objFile.AtEndOfStream
    strCharacters = objFile.Read(1)
    Wscript.Echo strCharacters
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Text File from the Bottom Up

Description
Demonstration script that uses the FileSystemObject to read a text file, and then displays the text file in inverse order (that is, beginning with the last line in the text file and ending with the first line).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Dim arrFileLines()
i = 0

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\FSO\ScriptLog.txt", 1)

Do Until objFile.AtEndOfStream
     Redim Preserve arrFileLines(i)
     arrFileLines(i) = objFile.ReadLine
     i = i + 1
Loop

objFile.Close

For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
    Wscript.Echo arrFileLines(l)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Read a Text File into an Array

Description
Demonstration script that uses the VBScript Split command to read a line from a commas-separated values file, and then place the individual items in that line into an array.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\servers and services.txt", ForReading)

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")
    Wscript.Echo "Server name: " & arrServiceList(0)
    For i = 1 to Ubound(arrServiceList)
        Wscript.Echo "Service: " & arrServiceList(i)
    Next
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify the Size of a File Before Reading It

Description
Demonstration script that uses the FileSystemObject to ensure that a text file is not empty before attempting to read it. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\Windows\Netlogon.log")

If objFile.Size > 0 Then
    Set objReadFile = objFSO.OpenTextFile("C:\Windows\Netlogon.log", 1)
    strContents = objReadFile.ReadAll
    Wscript.Echo strContents
    objReadFile.Close
Else
    Wscript.Echo "The file is empty."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Writing Data to a Text File

Description
Demonstration script that retrieves the status for all the services installed on a computer, and then saves the service name and status to a text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\scripts\service_status.txt", ForAppending, True)

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")
Set colServices = objWMIService.ExecQuery("Select * from Win32_Service")

For Each objService in colServices
    objTextFile.WriteLine(objService.DisplayName & vbTab & _
        objService.State)
Next
objTextFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy Text to the Clipboard

Description
Sample HTML script for copying text found in a text area named BasicTextArea to the clipboard.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    strCopy = BasicTextArea.Value
    document.parentwindow.clipboardData.SetData "text", strCopy
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Timer

Description
Sample HTML code for adding a timer to a Web page, This timer calls a function named RunScript every 5 seconds (5000 milliseconds).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub Window_OnLoad
    iTimerID = window.setInterval("RunScript", 5000, "VBScript")
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create an Instance of Internet Explorer

Description
Demonstration script that creates an instance of Internet Explorer, opened to a blank page.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objExplorer = WScript.CreateObject("InternetExplorer.Application")

objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=300
objExplorer.Height = 150
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Disable a Control

Description
Sample HTML code that disabled a dropdown list (named Dropdown1) on a Web page or HTA.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    DropDown1.Disabled = False
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display a Confirmation Box

Description
HTML code that displays a confirmation box on a Web page or HTA and then indicates which button the user clicked.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    blnAnswer = window.confirm("Are you sure you want to continue?")
    If blnAnswer Then
        Msgbox "You clicked the OK button"
    Else
        Msgbox "You clicked the Cancel button."
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display a Message Box

Description
Sample HTML function that displays a message box in a Web page or HTA.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Msgbox "Test"
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display Data in a New Window

Description
Sample HTML function that displays information in a new Internet Explorer window.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate("about:blank")
    objIE.ToolBar = 0
    objIE.StatusBar = 0
    Set objDoc = objIE.Document.Body
    strHTML = "This information is displayed in a separate window."
    objDoc.InnerHTML = strHTML
    objIE.Visible = True
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display the Print Dialog Box

Description
Sample HTML function that displays the Print dialog box in a Web page or HTA.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Window.Print()
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Selected Items in a Multi-select Listbox

Description
Sample HTML function that lists all the items that were selected in a multi-select listbox.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    For i = 0 to (Dropdown1.Options.Length - 1)
        If (Dropdown1.Options(i).Selected) Then
            strComputer = strComputer & Dropdown1.Options(i).Value & vbcrlf
        End If
    Next
    Msgbox strComputer
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Value of a Checkbox

Description
Sample HTML function that indicates whether a checkbox named BasicCheckbox has been checked or not.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    If BasicCheckbox.Checked Then
        Msgbox "The checkbox has been checked."
    Else
        Msgbox "The checkbox has not been checked."
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Value of a Dropdown List

Description
Sample HTML function that reports the value of a dropdown list named Dropwdown1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Msgbox DropDown1.Value
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Value of a Listbox

Description
Sample HTML function that reports the value of a listbox named Listbox1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Msgbox Listbox1.Value
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Value of a Password Box

Description
Sample HTML function that reports the value of a password box named PasswordArea.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Msgbox PasswordArea.Value
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Value of a Text Box

Description
Sample HTML function that reports the value of a text box named BasicTextBox.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Msgbox BasicTextBox.Value
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Cursor Type

Description
Sample HTML function that changes the Internet Explorer cursor to an hourglass. Other values you can set the cursor to include crosshair; default; hand; and help.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    document.body.style.cursor = "wait"
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Value of a SPAN

Description
Sample HTML function that changes the value of a SPAN named DataArea.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    DataArea.InnerHTML = "The computer did not respond when pinged."
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Value of a Text Area

Description
Sample HTML script that changes the text displayed in a multi-line text box.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    BasicTextArea.Value = "This information will be placed in the " & _
        "multi-line text box named BasicTextArea."
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Value of a Tooltip

Description
Sample HTML function that modifies the tool tip for a button named Run_Button.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Run_Button.Title = "You successfully changed the tool tip."
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Paste Text from the Clipboard

Description
Sample HTML function that pastes data from the clipboard into a SPAN named DataArea.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    DataArea.InnerHTML = document.parentwindow.clipboardData.GetData("text")
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Populate a Listbox Using the Contents of a Text File

Description
Sample HTML function that opens a text file and adds the contents to a listbox each time a Web page or HTA is loaded.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub Window_Onload
    ForReading = 1
    strNewFile = "computers.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile _
        (strNewFile, ForReading)
    Do Until objFile.AtEndOfStream
        strLine = objFile.ReadLine
        Set objOption = Document.createElement("OPTION")
        objOption.Text = strLine
        objOption.Value = strLine
        AvailableComputers.Add(objOption)
    Loop
    objFile.Close
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Prompt a User for Input

Description
Sample HTML function that prompts the user for input of some type, and then displays the information entered.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    strAnswer = window.prompt("Please enter the domain name.", "fabrikam.com")
    If IsNull(strAnswer) Then
        Msgbox "You clicked the Cancel button"
    Else
        Msgbox "You entered: " & strAnswer
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Reload a Page

Description
Sample HTML function that reloads a Web page or HTA.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Location.Reload(True)
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Run a Script Each Time a Page Loads

Description
Sample HTML function that displays a message box each time a Web page or HTA is loaded.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub Window_Onload
    Msgbox "The application has started."
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save Data to an HTML File

Description
Sample HTML function that saves the data found in a SPAN named DataArea to a text file named test.htm.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CreateTextFile("test.htm")
    Set objFile = objFSO.OpenTextFile("test.htm", 2)
    objFile.WriteLine DataArea.InnerHTML
    objFile.Close
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify That a Radio Button Has Been Selected

Description
Sample HTML function that indicates whether or not a radio button has been selected.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Sub RunScript
    If UserOption(0).Checked Then
        Msgbox "Option 1 was selected."
    End If
    If UserOption(1).Checked Then
        Msgbox "Option 2 was selected."
    End If
    If UserOption(2).Checked Then
        Msgbox "Option 3 was selected."
    End If
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Permanent Event Consumer

Description
Creates a permanent event consumer for monitoring changes in service status.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

Set objConsumerType = objWMIService.get("SMTPEventConsumer")
Set objConsumer = objConsumerType.SpawnInstance_
objConsumer.Name = "Service Monitor Consumer"
objConsumer.Message = "A service has changed state."
objConsumer.SMTPServer = "mailserver.fabrikam.com"
objConsumer.Subject = "Service state change"
objConsumer.ToLine = "administrator@fabrikam.com"
objConsumer.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Permanent Event Filter

Description
Creates a permanent event filter for monitoring changes in service status.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")

strFilterQuery = "Select * from __InstanceModificationEvent within 3 " & _
    "where TargetInstance isa 'Win32_Service'"
Set objFilterClass = objWMIService.get("__EventFilter")
Set objFilter = objFilterClass.SpawnInstance_
objFilter.Name = "Service Monitor Filter"
objFilter.QueryLanguage = "wql"
objFilter.Query = strFilterQuery
objFilter.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Abstract Classes in WMI

Description
Lists all WMI Abstract classes defined in the root\cimv2 namespace.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colClasses = objWMIService.SubclassesOf()

For Each objClass in colClasses
    For Each objClassQualifier In objClass.Qualifiers_
        If LCase(objClassQualifier.Name) = "abstract" Then
            WScript.Echo objClass.Path_.Class & ": " & _
            objClassQualifier.Name & "=" & _
            objClassQualifier.Value
        End If
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Dynamic Classes in WMI

Description
Lists all WMI Dynamic classes (including Association classes) defined in the root\cimv2 namespace.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colClasses = objWMIService.SubclassesOf()

For Each objClass in colClasses
    For Each objClassQualifier In objClass.Qualifiers_
        If LCase(objClassQualifier.Name) = "dynamic" Then
            WScript.Echo objClass.Path_.Class & ": " & _
            objClassQualifier.Name & "=" & _
            objClassQualifier.Value
        End If
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Properties and Methods for a WMI Class

Description
Lists the class qualifiers, properties, property qualifiers, methods, and method qualifiers for a specified WMI class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
strNameSpace = "root\cimv2"
strClass = "Win32_Service"

Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\" & strNameSpace & ":" & strClass)

WScript.Echo strClass & " Class Qualifiers"
WScript.Echo "------------------------------"
i = 1

For Each objClassQualifier In objClass.Qualifiers_
    If VarType(objClassQualifier.Value) = (vbVariant + vbArray) Then
        strQualifier = i & ". " & objClassQualifier.Name & " = " & _
            Join(objClassQualifier.Value, ",")
    Else
        strQualifier = i & ". " & objClassQualifier.Name & " = " & _
        objClassQualifier.Value
    End If
    WScript.Echo strQualifier
    strQualifier = ""
    i = i + 1
Next

WScript.Echo
WScript.Echo strClass & " Class Properties and Property Qualifiers"
WScript.Echo "------------------------------------------------------"
i = 1 : j = 1

For Each objClassProperty In objClass.Properties_
    WScript.Echo i & ". " & objClassProperty.Name
    For Each objPropertyQualifier In objClassProperty.Qualifiers_
        If VarType(objPropertyQualifier.Value) = (vbVariant + vbArray) Then
            strQualifier = i & "." & j & ". " & _
                objPropertyQualifier.Name & " = " & _
            Join(objPropertyQualifier.Value, ",")
        Else
            strQualifier = i & "." & j & ". " & _
                objPropertyQualifier.Name & " = " & _
            objPropertyQualifier.Value
        End If
        WScript.Echo strQualifier
        strQualifier = ""
        j = j + 1
    Next
    WScript.Echo
    i = i + 1 : j = 1
Next

WScript.Echo
WScript.Echo strClass & " Class Methods and Method Qualifiers"
WScript.Echo "-------------------------------------------------"
i = 1 : j = 1

For Each objClassMethod In objClass.Methods_
    WScript.Echo i & ". " & objClassMethod.Name
    For Each objMethodQualifier In objClassMethod.Qualifiers_
        If VarType(objMethodQualifier.Value) = (vbVariant + vbArray) Then
            strQualifier = i & "." & j & ". " & _
                objMethodQualifier.Name & " = " & _
            Join(objMethodQualifier.Value, ",")
        Else
            strQualifier = i & "." & j & ". " & _
                objMethodQualifier.Name & " = " & _
                    objMethodQualifier.Value
        End If
    WScript.Echo strQualifier
    strQualifier = ""
    j = j + 1
    Next

    WScript.Echo
    i = i + 1 : j = 1
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Properties and Methods of the Win32 Classes

Description
Returns the properties and methods for all the WMI Win32 classes (for example, Win32_Service, Win32_Process, Win32_NTEventLog, etc.).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

For Each objclass in objWMIService.SubclassesOf()
    intCounter=0
    If Left(objClass.Path_.Class,5) = "Win32" Then
        For Each Qualifier in objClass.Qualifiers_
            If UCase(Trim(Qualifier.Name)) = "ASSOCIATION" Then
                intCounter = 1
            End If
        Next
        If x = 0 Then
            strComputer = "."
            Set objWMIService = GetObject _
                ("winmgmts:{impersonationLevel=impersonate}!\\" & _
                    strComputer & "\root\cimv2")
            Set strClass = objWMIService.Get(objClass.Path_.Class)
            Wscript.Echo "PROPERTIES:"
            For each strItem in strClass.properties_
                Wscript.Echo objClass.Path_.Class & vbTab & strItem.name
            Next
            Wscript.Echo "METHODS:"
            For Each strItem in strClass.methods_
                Wscript.Echo objClass.Path_.Class & vbTab & strItem.name
            Next
        End If
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Properties for a WMI Class

Description
Lists the properties for a specified WMI class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
strNameSpace = "root\cimv2"
strClass = "Win32_Service"

Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\" & strNameSpace & ":" & strClass)

WScript.Echo strClass & " Class Properties"
WScript.Echo "------------------------------"

For Each objClassProperty In objClass.Properties_
    WScript.Echo objClassProperty.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Qualifiers for a WMI Class

Description
Lists the class qualifiers for a specified WMI class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
strNameSpace = "root\cimv2"
strClass = "Win32_Service"

Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\" & strNameSpace & ":" & strClass)

WScript.Echo strClass & " Class Qualifiers"
WScript.Echo "------------------------------"

For Each objClassQualifier In objClass.Qualifiers_
    If VarType(objClassQualifier.Value) = (vbVariant + vbArray) Then
        strQualifier = objClassQualifier.Name & " = " & _
            Join(objClassQualifier.Value, ",")
    Else
        strQualifier = objClassQualifier.Name & " = " & _
            objClassQualifier.Value
    End If
    WScript.Echo strQualifier
    strQualifier = ""
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the WMI cimV2 Classes

Description
Returns a list of all the WMI classes found in the cimv2 namespace.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

For Each objclass in objWMIService.SubclassesOf()
    Wscript.Echo objClass.Path_.Class
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the WMI Methods for a Class

Description
Lists the methods for a specified WMI class.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
strNameSpace = "root\cimv2"
strClass = "Win32_Service"

Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\" & strNameSpace & ":" & strClass)

WScript.Echo strClass & " Class Methods"
WScript.Echo "---------------------------"

For Each objClassMethod In objClass.Methods_
    WScript.Echo objClassMethod.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the WMI Namespaces

Description
Lists only those WMI namespaces immediately below the connected namespace.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root")

Set colNameSpaces = objWMIService.InstancesOf("__NAMESPACE")

For Each objNameSpace In colNameSpaces
    WScript.Echo objNameSpace.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the WMI Providers

Description
Lists all WMI Providers installed in the root\cimv2 namespace.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colWin32Providers = objWMIService.InstancesOf("__Win32Provider")

For Each objWin32Provider In colWin32Providers
    WScript.Echo objWin32Provider.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the WMI Settings

Description
Returns a list of WMI settings configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWMISettings = objWMIService.ExecQuery _
    ("Select * from Win32_WMISetting")

For Each objWMISetting in colWMISettings
    Wscript.Echo "Default namespace: " & _
        objWMISetting.ASPScriptDefaultNamespace
    Wscript.Echo "Backup interval: " & objWMISetting.BackupInterval
    Wscript.Echo "Last backup: " & objWMISetting.BackupLastTime
    Wscript.Echo "Build version: " & objWMISetting.BuildVersion
    Wscript.Echo "Repository directory: " & _
        objWMISetting.DatabaseDirectory
    Wscript.Echo "Enable events: " & objWMISetting.EnableEvents
    Wscript.Echo "High threshold on client objects: " & _
        objWMISetting.HighThresholdOnClientObjects
    Wscript.Echo "High threshold on events: " & _
        objWMISetting.HighThresholdOnEvents
    Wscript.Echo "Installation folder: " & _
        objWMISetting.InstallationDirectory
    Wscript.Echo "Logging folder: " & objWMISetting.LoggingDirectory
    Wscript.Echo "Logging level: " & objWMISetting.LoggingLevel
    Wscript.Echo "Low threshold on client objects: " & _
        objWMISetting.LowThresholdOnClientObjects
    Wscript.Echo "Low threshold on events: " & _
        objWMISetting.LowThresholdOnEvents
    Wscript.Echo "Maximum log file size: " & objWMISetting.MaxLogFileSize
    Wscript.Echo "Maximum wait time on client objects: " & _
        objWMISetting.MaxWaitOnClientObjects
    Wscript.Echo "Maximum wait time on events: " & _
        objWMISetting.MaxWaitOnEvents
    Wscript.Echo "MOF Self-install folder: " & _
        objWMISetting.MofSelfInstallDirectory
    For i = 0 to Ubound(objWMISetting.AutorecoverMofs)
        Wscript.Echo "Autorecover MOF: " & _
            objWMISetting.AutorecoverMofs(i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All WMI Namespaces

Description
Lists all WMI namespace on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Call EnumNameSpaces("root")

Sub EnumNameSpaces(strNameSpace)
    WScript.Echo strNameSpace
    Set objWMIService=GetObject _
        ("winmgmts:{impersonationLevel=impersonate}\\" & _
            strComputer & "\" & strNameSpace)

    Set colNameSpaces = objWMIService.InstancesOf("__NAMESPACE")

    For Each objNameSpace In colNameSpaces
        Call EnumNameSpaces(strNameSpace & "\" & objNameSpace.Name)
    Next
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Computer Hardware

Description
Returns information about the pointing devices installed on a computer. Used as an example of how to retrieve hardware information using WMI.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colMice = objWMIService.ExecQuery _
    ("Select * from Win32_PointingDevice")

For Each objMouse in colMice
    Wscript.Echo "Hardware Type: " & objMouse.HardwareType
    Wscript.Echo "Number of Buttons: " & objMouse.NumberOfButtons
    Wscript.Echo "Status: " & objMouse.Status
    Wscript.Echo "PNP Device ID: " & objMouse.PNPDeviceID
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List System Information

Description
Uses WMI to retrieve the same data found in the System Information applet.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colSettings
    Wscript.Echo "OS Name: " & objOperatingSystem.Name
    Wscript.Echo "Version: " & objOperatingSystem.Version
    Wscript.Echo "Service Pack: " & _
        objOperatingSystem.ServicePackMajorVersion _
            & "." & objOperatingSystem.ServicePackMinorVersion
    Wscript.Echo "OS Manufacturer: " & objOperatingSystem.Manufacturer
    Wscript.Echo "Windows Directory: " & _
        objOperatingSystem.WindowsDirectory
    Wscript.Echo "Locale: " & objOperatingSystem.Locale
    Wscript.Echo "Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory
    Wscript.Echo "Total Virtual Memory: " & _
        objOperatingSystem.TotalVirtualMemorySize
    Wscript.Echo "Available Virtual Memory: " & _
        objOperatingSystem.FreeVirtualMemory
    Wscript.Echo "Size stored in paging files: " & _
        objOperatingSystem.SizeStoredInPagingFiles
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")

For Each objComputer in colSettings
    Wscript.Echo "System Name: " & objComputer.Name
    Wscript.Echo "System Manufacturer: " & objComputer.Manufacturer
    Wscript.Echo "System Model: " & objComputer.Model
    Wscript.Echo "Time Zone: " & objComputer.CurrentTimeZone
    Wscript.Echo "Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_Processor")

For Each objProcessor in colSettings
    Wscript.Echo "System Type: " & objProcessor.Architecture
    Wscript.Echo "Processor: " & objProcessor.Description
Next

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")

For Each objBIOS in colSettings
    Wscript.Echo "BIOS Version: " & objBIOS.Version
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Default WMI Namespace

Description
Retrieves and displays the current WMI "Default namespace for scripting" setting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colWMISettings = objWMIService.InstancesOf("Win32_WMISetting")

For Each objWMISetting in colWMISettings
    Wscript.Echo "Default namespace for scripting: " & _
    objWMISetting.ASPScriptDefaultNamespace
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Definition of a WMI Class in MOF Format

Description
Retrieves and displays the textual representation of a WMI class definition in MOF (Managed Object Format) syntax.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
strNameSpace = "root\cimv2"
strClass = "Win32_Service"

Const wbemFlagUseAmendedQualifiers = &h20000

Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\" & strNameSpace)

Set objClass = objWMIService.Get(strClass, wbemFlagUseAmendedQualifiers)
strMOF = objClass.GetObjectText_

WScript.Echo strMOF

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Default WMI Namespace

Description
Sets the WMI "Default namespace for scripting" setting to "root\cimv2".

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\cimv2")

Set colWMISettings = objWMIService.InstancesOf("Win32_WMISetting")

For Each objWMISetting in colWMISettings
    objWMISetting.ASPScriptDefaultNamespace = "root\cimv2"
    objWMISetting.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify WMI Settings

Description
Configures the WMI backup interval and logging level.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colWMISettings = objWMIService.ExecQuery _
    ("Select * from Win32_WMISetting")

For Each objWMISetting in colWMISettings
    objWMISetting.BackupInterval = 60
    objWMISetting.LoggingLevel = 2
    objWMISetting.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Baseline Performance

Description
Uses cooked performance counters and the SWbemRefresher object to monitor three performance counters on a computer, and then save that data to a text file.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ForAppending = 8

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.Swbemrefresher")
Set objMemory = objRefresher.AddEnum _
  (objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").objectSet
Set objDiskSpace = objRefresher.AddEnum _
  (objWMIService, "Win32_PerfFormattedData_PerfDisk_LogicalDisk").objectSet
Set objQueueLength = objRefresher.AddEnum _
  (objWMIService, "Win32_PerfFormattedData_PerfNet_ServerWorkQueues").objectSet
objRefresher.Refresh

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile _
  ("c:\scripts\performance.csv", ForAppending, True)

For i = 1 to 10
  For Each intAvailableBytes in objMemory
      objLogFile.Write(intAvailableBytes.AvailableMBytes) & ","
  Next
  For each intQueueLength in objDiskSpace
      objLogFile.Write(intQueueLength.CurrentDiskQueueLength) & ","
  Next
  For each intServerQueueLength in objQueueLength
      objLogFile.Write(intServerQueueLength.QueueLength) & ","
  Next
  objLogFile.Write VbCrLf
  Wscript.Sleep 10000
  objRefresher.Refresh
Next
objLogFile.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a New Record to a Table

Description
Demonstration script that adds a new record to a database.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "SELECT * FROM GeneralProperties" , _
    objConnection, adOpenStatic, adLockOptimistic

objRecordSet.AddNew
objRecordSet("ComputerName") = "atl-ws-01"
objRecordSet("Department") = "Human Resources"
objRecordSet("OSName") = "Microsoft Windows XP Professional"
objRecordSet("OSVersion") = "5.1.2600"
objRecordSet("OSManufacturer") = "Microsoft Corporation"
objRecordSet.Update

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear a Database Table

Description
Demonstration script that deletes all the records in a table named Hardware from an ADO database with the DSN "Inventory."

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "Delete * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Connect to a SQL Server Database

Description
Demonstration script that connects to a SQL Server database named Northwind on a computer named atl-sql-01.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider=SQLOLEDB;Data Source=atl-sql-01;" & _
        "Trusted_Connection=Yes;Initial Catalog=Northwind;" & _
             "User ID=fabrikam\kenmyer;Password=34DE6t4G!;"

objRecordSet.Open "SELECT * FROM Customers", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo objRecordSet.RecordCount

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Connect to an ADO Database

Description
Demonstration script that deletes all the records in a table named Hardware from an ADO database with the DSN "Inventory."

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic
objRecordset.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a JET Database

Description
Demonstration script that creates a new database named New_db.mdb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConnection = CreateObject("ADOX.Catalog")

objConnection.Create _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = new_db.mdb"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Table in a JET Database

Description
Demonstration script that creates a new table in a database named New_db.mdb.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open _
    "Provider= Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=new_db.mdb"

objConnection.Execute "CREATE TABLE EventTable(" & _
    "EventKey COUNTER ," & _
    "Category TEXT(50) ," & _
    "ComputerName TEXT(50) ," & _
    "EventCode INTEGER ," & _
    "RecordNumber INTEGER ," & _
    "SourceName TEXT(50) ," & _
    "TimeWritten DATETIME ," & _
    "UserName TEXT(50) ," & _
    "EventType TEXT(50) ," & _
    "Logfile TEXT(50) ," & _
    "Message MEMO)"

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Record from a Recordset

Description
Demonstration script that deletes the record for a computer named WebServer from an ADO database with the DSN "Inventory."

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic
strSearchCriteria = "ComputerName = 'WebServer'"
objRecordSet.Find strSearchCriteria
objRecordset.Delete
objRecordset.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete Multiple Records from a Table

Description
Demonstration script that deletes all records from a database where the Department field is equal to Human Resources.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "DELETE * FROM GeneralProperties WHERE " & _
    "Department = 'Human Resources'", _
        objConnection, adOpenStatic, adLockOptimistic

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Basic Statistics Derived from a Recordset

Description
Demonstration script that lists the different operating systems found in a database, as well as the number of computers running each operating system.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "SELECT OSName, Count(OSName) AS CountOfOSName" & _
   " FROM GeneralProperties GROUP BY OSName ORDER BY Count(OSName) DESC", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("OSName") & _
        vbTab & objRecordset.Fields.Item("CountOfOSName")
    objRecordset.MoveNext
Loop

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Number of Records in a Recordset

Description
Demonstration script that returns the number of records in a recordset.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable" , _
    objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo "Number of records: " & objRecordset.RecordCount

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Top 25 Records in a Recordset

Description
Demonstration script that queries a database for the 25 computers with the most physical memory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "SELECT TOP 25 * FROM GeneralProperties " & _
    "ORDER BY TotalPhysicalMemory DESC", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("ComputerName") & _
        vbTab & objRecordset.Fields.Item("TotalPhysicalMemory")
    objRecordset.MoveNext
Loop

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Unique Records in a Recordset

Description
Demonstration script that returns the unique operating systems found in a database.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "SELECT DISTINCT OSName FROM " & _
    "GeneralProperties ORDER BY OSName", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("OSName")
    objRecordset.MoveNext
Loop

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Open a Database Using a DSN

Description
Demonstration script that uses a DSN to open a database named Northwind.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Northwind;fabrikam\kenmyer;34ghfn&!j"

objRecordSet.Open "SELECT * FROM Customers", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo objRecordSet.RecordCount

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Open Two Recordsets

Description
Demonstration script that works with two separate recordsets.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
Set objRecordSet2 = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider= Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=inventory.mdb"

objRecordSet.Open "SELECT * FROM GeneralProperties Where ComputerName = 'Computer1'", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

objRecordSet2.Open "SELECT * FROM Storage Where ComputerName = 'Computer1'", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet2.MoveFirst

Do Until objRecordset.EOF
    Wscript.Echo objRecordset.Fields.Item("ComputerName")
    Wscript.Echo objRecordset.Fields.Item("OSName")
    objRecordSet.MoveNext
Loop

Do Until objRecordset2.EOF
    Wscript.Echo objRecordset2.Fields.Item("DriveName"), _
        objRecordset2.Fields.Item("DriveDescription")
    objRecordSet2.MoveNext
Loop

objRecordSet.Close
objRecordSet2.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save a Recordset in XML format

Description
Demonstration script that retrieves data from a database and then saves that data in XML format.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adPersistXML = 1

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider= Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=eventlogs.mdb"
objRecordSet.Open "SELECT * FROM EventTable" , _
    objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

objRecordSet.Save "output.xml", adPersistXML

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search a Database Using a LIKE Query

Description
Demonstration script that searches a database for all records where the Message field contains the word PowerPoint.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable WHERE " & _
    "Message Like '%PowerPoint%'", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo "Number of records: " & objRecordset.RecordCount

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search a Database Using Numeric Criteria

Description
Demonstration script that searches a database for all records where the event code is equal to the numeric value 1054.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable " & _
    "WHERE EventCode = 1054", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo "Number of records: " & objRecordset.RecordCount

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search a Database Using Variable Criteria

Description
Demonstration script that searches a database for all records where the TimeWritten field is equal to the value of the variable dtmDate.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider= Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=eventlogs.mdb"

dtmDate = "#1/7/2004#"

objRecordSet.Open "SELECT * FROM EventTable Where TimeWritten = " & dtmDate, objconnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordset.Fields.Item("EventCode") & vbTab _
        & objRecordset.Fields.Item("Logfile")
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a Record in a Recordset

Description
Searches an ADO database with a DSN of "Inventory" looking for a specific computer record.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic
strSearchCriteria = "ComputerName = 'WebServer'"
objRecordSet.Find strSearchCriteria

If objRecordset.EOF Then
    Wscript.Echo "Record cannot be found."
Else
    Wscript.Echo "Record found."
End If

objRecordset.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Searching a Database Using String Criteria

Description
Demonstration script that searches a database for all records where the Type field is equal to Error.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable " & _
    "WHERE Type = 'Error'", objConnection, adOpenStatic, _
         adLockOptimistic

objRecordSet.MoveFirst

Wscript.Echo "Number of records: " & objRecordset.RecordCount

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sort a Recordset

Description
Demonstration script that sorts a recordset (in ascending order) on the EventCode field.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable " & _
    "ORDER BY EventCode ASC", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields.Item("EventCode"), objRecordSet.Fields.Item("Logfile")
    objRecordSet.MoveNext
Loop

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sort a Recordset on Multiple Fields

Description
Demonstration script that sorts a recordset on two fields: first by EventCode (in ascending order), and then by Logfile (in descending order).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = eventlogs.mdb"

objRecordSet.Open "SELECT * FROM EventTable " & _
    "ORDER BY EventCode ASC, Logfile DESC", _
        objConnection, adOpenStatic, adLockOptimistic

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields.Item("EventCode"), objRecordSet.Fields.Item("Logfile")
    objRecordSet.MoveNext
Loop

objRecordSet.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Update a Record in a Recordset

Description
Demonstration script that updates sound card information for a computer named Webserver.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
    adOpenStatic, adLockOptimistic
strSearchCriteria = "ComputerName = 'WebServer'"
objRecordSet.Find strSearchCriteria

Set colSoundCards = GetObject("winmgmts:").ExecQuery _
    ("Select * from Win32_SoundDevice")

For Each objSoundCard in colSoundCards
    objRecordset("ComputerName") = objSoundCard.SystemName
    objRecordset("Manufacturer") = objSoundCard.Manufacturer
    objRecordset("ProductName") = objSoundCard.ProductName
    objRecordset.Update
Next

objRecordset.Close
objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Update Multiple Records in a Recordset

Description
Demonstration script that sets the value of the Department field to Accounting for all the records in a table.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const adOpenStatic = 3
Const adLockOptimistic = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source = inventory.mdb"

objRecordSet.Open "UPDATE GeneralProperties SET " & _
    "Department = 'Accounting'", _
        objConnection, adOpenStatic, adLockOptimistic

objConnection.Close

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sign a Script Programmatically

Description
Uses the Scripting Runtime Signer object to digitally sign a script. Requires a valid digital certificate.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objSigner = WScript.CreateObject("Scripting.Signer")
objSigner.SignFile "C:\Scripts\CreateUsers.vbs", "IT Department"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Sign All the Scripts in a Folder

Description
Uses the Scripting Runtime Signer object to digitally sign all the scripts in a folder. Requires a valid digital certificate.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objSigner = WScript.CreateObject("Scripting.Signer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\scripts")
Set colListOfFiles = objFolder.Files

For Each objFile in colListOfFiles
    objSigner.SignFile objFile.Path, "IT Department"
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify a Script Signature

Description
Verifies that an individual script has been digitally signed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

blnShowGUI = False

Set objSigner = WScript.CreateObject("Scripting.Signer")
blnIsSigned = objSigner.VerifyFile("C:\Scripts\CreateUser.vbs", blnShowGUI)

If blnIsSigned Then
    WScript.Echo "Script has been signed."
Else
   WScript.Echo " Script has not been signed."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify Signatures for All the Scripts in a Folder

Description
Verifies that all the scripts in the C:\Scripts folder have been digitally signed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

blnShowGUI = False

set objSigner = WScript.CreateObject("Scripting.Signer")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Scripts\")
Set colListOfFiles = objFolder.Files

For Each objFile in colListOfFiles
    If Right(objFile.Name, 3) = "vbs" Then
        blnIsSigned = objSigner.VerifyFile(objFile.Path, blnShowGUI)
        If blnIsSigned then
            WScript.Echo objFile.Name & " has been signed."
        Else
            WScript.Echo objFile.Name & " has not been signed."
        End If
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Installed Hot Fixes

Description
Returns a list of all the hot fixes installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuickFixes = objWMIService.ExecQuery _
    ("Select * from Win32_QuickFixEngineering")

For Each objQuickFix in colQuickFixes
    Wscript.Echo "Computer: " & objQuickFix.CSName
    Wscript.Echo "Description: " & objQuickFix.Description
    Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
    Wscript.Echo "Installation Date: " & objQuickFix.InstallDate
    Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Latest Installed Service Pack

Description
Returns the last service pack to be installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
    Wscript.Echo objOperatingSystem.ServicePackMajorVersion  _
        & "." & objOperatingSystem.ServicePackMinorVersion
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Component Information

Description
Displays information about Services for UNIX components.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from SFU_Component")

For Each objItem in colItems
    Wscript.Echo "Component: " & objItem.Component
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Tab Number: " & objItem.TabNum
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Domain Information

Description
Displays information about Services for UNIX domains.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from SFU_Domain")

For Each objItem in colItems
    Wscript.Echo "DC: " & objItem.DC
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Domain: " & objItem.Domain
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Maps: " & objItem.Maps
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Dummy Information

Description
Displays Services for UNIX dummy information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from SFU_Dummy")

For Each objItem in colItems
    Wscript.Echo "Dummy: " & objItem.Dummy
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Global Settings

Description
Displays global Services for UNIX settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from GlobalSettings_Reg")

For Each objItem in colItems
    Wscript.Echo "Dummy: " & objItem.Dummy
    Wscript.Echo "Key Name: " & objItem.KeyName
    For Each strServer in objItem.MappingServers
        Wscript.Echo "Mapping Server: " & strServer
    Next
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Mapper Settings

Description
Displays mapper settings for Services for UNIX.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Mapper_Settings")

For Each objItem in colItems
    Wscript.Echo "Additional Map Definitions: " & _
        objItem.AdditionalMapDefinitions
    Wscript.Echo "Advanced Group Maps: " & _
        objItem.AdvancedGroupMaps
    Wscript.Echo "Advanced User Maps: " & _
        objItem.AdvancedUserMaps
    Wscript.Echo "Anonymous GID: " & objItem.AnonymousGid
    Wscript.Echo "Anonymous UID: " & objItem.AnonymousUid
    Wscript.Echo "Anonymous Unix User: " & _
        objItem.AnonymousUnixUser
    Wscript.Echo "Authentication Type: " & objItem.AuthType
    Wscript.Echo "Backup File Name: " & objItem.BackupFileName
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Group File Name: " & objItem.GroupFileName
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Logging Level: " & objItem.LoggingLevel
    Wscript.Echo "Map File Name: " & objItem.MapFileName
    Wscript.Echo "NIS Domain: " & objItem.NisDomain
    Wscript.Echo "NIS Server: " & objItem.NisServer
    Wscript.Echo "NT Domain: " & objItem.NTDomain
    Wscript.Echo "NT Domain2: " & objItem.NTDomain2
    Wscript.Echo "Password File Name: " & objItem._
        PasswdFileName
    Wscript.Echo "Refresh Interval: " & _
        objItem.RefreshInterval
    Wscript.Echo "Restore File Name: " & _
        objItem.RestoreFileName
    Wscript.Echo "Security: " & objItem.Security
    Wscript.Echo "Server Type: " & objItem.ServerType
    Wscript.Echo "Write Block: " & objItem.WriteBlock
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Mapping Server Settings

Description
Displays mapping server settings for Services for UNIX.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from MapServer_Reg")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "KeyName: " & objItem.KeyName
    Wscript.Echo "ReadConfig: " & objItem.ReadConfig
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Remote Settings

Description
Displays Services for UNIX remote settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from SFU_Remote")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Machine: " & objItem.Machine
    Wscript.Echo "Path: " & objItem.Path
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SFU Version Information

Description
Displays Services for UNIX version information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from version_info")

For Each objItem in colItems
    Wscript.Echo "Current release: " & objItem.curRel
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "PUD: " & objItem.pid
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the SFU Product Version

Description
Displays the Services for UNIX product version.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery("Select * from ProductVer")

For Each objItem in colItems
    Wscript.Echo "KeyName: " & objItem.KeyName
    Wscript.Echo "Operating System Version: " & objItem.OsVersion
    Wscript.Echo "Software Type: " & objItem.SoftwareType
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the SFU Windows Directory

Description
Displays the Services for UNIX Windows directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from SFU_Windir")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Windows directory: " & objItem.windir
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify SFU Mapper Settings

Description
Displays Services for UNIX mapper settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Mapper_Settings Where KeyName = 'CurrentVersion'")

For Each objItem in colItems
    objItem.LoggingLevel = 1
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Authentication Settings

Description
Displays Services for UNIX NFS client authentication settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Authenticate")

For Each objItem in colItems
    Wscript.Echo "Authentication Type: " & objItem.AuthType
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "NIS Domain: " & objItem.NISDomain
    Wscript.Echo "NIS Server: " & objItem.NISServer
    Wscript.Echo "NT Domain: " & objItem.NTDomain
    Wscript.Echo "PC NFSD Server: " & objItem.PCNFSDServer
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client File Settings

Description
Displays Services for UNIX NFS client file settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Files")

For Each objItem in colItems
    Wscript.Echo "Access: " & objItem.Access
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Global Settings

Description
Displays Services for UNIX NFS client global settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Reg")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Read Configuration: " & objItem.ReadConfig
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Mapping Server Settings

Description
Displays Services for UNIX NFS client mapping server settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_MapSvr")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Map Server: " & objItem.MapSvr
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Performance Information

Description
Displays Services for UNIX NFS client performance information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Perf")

For Each objItem in colItems
    Wscript.Echo "AutoTuning: " & objItem.AutoTuning
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Defaults: " & objItem.Defaults
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Mount Type: " & objItem.MountType
    Wscript.Echo "Prefer TCP: " & objItem.PreferTCP
    Wscript.Echo "Read Buffer: " & objItem.ReadBuffer
    Wscript.Echo "Retries: " & objItem.Retries
    Wscript.Echo "Timeout: " & objItem.Timeout
    Wscript.Echo "Write Buffer: " & objItem.WriteBuffer
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Prefer TCP Settings

Description
Displays Services for UNIX NFS client TCP preference information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_PreferTCP")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Prefer TCP: " & objItem.PreferTCP
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Client Security Settings

Description
Displays Services for UNIX NFS client security settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Security")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Security: " & objItem.Security
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Auditing Settings

Description
Displays Services for UNIX NFS server auditing settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Auditing")

For Each objItem in colItems
    Wscript.Echo "Audit: " & objItem.Audit
    Wscript.Echo "Audit Bits: " & objItem.AuditBits
    Wscript.Echo "Check Space: " & objItem.CheckSpace
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "File Maximum Size: " & objItem.FileMaxSize
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Log File: " & objItem.LogFile
    Wscript.Echo "Minimum Space: " & objItem.MinSpace
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Authentication Settings

Description
Displays Services for UNIX NFS server authentication settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Authenticate")

For Each objItem in colItems
    Wscript.Echo "Authentication Type: " & objItem.AuthType
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "NIS Domain: " & objItem.NISDomain
    Wscript.Echo "NIS Server: " & objItem.NISServer
    Wscript.Echo "NT Domain: " & objItem.NTDomain
    Wscript.Echo "PC NFSD Server: " & objItem.PCNFSDServer
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Character Translation Settings

Description
Displays Services for UNIX NFS server character translation settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_SvSet_CharTran")

For Each objItem in colItems
    Wscript.Echo "Character Translation: " & objItem.CharacterTranslation
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server File Settings

Description
Displays Services for UNIX NFS server file settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Files")

For Each objItem in colItems
    Wscript.Echo "Case: " & objItem.Case
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Grace Period: " & objItem.GracePeriod
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Timeout: " & objItem.Timeout
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Global Settings

Description
Displays Services for UNIX NFS server global settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Reg")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Read Configuration: " & objItem.ReadConfig
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Mapping Server Settings

Description
Displays Services for UNIX NFS server mapping server settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_MapSvr")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Map Server: " & objItem.MapSvr
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Security Settings

Description
Displays Services for UNIX NFS server security settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Security")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Security: " & objItem.Security
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NFS Server Settings

Description
Displays Services for UNIX NFS server settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_SvSet")

For Each objItem in colItems
    Wscript.Echo "Case Sensitive: " & objItem.CaseSensitive
    Wscript.Echo "CDFS Case: " & objItem.CdfsCase
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Directory Cache Pages: " & _
        objItem.DirectoryCachePages
    Wscript.Echo "Dot Files Hidden: " & objItem.DotFilesHidden
    Wscript.Echo "FAT Case: " & objItem.FatCase
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Logon TimeOut: " & objItem.LogonTimeOut
    Wscript.Echo "Maximum Handle Cache Size: " & _
        objItem.MaxHandleCacheSize
    Wscript.Echo "NTFS Case: " & objItem.NtfsCase
    Wscript.Echo "RdWr Handle LifeTime: " & _
        objItem.RdWrHandleLifeTime
    Wscript.Echo "Register TCP: " & objItem.RegisterTcp
    Wscript.Echo "Register Version 3: " & _
        objItem.RegisterVersion3
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the NFS Server Version

Description
Displays Services for UNIX NFS server version.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_CurrentVersion")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Path Name: " & objItem.PathName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NFS Client Performance Settings

Description
Displays Services for UNIX NFS client performance settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSClient_Perf Where KeyName = 'Defaults'")

For Each objItem in colItems
    objItem.Retries = 2
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NFS Server Auditing Settings

Description
Demonstration script that modifies a Services for UNIX NFS server auditing setting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_Auditing Where KeyName = 'Parameters'")

For Each objItem in colItems
    objItem.Audit = 1
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify NFS Server Settings

Description
Demonstration script that modifies a Services for UNIX NFS server setting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from NFSServer_SvSet Where KeyName = 'Parameters'")

For Each objItem in colItems
    objItem.CaseSensitive = 0
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Telnet Server Auditing Settings

Description
Displays Services for UNIX Telnet server auditing settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Telnet_Auditing")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Event Logging Enabled: " & _
        objItem.EventLoggingEnabled
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Log Administrator Attempts: " & _
        objItem.LogAdminAttempts
    Wscript.Echo "Log Events: " & objItem.LogEvents
    Wscript.Echo "Log Failures: " & objItem.LogFailures
    Wscript.Echo "Log File: " & objItem.LogFile
    Wscript.Echo "Log File Size: " & objItem.LogFileSize
    Wscript.Echo "Log To File: " & objItem.LogToFile
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Telnet Server Authentication Settings

Description
Displays Services for UNIX Telnet server authentication settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Telnet_Authenticate")

For Each objItem in colItems
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Mechanism: " & objItem.Mechanism
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Telnet Server Information

Description
Displays Services for UNIX Telnet server information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Tlnt_Reg")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Read Configuration: " & objItem.ReadConfig
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Telnet Server License Information

Description
Displays Services for UNIX Telnet server license information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from TelnetServer_Licences")

For Each objItem in colItems
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Licenses: " & objItem.Licences
    Wscript.Echo "Mode: " & objItem.Mode
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Telnet Server Settings

Description
Displays Services for UNIX Telnet server settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from TelnetServer_Settings")

For Each objItem in colItems
    Wscript.Echo "Alt Key Mapping: " & objItem.AltKeyMapping
    Wscript.Echo "Default: " & objItem.Default
    Wscript.Echo "Default Domain: " & objItem.DefaultDomain
    Wscript.Echo "Idle Session Timeout: " & _
        objItem.IdleSessionTimeout
    Wscript.Echo "Idle Session Timeout Backup: " & _
        objItem.IdleSessionTimeoutBkup
    Wscript.Echo "Key Name: " & objItem.KeyName
    Wscript.Echo "Kill All: " & objItem.KillAll
    Wscript.Echo "Maximum Connections: " & objItem.MaxConnections
    Wscript.Echo "Maximum Failed Logins: " & _
        objItem.MaxFailedLogins
    Wscript.Echo "Mode Operation: " & objItem.ModeOperation
    Wscript.Echo "Telnet Port: " & objItem.TelnetPort
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Telnet Auditing Settings

Description
Demonstration script that modifies a Services for UNIX Telnet auditing setting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Telnet_Auditing Where KeyName = 'Defaults'")

For Each objItem in colItems
    objItem.LogEvents = 1
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Telnet Server Settings

Description
Demonstration script that modifies a Services for UNIX Telnet server setting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\sfuadmin")

Set colItems = objWMIService.ExecQuery _\
    ("Select * from TelnetServer_Settings Where KeyName = 'Defaults'")

For Each objItem in colItems
    objItem.DefaultDomain = "fabrikam.com"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Shadow Copy

Description
Creates a client-accessible shadow copy for drive C.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const VOLUME = "C:\"
Const CONTEXT = "ClientAccessible"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objShadowStorage = objWMIService.Get("Win32_ShadowCopy")
errResult = objShadowStorage.Create(VOLUME, CONTEXT, strShadowID)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Shadow Copy Storage Area

Description
Creates a shadow copy storage area -- on drive E -- for storing shadow copies of drive C. This script reserves 130,023,424 bytes of storage space for the shadow copies.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const VOLUME = "C:\"
Const DIFFERENTIAL_VOLUME = "E:\"
Const MAXIMUM_SPACE = 130023424

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objShadowStorage = objWMIService.Get("Win32_ShadowStorage")
errResult = objShadowStorage.Create(VOLUME, DIFFERENTIAL_VOLUME, MAXIMUM_SPACE)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Shadow Copies on a Computer

Description
Deletes all the shadow copies stored on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
)
Set colItems = objWMIService.ExecQuery("Select * From Win32_ShadowCopy")

For Each objItem in colItems
    objItem.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Shadow Copy Storage Areas

Description
Deletes all the shadow copy storage areas on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * From Win32_ShadowStorage")

For Each objItem in colItems
    objItem.Delete_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Shadow Copies on a Computer

Description
Enumerates the properties of all the shadow copies stored on a server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowCopy")

For Each objItem in colItems
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Client accessible: " & objItem.ClientAccessible
    Wscript.Echo "Count: " & objItem.Count
    Wscript.Echo "Device object: " & objItem.DeviceObject
    Wscript.Echo "Differential: " & objItem.Differential
    Wscript.Echo "Exposed locally: " & objItem.ExposedLocally
    Wscript.Echo "Exposed name: " & objItem.ExposedName
    Wscript.Echo "Exposed remotely: " & objItem.ExposedRemotely
    Wscript.Echo "Hardware assisted: " & objItem.HardwareAssisted
    Wscript.Echo "Imported: " & objItem.Imported
    Wscript.Echo "No auto release: " & objItem.NoAutoRelease
    Wscript.Echo "Not surfaced: " & objItem.NotSurfaced
    Wscript.Echo "No writers: " & objItem.NoWriters
    Wscript.Echo "Originating machine: " & objItem.OriginatingMachine
    Wscript.Echo "Persistent: " & objItem.Persistent
    Wscript.Echo "Plex: " & objItem.Plex
    Wscript.Echo "Provider ID: " & objItem.ProviderID
    Wscript.Echo "Service machine: " & objItem.ServiceMachine
    Wscript.Echo "Set ID: " & objItem.SetID
    Wscript.Echo "State: " & objItem.State
    Wscript.Echo "Transportable: " & objItem.Transportable
    Wscript.Echo "Volume name: " & objItem.VolumeName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Shadow Copy Providers

Description
Returns the properties of all the shadow copy providers installed on a computer. For most computers, there will be only the default shadow copy provider included with the operating system.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowProvider")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "CLSID: " & objItem.CLSID
    Wscript.Echo "ID: " & objItem.ID
    Wscript.Echo "Type: " & objItem.Type
    Wscript.Echo "Version: " & objItem.Version
    Wscript.Echo "Version ID: " & objItem.VersionID
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Shadow Copy Storage Areas on a Computer

Description
Retrieves a list of all the shadow copy storage areas on a computer, as well as the properties of each storage area.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowStorage")

For Each objItem in colItems
    Wscript.Echo "Volume: " & objItem.Volume
    Wscript.Echo "Allocated space: " & objItem.AllocatedSpace
    Wscript.Echo "Differential volume: " & objItem.DiffVolume
    Wscript.Echo "Maximum space: " & objItem.MaxSpace
    Wscript.Echo "Used space: " & objItem.UsedSpace
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Shadow Copy Settings

Description
Retrieves the shadow copy settings configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowContext")

For Each objItem in colItems
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Client accessible: " & objItem.ClientAccessible
    Wscript.Echo "Differential: " & objItem.Differential
    Wscript.Echo "Exposed locally: " & objItem.ExposedLocally
    Wscript.Echo "Exposed remotely: " & objItem.ExposedRemotely
    Wscript.Echo "Hardware assisted: " & objItem.HardwareAssisted
    Wscript.Echo "Imported: " & objItem.Imported
    Wscript.Echo "No auto release: " & objItem.NoAutoRelease
    Wscript.Echo "Not surfaced: " & objItem.NotSurfaced
    Wscript.Echo "No writers: " & objItem.NoWriters
    Wscript.Echo "Persistent: " & objItem.Persistent
    Wscript.Echo "Plex: " & objItem.Plex
    Wscript.Echo "Transportable: " & objItem.Transportable
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Shadow Copy Storage Area

Description
Modifies all the shadow copy storage areas on a computer, setting the maximum amount of reserved space to 500,000,000 bytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ShadowStorage")

For Each objItem in colItems
    objItem.MaxSpace = 500000000
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display the Settings Dialog Box

Description
Displays the Software Updates Service settings dialog box.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
objAutoUpdate.ShowSettingsDialog

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display the Software Update Service Wizard

Description
Locates update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44 and then displays the Software Update Service wizard.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")
Set colUpdates = objResults.Updates

objCollection.Add(colUpdates.Item(0))
Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection
Set objResults = objInstaller.RunWizard

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install an Update

Description
Installs update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")
Set colUpdates = objResults.Updates
objCollection.Add(colUpdates.Item(0))

Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection
Set objInstallResults = objInstaller.Install
Wscript.Echo objInstallResults.Exception
Wscript.Echo objInstallResults.RebootRequired
Wscript.Echo objInstallResults.ResultCode

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Client-Side Settings

Description
Displays client-side Software Update Service settings.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Wscript.Echo "Service enabled: " & objAutoUpdate.ServiceEnabled

Set objSettings = objAutoUpdate.Settings

Wscript.Echo "Notification level: " & objSettings.NotificationLevel
Wscript.Echo "Read-only: " & objSettings.ReadOnly
Wscript.Echo "Required: " & objSettings.Required
Wscript.Echo "Scheduled Installation Day: " & _
    objSettings.ScheduledInstallationDay
Wscript.Echo "Scheduled Installation Time: " & _
    objSettings.ScheduledInstallationTime

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Proxy Properties

Description
Displays proxy settings for Software Update Services.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objProxy = CreateObject("Microsoft.Update.WebProxy")

Wscript.Echo "Address: " & objProxy.Address
Wscript.Echo "Bypass proxy on local addresses: " & objProxy.BypassProxyOnLocal
Wscript.Echo "Read-only: " & objProxy.Readonly
Wscript.Echo "User name: " & objProxy.UserName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Search Properties

Description
Displays search settings for Software Update Services.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objSearcher = CreateObject("Microsoft.Update.Searcher")

Wscript.Echo "Can automatically upgrade service: " & _
    objSearcher.CanAutomaticallyUpgradeService
Wscript.Echo "Client application ID: " & objSearcher.ClientApplicationID
Wscript.Echo "Online: " & objSearcher.Online
Wscript.Echo "Server selection: " & objSearcher.ServerSelection
Wscript.Echo "Service ID: " & objSearcher.ServiceID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Service Properties

Description
Displays service properties for Software Update Services.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set colServices = objServiceManager.Services

For i = 0 to colServices.Count - 1
    Wscript.Echo "Name: " & colServices.Item(i).Name
    Wscript.Echo "Is managed: " & colServices.Item(i).IsManaged
    Wscript.Echo "Is registered with Automatic Updates: " & _
        colServices.Item(i).IsRegisteredWithAU
    Wscript.Echo "Issue date: " & colServices.Item(i).IssueDate
    Wscript.Echo "Offers Windows updates: " & _
        colServices.Item(i).OffersWindowsUpdates
    Wscript.Echo  "Redirection URL: " &colServices.Item(i).RedirectURL
    Wscript.Echo "Service ID: " & colServices.Item(i).ServiceID
    Wscript.Echo "UI Plugin Class ID: " & colServices.Item(i).UIPluginClsid
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List System Information Properties

Description
Displays basic system information properties for Software Update Services.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")

Wscript.Echo "OEM hardware support link: " & objSysInfo.OEMHardwareSupportLink
Wscript.Echo "Reboot required: " & objSysInfo.RebootRequired

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Update History

Description
Displays all the updates that have been installed on a computer.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
intHistoryCount = objSearcher.GetTotalHistoryCount

Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)

For Each objEntry in colHistory
    Wscript.Echo "Operation: " & objEntry.Operation
    Wscript.Echo "Result code: " & objEntry.ResultCode
    Wscript.Echo "Exception: " & objEntry.Exception
    Wscript.Echo "Date: " & objEntry.Date
    Wscript.Echo "Title: " & objEntry.Title
    Wscript.Echo "Description: " & objEntry.Description
    Wscript.Echo "Unmapped exception: " & objEntry.UnmappedException
    Wscript.Echo "Client application ID: " & objEntry.ClientApplicationID
    Wscript.Echo "Server selection: " & objEntry.ServerSelection
    Wscript.Echo "Service ID: " & objEntry.ServiceID
    i = 1
    For Each strStep in objEntry.UninstallationSteps
        Wscript.Echo i & " -- " & strStep
        i = i + 1
    Next
    Wscript.Echo "Uninstallation notes: " & objEntry.UninstallationNotes
    Wscript.Echo "Support URL: " & objEntry.SupportURL
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Update Schedule

Description
Demonstration script that modifies the software update schedule.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Set objSettings = objAutoUpdate.Settings

objSettings.ScheduledInstallationDay = 3
objSettings.ScheduledInstallationTime = 4

objSettings.Save

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Driver Updates

Description
Demonstration script that searches for new driver update.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

@Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Driver'")
Set colUpdates = objResults.Updates

Wscript.Echo colUpdates.Count

For i = 0 to colUpdates.Count - 1
    Wscript.Echo "Title: " & colUpdates.Item(i).Title
    Wscript.Echo "Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites

    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        Wscript.Echo "Bundled update: " & strUpdate
    Next

    Wscript.Echo "Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories

    For z = 0 to objCategories.Count - 1
        Wscript.Echo "Category name: " & objCategories.Item(z).Name
        Wscript.Echo "Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            Wscript.Echo "Child category: " & strChild
        Next
        Wscript.Echo "Category description: " & _
            objCategories.Item(z).Description
        Wscript.Echo "Category order: " & objCategories.Item(z).Order
        Wscript.Echo "Category type: " & objCategories.Item(z).Type
    Next

    Wscript.Echo "Deadline: " & colUpdates.Item(i).Deadline
    Wscript.Echo "Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    Wscript.Echo "Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    Wscript.Echo "Description: " & colUpdates.Item(i).Description
    Wscript.Echo "EULA accepted: " & colUpdates.Item(i).EULAAccepted
    Wscript.Echo "EULA text: " & colUpdates.Item(i).EULAText
    Wscript.Echo "Handler ID: " & colUpdates.Item(i).HandlerID

    Set objIdentity = colUpdates.Item(i).Identity
    Wscript.Echo "Revision number: " & objIdentity.RevisionNumber
    Wscript.Echo "Update ID: " & objIdentity.UpdateID

    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    Wscript.Echo "Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    Wscript.Echo "Impact: " & objInstallationBehavior.Impact
    Wscript.Echo "Reboot behavior: " & objInstallationBehavior.RebootBehavior
    Wscript.Echo "Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    Wscript.Echo "Is beta: " & colUpdates.Item(i).IsBeta
    Wscript.Echo "Is hidden: " & colUpdates.Item(i).IsHidden
    Wscript.Echo "Is installed: " & colUpdates.Item(i).IsInstalled
    Wscript.Echo "Is mandatory: " & colUpdates.Item(i).IsMandatory
    Wscript.Echo "Is uninstallable: " & colUpdates.Item(i).IsUninstallable

    For Each strLanguage in colUpdates.Item(i).Languages
        Wscript.Echo "Supported language: " & strLanguage
    Next

    Wscript.Echo "Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    Wscript.Echo "Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    Wscript.Echo "Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    Wscript.Echo "Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    Wscript.Echo "Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    Wscript.Echo "Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    Wscript.Echo "Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    Wscript.Echo "Release notes: " & colUpdates.Item(i).ReleaseNotes
    Wscript.Echo "Support URL: " & colUpdates.Item(i).SupportURL
    Wscript.Echo "Type: " & colUpdates.Item(i).Type
    Wscript.Echo "Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes

    x = 1
    For Each strStep in colUpdates.Item(i).UninstallationSteps
        Wscript.Echo x & " -- " & strStep
        x = x + 1
    Next

    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        Wscript.Echo "KB article: " & strArticle
    Next

    Wscript.Echo "Deployment action: " & colUpdates.Item(i).DeploymentAction
    Wscript.Echo

Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Software Updates

Description
Demonstration script that searches for new software updates.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates

For i = 0 to colUpdates.Count - 1
    Wscript.Echo "Title: " & colUpdates.Item(i).Title
    Wscript.Echo "Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites

    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        Wscript.Echo "Bundled update: " & strUpdate
    Next
    Wscript.Echo "Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories

    For z = 0 to objCategories.Count - 1
        Wscript.Echo "Category name: " & objCategories.Item(z).Name
        Wscript.Echo "Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            Wscript.Echo "Child category: " & strChild
        Next
        Wscript.Echo "Category description: " & _
            objCategories.Item(z).Description
        Wscript.Echo "Category order: " & objCategories.Item(z).Order
        Wscript.Echo "Category type: " & objCategories.Item(z).Type
    Next

    Wscript.Echo "Deadline: " & colUpdates.Item(i).Deadline
    Wscript.Echo "Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    Wscript.Echo "Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    Wscript.Echo "Description: " & colUpdates.Item(i).Description
    Wscript.Echo "EULA accepted: " & colUpdates.Item(i).EULAAccepted
    Wscript.Echo "EULA text: " & colUpdates.Item(i).EULAText
    Wscript.Echo "Handler ID: " & colUpdates.Item(i).HandlerID

    Set objIdentity = colUpdates.Item(i).Identity
    Wscript.Echo "Revision number: " & objIdentity.RevisionNumber
    Wscript.Echo "Update ID: " & objIdentity.UpdateID

    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    Wscript.Echo "Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    Wscript.Echo "Impact: " & objInstallationBehavior.Impact
    Wscript.Echo "Reboot behavior: " & objInstallationBehavior.RebootBehavior
    Wscript.Echo "Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    Wscript.Echo "Is beta: " & colUpdates.Item(i).IsBeta
    Wscript.Echo "Is hidden: " & colUpdates.Item(i).IsHidden
    Wscript.Echo "Is installed: " & colUpdates.Item(i).IsInstalled
    Wscript.Echo "Is mandatory: " & colUpdates.Item(i).IsMandatory
    Wscript.Echo "Is uninstallable: " & colUpdates.Item(i).IsUninstallable

    For Each strLanguage in colUpdates.Item(i).Languages
        Wscript.Echo "Supported language: " & strLanguage
    Next

    Wscript.Echo "Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    Wscript.Echo "Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    Wscript.Echo "Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    Wscript.Echo "Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    Wscript.Echo "Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    Wscript.Echo "Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    Wscript.Echo "Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    Wscript.Echo "Release notes: " & colUpdates.Item(i).ReleaseNotes
    Wscript.Echo "Support URL: " & colUpdates.Item(i).SupportURL
    Wscript.Echo "Type: " & colUpdates.Item(i).Type
    Wscript.Echo "Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes

    x = 1
    For Each strStep in colUpdates.Item(i).UninstallationSteps
        Wscript.Echo x & " -- " & strStep
        x = x + 1
    Next

    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        Wscript.Echo "KB article: " & strArticle
    Next

    Wscript.Echo "Deployment action: " & colUpdates.Item(i).DeploymentAction
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Uninstall an Update

Description
Uninstalls update ac94db3b-e1a8-4e92-9fd0-e86f355e6a44.

Supported Platforms

Windows Server 2003 | No
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objCollection = CreateObject("Microsoft.Update.UpdateColl")

Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search _
    ("UpdateID='ac94db3b-e1a8-4e92-9fd0-e86f355e6a44'")

Set colUpdates = objResults.Updates
Wscript.echo colUpdates.count

objCollection.Add(colUpdates.Item(0))
Wscript.echo objCollection.count

Set objInstaller = CreateObject("Microsoft.Update.Installer")
objInstaller.Updates = objCollection

Set objInstallResults = objInstaller.Uninstall
Wscript.Echo objInstallResults.Exception
Wscript.Echo objInstallResults.RebootRequired
Wscript.Echo objInstallResults.ResultCode

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Dfs Node

Description
Creates a new Dfs node for a shared folder named Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDfsNode = objWMIService.Get("Win32_DfsNode")

errReturn = objDfsNode.Create _
    ("\\atl-dc-02\Scripts","\\atl-dc-02","Scripts", _
        "New Dfs node for shared scripts.")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Dfs Nodes

Description
Lists all the Dfs nodes on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDfsNodes = objWMIService.ExecQuery _
    ("Select * from Win32_DFSNode")

For each objDfsNode in colDfsNodes
    Wscript.Echo "Caption: " & objDfsNode.Caption
    Wscript.Echo "Description: " & objDfsNode.Description
    Wscript.Echo "Install Date: " & objDfsNode.InstallDate
    Wscript.Echo "Name: " & objDfsNode.Name
    Wscript.Echo "Root: " & objDfsNode.Root
    Wscript.Echo "State: " & objDfsNode.State
    Wscript.Echo "Status: " & objDfsNode.Status
    Wscript.Echo "Timeout: " & objDfsNode.Timeout
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Dfs Targets

Description
Enumerates all the Dfs targets on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDfsTargets = objWMIService.ExecQuery _
    ("Select * from Win32_DFSTarget")

For each objDfsTarget in colDfsTargets
    Wscript.Echo "Caption: " & objDfsTarget.Caption
    Wscript.Echo "Description: " & objDfsTarget.Description
    Wscript.Echo "Install Date: " & objDfsTarget.InstallDate
    Wscript.Echo "Link Name: " & objDfsTarget.LinkName
    Wscript.Echo "Name: " & objDfsTarget.Name
    Wscript.Echo "Server Name: " & objDfsTarget.ServerName
    Wscript.Echo "Share Name: " & objDfsTarget.ShareName
    Wscript.Echo "State: " & objDfsTarget.State
    Wscript.Echo "Status: " & objDfsTarget.Status
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Floppy Controller Information

Description
Retrieves information about all the floppy drive controllers found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_FloppyController")

For Each objItem in colItems
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List IDE Controller Information

Description
Retrieves information about all IDE controllers found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_IDEController")

For Each objItem in colItems
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List SCSI Controller Information

Description
Returns information about all the SCSI controllers found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_SCSIController")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Configuration Manager Error Code: " & _
         objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Driver Name: " & objItem.DriverName
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
    Wscript.Echo "Status Information: " & objItem.StatusInfo
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List USB Controller Information

Description
Returns information about all the USB controllers found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_USBController")

For Each objItem in colItems
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "Protocol Supported: " & objItem.ProtocolSupported
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List USB Hub Information

Description
Returns information about all the USB hubs found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_USBHub")

For Each objItem in colItems
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Available Disk Space

Description
Issues an alert if free disk space for any hard drive on a computer falls below 100 megabytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const LOCAL_HARD_DISK = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colMonitoredDisks = objWMIService.ExecNotificationQuery _
    ("Select * from __instancemodificationevent within 30 where " _
        & "TargetInstance isa 'Win32_LogicalDisk'")
i = 0

Do While i = 0
    Set objDiskChange = colMonitoredDisks.NextEvent
    If objDiskChange.TargetInstance.DriveType = LOCAL_HARD_DISK Then
        If objDiskChange.TargetInstance.Size < 100000000 Then
            Wscript.Echo "Hard disk space is below 100000000 bytes."
        End If
    End If
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Disk Bytes Per Second

Description
Uses cooked performance counters to monitor disk bytes per second on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colDiskDrives = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfDisk_LogicalDisk").objectSet
objRefresher.Refresh

For i = 1 to 500
    For Each objDiskDrive in colDiskDrives
        Wscript.Echo "Drive name: " & objDiskDrive.Name
        Wscript.Echo "Disk bytes per second: " & objDiskDrive.DiskBytesPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Disk Drive Free Space

Description
Uses cooked performance counters to retrieve free disk space on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_PerfFormattedData_PerfDisk_LogicalDisk Where " _
        & "Name <> '_Total'")

For Each objDiskDrive in colDiskDrives
    Wscript.Echo "Drive Name: " & objDiskDrive.Name
    Wscript.Echo "Free Space: " & objDiskDrive.FreeMegabytes
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Logical Disk Drive Performance

Description
Uses cooked performance counters to monitor performance of the logical disk drives installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colDisks = objRefresher.AddEnum _
    (objWMIService, "win32_perfformatteddata_perfdisk_logicaldisk"). _
        objectSet
objRefresher.Refresh

For i = 1 to 100
    For Each objDisk in colDisks
        Wscript.Echo "Average Disk Bytes Per Read: " & _
            objDisk.AvgDiskBytesPerRead
        Wscript.Echo "Average Disk Bytes Per Transfer: " & _
            objDisk.AvgDiskBytesPerTransfer
        Wscript.Echo "Average Disk Bytes Per Write: " & _
            objDisk.AvgDiskBytesPerWrite
        Wscript.Echo "Average Disk Queue Length: " & _
            objDisk.AvgDiskQueueLength
        Wscript.Echo "Average Disk Read Queue Length: " & _
            objDisk.AvgDiskReadQueueLength
        Wscript.Echo "Average Disk Seconds Per Read: " & _
            objDisk.AvgDiskSecPerRead
        Wscript.Echo "Average Disk Seconds Per Transfer: " & _
            objDisk.AvgDiskSecPerTransfer
        Wscript.Echo "Average Disk Seconds Per Write: " & _
            objDisk.AvgDiskSecPerWrite
        Wscript.Echo "Average Disk Write Queue Length: " & _
            objDisk.AvgDiskWriteQueueLength
        Wscript.Echo "Current Disk Queue Length: " & _
            objDisk.CurrentDiskQueueLength
        Wscript.Echo "Disk Bytes Per Second: " & _
            objDisk.DiskBytesPerSec
        Wscript.Echo "Disk Read Bytes Per Second: " & _
            objDisk.DiskReadBytesPerSec
        Wscript.Echo "Disk Reads Per Second: " & _
            objDisk.DiskReadsPerSec
        Wscript.Echo "Disk Transfers Per Second: " & _
            objDisk.DiskTransfersPerSec
        Wscript.Echo "Disk Write Bytes Per Second: " & _
            objDisk.DiskWriteBytesPerSec
        Wscript.Echo "Disk Writes Per Second: " & _
            objDisk.DiskWritesPerSec
        Wscript.Echo "Free Megabytes: " & objDisk.FreeMegabytes
        Wscript.Echo "Name: " & objDisk.Name
        Wscript.Echo "Percent Disk Read Time: " &  _
            objDisk.PercentDiskReadTime
        Wscript.Echo "Percent Disk Time: " & _
            objDisk.PercentDiskTime
        Wscript.Echo "Percent Disk Write Time: " & _
            objDisk.PercentDiskWriteTime
        Wscript.Echo "Percent Free Space: " & _
            objDisk.PercentFreeSpace
        Wscript.Echo "Percent Idle Time: " & _
            objDisk.PercentIdleTime
        Wscript.Echo "Split IO Per Second: " & _
            objDisk.SplitIOPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Logical Disk Performance

Description
Uses cooked performance counters to monitor logical disk performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfDisk_LogicalDisk").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Average Disk Bytes Per Read: " & _
            objItem.AvgDiskBytesPerRead
        Wscript.Echo "Average Disk Bytes Per Transfer: " & _
            objItem.AvgDiskBytesPerTransfer
        Wscript.Echo "Average Disk Bytes Per Write: " & _
            objItem.AvgDiskBytesPerWrite
        Wscript.Echo "Average Disk Queue Length: " & objItem.AvgDiskQueueLength
        Wscript.Echo "Average Disk Read Queue Length: " & _
            objItem.AvgDiskReadQueueLength
        Wscript.Echo "Average Disk Seconds Per Read: " & _
            objItem.AvgDisksecPerRead
        Wscript.Echo "Average Disk Seconds Per Transfer: " & _
            objItem.AvgDisksecPerTransfer
        Wscript.Echo "Average Disk Seconds Per Write: " & _
            objItem.AvgDisksecPerWrite
        Wscript.Echo "Average Disk Write Queue Length: " & _
            objItem.AvgDiskWriteQueueLength
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Current Disk Queue Length: " & _
            objItem.CurrentDiskQueueLength
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Disk Bytes Per Second: " & objItem.DiskBytesPersec
        Wscript.Echo "Disk Read Bytes Per Second: " & _
            objItem.DiskReadBytesPersec
        Wscript.Echo "Disk Reads Per Second: " & objItem.DiskReadsPersec
        Wscript.Echo "Disk Transfers Per Second: " & _
            objItem.DiskTransfersPersec
        Wscript.Echo "Disk Write Bytes Per Second: " & _
            objItem.DiskWriteBytesPersec
        Wscript.Echo "Disk Writes Per Second: " & objItem.DiskWritesPersec
        Wscript.Echo "Free Megabytes: " & objItem.FreeMegabytes
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Disk Read Time: " & objItem.PercentDiskReadTime
        Wscript.Echo "Percent Disk Time: " & objItem.PercentDiskTime
        Wscript.Echo "Percent Disk Write Time: " & _
            objItem.PercentDiskWriteTime
        Wscript.Echo "Percent Free Space: " & objItem.PercentFreeSpace
        Wscript.Echo "Percent Idle Time: " & objItem.PercentIdleTime
        Wscript.Echo "Split I/O Per Second: " & objItem.SplitIOPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Physical Disk Drive Performance

Description
Uses cooked performance counters to monitor performance of the physical disk drives installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colDisks = objRefresher.AddEnum _
    (objWMIService, "win32_perfformatteddata_perfdisk_physicaldisk"). _
        objectSet
objRefresher.Refresh

For i = 1 to 100
    For Each objDisk in colDisks
        Wscript.Echo "Average Disk Bytes Per Read: " & vbTab &  _
            objDisk.AvgDiskBytesPerRead
        Wscript.Echo "Average Disk Bytes Per Transfer: " & vbTab &  _
            objDisk.AvgDiskBytesPerTransfer
        Wscript.Echo "Average Disk Bytes Per Write: " & vbTab &  _
            objDisk.AvgDiskBytesPerWrite
        Wscript.Echo "Average Disk Queue Length: " & vbTab &  _
           objDisk.AvgDiskQueueLength
        Wscript.Echo "Average Disk Read Queue Length: " & vbTab &  _
            objDisk.AvgDiskReadQueueLength
        Wscript.Echo "Average Disk Seconds Per Read: " & vbTab &  _
            objDisk.AvgDiskSecPerRead
        Wscript.Echo "Average Disk Seconds Per Transfer: " & vbTab &  _
            objDisk.AvgDiskSecPerTransfer
        Wscript.Echo "Average Disk Seconds Per Write: " & vbTab &  _
            objDisk.AvgDiskSecPerWrite
        Wscript.Echo "Average Disk Write Queue Length: " & vbTab &  _
            objDisk.AvgDiskWriteQueueLength
        Wscript.Echo "Current Disk Queue Length: " & vbTab &  _
            objDisk.CurrentDiskQueueLength
        Wscript.Echo "Disk Bytes Per Second: " & vbTab &  _
            objDisk.DiskBytesPerSec
        Wscript.Echo "Disk Read Bytes Per Second: " & vbTab &  _
            objDisk.DiskReadBytesPerSec
        Wscript.Echo "Disk Reads Per Second: " & vbTab &  _
            objDisk.DiskReadsPerSec
        Wscript.Echo "Disk Transfers Per Second: " & vbTab &  _
            objDisk.DiskTransfersPerSec
        Wscript.Echo "Disk Write Bytes Per Second: " & vbTab &  _
            objDisk.DiskWriteBytesPerSec
        Wscript.Echo "Disk Writes Per Second: " & vbTab &  _
            objDisk.DiskWritesPerSec
        Wscript.Echo "Name: " & vbTab &  objDisk.Name
        Wscript.Echo "Percent Disk Read Time: " & vbTab &  _
            objDisk.PercentDiskReadTime
        Wscript.Echo "Percent Disk Time: " & vbTab &  _
            objDisk.PercentDiskTime
        Wscript.Echo "Percent Disk Write Time: " & vbTab &  _
            objDisk.PercentDiskWriteTime
        Wscript.Echo "Percent Idle Time: " & vbTab &  _
            objDisk.PercentIdleTime
        Wscript.Echo "Split IO Per Second: " & vbTab &  _
            objDisk.SplitIOPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Physical Disk Performance

Description
Uses cooked performance counters to monitor physical disk performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfDisk_PhysicalDisk").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Average Disk Bytes Per Read: " & _
            objItem.AvgDiskBytesPerRead
        Wscript.Echo "Average Disk Bytes Per Transfer: " & _
            objItem.AvgDiskBytesPerTransfer
        Wscript.Echo "Average Disk Bytes Per Write: " & _
            objItem.AvgDiskBytesPerWrite
        Wscript.Echo "Average Disk Queue Length: " & objItem.AvgDiskQueueLength
        Wscript.Echo "Average Disk Read Queue Length: " & _
            objItem.AvgDiskReadQueueLength
        Wscript.Echo "Average Disk Seconds Per Read: " & _
            objItem.AvgDisksecPerRead
        Wscript.Echo "Average Disk Seconds Per Transfer: " & _
            objItem.AvgDisksecPerTransfer
        Wscript.Echo "Average Disk Seconds Per Write: " & _
            objItem.AvgDisksecPerWrite
        Wscript.Echo "Average Disk Write Queue Length: " & _
            objItem.AvgDiskWriteQueueLength
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Current Disk Queue Length: " & _
            objItem.CurrentDiskQueueLength
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Disk Bytes Per Second: " & objItem.DiskBytesPersec
        Wscript.Echo "Disk Read Bytes Per Second: " & _
            objItem.DiskReadBytesPersec
        Wscript.Echo "Disk Reads Per Second: " & objItem.DiskReadsPersec
        Wscript.Echo "Disk Transfers Per Second: " & _
            objItem.DiskTransfersPersec
        Wscript.Echo "Disk Write Bytes Per Second: " & _
            objItem.DiskWriteBytesPersec
        Wscript.Echo "Disk Writes Per Second: " & objItem.DiskWritesPersec
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Disk Read Time: " & objItem.PercentDiskReadTime
        Wscript.Echo "Percent Disk Time: " & objItem.PercentDiskTime
        Wscript.Echo "Percent Disk Write Time: " & objItem.PercentDiskWriteTime
        Wscript.Echo "Percent Idle Time: " & objItem.PercentIdleTime
        Wscript.Echo "Split I/O Per Second: " & objItem.SplitIOPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Volume Change Events

Description
Temporary event consumer that issues an alert when local volumes are added to or deleted from a computer. (This class monitors only changes to local drives; it cannot detect the addition/deletion of network volumes.)

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService. _
    ExecNotificationQuery("Select * from Win32_VolumeChangeEvent")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.DriveName
    Wscript.Echo objLatestEvent.EventType
    Wscript.Echo objLatestEvent.Time_Created
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Volume Mount Point

Description
Adds a new volume mount point for the folder W:\Scripts. Note that in the WQL query, you must use two slashes rather than one, and you must also include two slashes at the end of the folder path. Thus the folder X:\Scripts\WMI would be listed as X:\\Scripts\\WMI\\.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Volume Where Name = 'D:\\'")

For Each objItem in colItems
    objItem.AddMountPoint("W:\\Scripts\\")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Analyze Volume Defragmentation

Description
Analyzes the defragmentation status of all the volumes on a computer. This is equivalent to running defrag.exe with the command-line options -a (analyze) and -v (verbose).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colVolumes = objWMIService.ExecQuery("Select * from Win32_Volume")

For Each objVolume in colVolumes
    errResult = objVolume.DefragAnalysis(blnRecommended, objReport)
    If errResult = 0 then
        Wscript.Echo "Average file size: " & objReport.AverageFileSize
        Wscript.Echo "Average fragments per file: " & _
            objReport.AverageFragmentsPerFile
        Wscript.Echo "Cluster size: " & objReport.ClusterSize
        Wscript.Echo "Excess folder fragments: " & _
            objReport.ExcessFolderFragments
        Wscript.Echo "File percent fragmentation: " & _
            objReport.FilePercentFragmentation
        Wscript.Echo "Fragmented folders: " & objReport.FragmentedFolders
        Wscript.Echo "Free soace: " & objReport.FreeSpace
        Wscript.Echo "Free space percent: " & objReport.FreeSpacePercent
        Wscript.Echo "Free space percent fragmentation: " & _
            objReport.FreeSpacePercentFragmentation
        Wscript.Echo "MFT percent in use: " & objReport.MFTPercentInUse
        Wscript.Echo "MFT record count: " & objReport.MFTRecordCount
        Wscript.Echo "Page file size: " & objReport.PageFileSize
        Wscript.Echo "Total excess fragments: " & _
            objReport.TotalExcessFragments
        Wscript.Echo "Total files: " & objReport.TotalFiles
        Wscript.Echo "Total folders: " & objReport.TotalFolders
        Wscript.Echo "Total fragmented files: " & _
            objReport.TotalFragmentedFiles
        Wscript.Echo "Total MFT fragments: " & objReport.TotalMFTFragments
        Wscript.Echo "Total MFT size: " & objReport.TotalMFTSize
        Wscript.Echo "Total page file fragments: " & _
            objReport.TotalPageFileFragments
        Wscript.Echo "Total percent fragmentation: " & _
            objReport.TotalPercentFragmentation
        Wscript.Echo "Used space: " & objReport.UsedSpace
        Wscript.Echo "Volume name: " & objReport.VolumeName
        Wscript.Echo "Volume size: " & objReport.VolumeSize
        If blnRecommended = True Then
           Wscript.Echo "This volume should be defragged."
        Else
           Wscript.Echo "This volume does not need to be defragged."
        End If
        Wscript.Echo
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Associate Disk Partitions with Physical Disk Drives

Description
Returns the DeviceID of all the physical disk drives installed on a computer, and indicates the partitions that have been created on those disks.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set wmiServices = GetObject _
    ("winmgmts:{impersonationLevel=Impersonate}!//" & strComputer)

Set wmiDiskDrives = wmiServices.ExecQuery _
    ("SELECT Caption, DeviceID FROM Win32_DiskDrive")

For Each wmiDiskDrive In wmiDiskDrives
    WScript.Echo wmiDiskDrive.Caption & " (" & wmiDiskDrive.DeviceID & ")"
    strEscapedDeviceID = Replace _
        (wmiDiskDrive.DeviceID, "\", "\\", 1, -1, vbTextCompare)
    Set wmiDiskPartitions = wmiServices.ExecQuery _
        ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
    strEscapedDeviceID & """} WHERE AssocClass = " & _
        "Win32_DiskDriveToDiskPartition")

    For Each wmiDiskPartition In wmiDiskPartitions
        WScript.Echo vbTab & wmiDiskPartition.DeviceID
        Set wmiLogicalDisks = wmiServices.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
                wmiDiskPartition.DeviceID & """} WHERE AssocClass = " & _
                    "Win32_LogicalDiskToPartition")

        For Each wmiLogicalDisk In wmiLogicalDisks
            WScript.Echo vbTab & vbTab & wmiLogicalDisk.DeviceID
        Next
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Bind to a Specific Disk Drive

Description
Demonstration script that uses the FileSystemObject to return available disk space on a specific disk drive. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDrive = objFSO.GetDrive("C:")
Wscript.Echo "Available space: " & objDrive.AvailableSpace

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Change the Drive Letter of a Volume

Description
Changes the drive letter of volume D to Q. If you modify this script to change the drive letter of a volume other than D, note that the volume name in the WQL query must include both the colon (:) and two slashes (\\). Thus drive C would look like this: C:\\. When specifying the new drive letter, however, you only have to include the colon (in the sample script, Q:).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colVolumes = objWMIService.ExecQuery _
    ("Select * from Win32_Volume Where Name = 'D:\\'")

For Each objVolume in colVolumes
    objVolume.DriveLetter = "Q:"
    objVolume.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Defragment a Volume

Description
Defragments volume D on a computer. If you modify this script to defragment a different volume (such as X), note that your WQL query must specify the drive letter followed by a colon and then followed by two slashes. Thus volume X would be listed as X:\\.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colVolumes = objWMIService.ExecQuery _
    ("Select * from Win32_Volume Where Name = 'D:\\'")

For Each objVolume in colVolumes
     errResult = objVolume.Defrag()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Dismount a Volume

Description
Dismounts volume E from the file system. If you modify this script to dismount a different volume (such as X), note that your WQL query must specify the drive letter followed by a colon and then followed by two slashes. Thus volume X would be listed as X:\\. The two parameters: 1) force the volume to be dismounted, even if users are currently connected to it; and, 2) place the volume in a no-automount, offline state. This script can be modified by setting either (or both) of these parameters to False.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Volume Where Name = 'E:\\'")

For Each objItem in colItems
    objItem.Dismount(True, True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Format a Volume

Description
Formats drive D using the NTFS file system. Drives could also be formatted using the FAT or FAT32 file systems. Note that this method cannot be used to format floppy drives. If you modify this script to format a different volume (such as drive X), also note that your WQL query must specify the drive letter followed by a colon and then followed by two slashes. Thus drive X would be listed as X:\\.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colVolumes = objWMIService.ExecQuery _
    ("Select * from Win32_Volume Where Name = 'D:\\'")

For Each objVolume in colVolumes
    errResult = objVolume.Format("NTFS")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Disk Drives

Description
Demonstration script that uses the FileSystemObject to return a list of all the disk drives installed on a computer. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives

For Each objDrive in colDrives
    Wscript.Echo "Drive letter: " & objDrive.DriveLetter
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Available Disk Space

Description
Returns the amount of free space for each hard disk installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const HARD_DISK = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")

For Each objDisk in colDisks
    Wscript.Echo "DeviceID: "& vbTab &  objDisk.DeviceID
    Wscript.Echo "Free Disk Space: "& vbTab & objDisk.FreeSpace
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List CD-ROM Properties

Description
Returns information about all the CD-ROM drives installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    For Each strCapability in objItem.Capabilities
        Wscript.Echo "Capability: "& strCapability
    Next
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Drive: " & objItem.Drive
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Media Loaded: " & objItem.MediaLoaded
    Wscript.Echo "Media Type: " & objItem.MediaType
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo "SCSI Bus: " & objItem.SCSIBus
    Wscript.Echo "SCSI Logical Unit: " & objItem.SCSILogicalUnit
    Wscript.Echo "SCSI Port: " & objItem.SCSIPort
    Wscript.Echo "SCSI Target ID: " & objItem.SCSITargetId
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Drive Properties Using FSO

Description
Demonstration script that uses the FileSystemObject to return the properties of all the disk drives installed on a computer. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives

For Each objDrive in colDrives
    Wscript.Echo "Available space: " & objDrive.AvailableSpace
    Wscript.Echo "Drive letter: " & objDrive.DriveLetter
    Wscript.Echo "Drive type: " & objDrive.DriveType
    Wscript.Echo "File system: " & objDrive.FileSystem
    Wscript.Echo "Free space: " & objDrive.FreeSpace
    Wscript.Echo "Is ready: " & objDrive.IsReady
    Wscript.Echo "Path: " & objDrive.Path
    Wscript.Echo "Root folder: " & objDrive.RootFolder
    Wscript.Echo "Serial number: " & objDrive.SerialNumber
    Wscript.Echo "Share name: " & objDrive.ShareName
    Wscript.Echo "Total size: " & objDrive.TotalSize
    Wscript.Echo "Volume name: " & objDrive.VolumeName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Partition Properties

Description
Lists the properties of all the disk partitions on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskPartitions = objWMIService.ExecQuery _
    ("Select * from Win32_DiskPartition")

For each objPartition in colDiskPartitions
    Wscript.Echo "Block Size: " & objPartition.BlockSize
    Wscript.Echo "Bootable: " & objPartition.Bootable
    Wscript.Echo "Boot Partition: " & objPartition.BootPartition
    Wscript.Echo "Description: " & objPartition.Description
    Wscript.Echo "Device ID: " & objPartition.DeviceID
    Wscript.Echo "Disk Index: " & objPartition.DiskIndex
    Wscript.Echo "Index: " & objPartition.Index
    Wscript.Echo "Name: " & objPartition.Name
    Wscript.Echo "Number Of Blocks: " & _
        objPartition.NumberOfBlocks
    Wscript.Echo "Primary Partition: " & _
        objPartition.PrimaryPartition
    Wscript.Echo "Size: " & objPartition.Size
    Wscript.Echo "Starting Offset: " & _
        objPartition.StartingOffset
    Wscript.Echo "Type: " & objPartition.Type
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Space by User on the Local Computer

Description
Uses disk quotas to return information about disk space usage per-user for drive C on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "C:\", True

For Each objUser in colDiskQuotas
    Wscript.Echo "Logon name: " & objUser.LogonName
    Wscript.Echo "Quota used: " & objUser.QuotaUsed
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Drive Types

Description
Identifies the drive type (floppy drive, hard drive, CD-ROM, etc.) for each physical drive installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

For Each objDisk in colDisks
    Wscript.Echo "DeviceID: "& objDisk.DeviceID
    Select Case objDisk.DriveType
        Case 1
            Wscript.Echo "No root directory. Drive type could not be " _
                & "determined."
        Case 2
            Wscript.Echo "DriveType: "& "Removable drive."
        Case 3
            Wscript.Echo "DriveType: "& "Local hard disk."
        Case 4
            Wscript.Echo "DriveType: "& "Network disk."
        Case 5
            Wscript.Echo "DriveType: "& "Compact disk."
        Case 6
            Wscript.Echo "DriveType: "& "RAM disk."
        Case Else
            Wscript.Echo "Drive type could not be determined."
    End Select
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Floppy Drive Information

Description
Returns information about all the floppy disk drives installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_FloppyDrive")

For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "Configuration Manager Error Code: " & _
        objItem.ConfigManagerErrorCode
    Wscript.Echo "Configuration Manager User Configuration: " & _
        objItem.ConfigManagerUserConfig
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "Manufacturer: " & objItem.Manufacturer
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNP Device ID: " & objItem.PNPDeviceID
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Logical Disk Drive Properties

Description
Lists the properties for all the logical disk drives on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk")

For each objDisk in colDisks
    Wscript.Echo "Compressed: " & objDisk.Compressed
    Wscript.Echo "Description: " & objDisk.Description
    Wscript.Echo "DeviceID: " & objDisk.DeviceID
    Wscript.Echo "DriveType: " & objDisk.DriveType
    Wscript.Echo "FileSystem: " & objDisk.FileSystem
    Wscript.Echo "FreeSpace: " & objDisk.FreeSpace
    Wscript.Echo "MediaType: " & objDisk.MediaType
    Wscript.Echo "Name: " & objDisk.Name
    Wscript.Echo "QuotasDisabled: " & objDisk.QuotasDisabled
    Wscript.Echo "QuotasIncomplete: " & objDisk.QuotasIncomplete
    Wscript.Echo "QuotasRebuilding: " & objDisk.QuotasRebuilding
    Wscript.Echo "Size: " & objDisk.Size
    Wscript.Echo "SupportsDiskQuotas: " & _
        objDisk.SupportsDiskQuotas
    Wscript.Echo "SupportsFileBasedCompression: " & _
        objDisk.SupportsFileBasedCompression
    Wscript.Echo "SystemName: " & objDisk.SystemName
    Wscript.Echo "VolumeDirty: " & objDisk.VolumeDirty
    Wscript.Echo "VolumeName: " & objDisk.VolumeName
    Wscript.Echo "VolumeSerialNumber: " & _
        objDisk.VolumeSerialNumber
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Mapped Network Drives

Description
Retrieves information about mapped network drives. The information returned is similar to that available through the Win32_LogicalDisk class, which retrieves information about the logical disks found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_MappedLogicalDisk")

For Each objItem in colItems
    Wscript.Echo "Compressed: " & objItem.Compressed
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Device ID: " & objItem.DeviceID
    Wscript.Echo "File System: " & objItem.FileSystem
    Wscript.Echo "Free Space: " & objItem.FreeSpace
    Wscript.Echo "Maximum Component Length: " & objItem.MaximumComponentLength
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "Provider Name: " & objItem.ProviderName
    Wscript.Echo "Session ID: " & objItem.SessionID
    Wscript.Echo "Size: " & objItem.Size
    Wscript.Echo "Supports Disk Quotas: " & objItem.SupportsDiskQuotas
    Wscript.Echo "Supports File-Based Compression: " & _
        objItem.SupportsFileBasedCompression
    Wscript.Echo "Volume Name: " & objItem.VolumeName
    Wscript.Echo "Volume Serial Number: " & objItem.VolumeSerialNumber
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Physical Disk Properties

Description
Retrieves the properties for all the physical disk drives installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDiskDrives = objWMIService.ExecQuery _
    ("Select * from Win32_DiskDrive")

For each objDiskDrive in colDiskDrives
    Wscript.Echo "Bytes Per Sector: " & vbTab &  _
        objDiskDrive.BytesPerSector
    For i = Lbound(objDiskDrive.Capabilities) to _
        Ubound(objDiskDrive.Capabilities)
        Wscript.Echo "Capabilities: " & vbTab &  _
            objDiskDrive.Capabilities(i)
    Next
    Wscript.Echo "Caption: " & vbTab &  objDiskDrive.Caption
    Wscript.Echo "Device ID: " & vbTab &  objDiskDrive.DeviceID
    Wscript.Echo "Index: " & vbTab &  objDiskDrive.Index
    Wscript.Echo "Interface Type: " & vbTab & objDiskDrive.InterfaceType
    Wscript.Echo "Manufacturer: " & vbTab & objDiskDrive.Manufacturer
    Wscript.Echo "Media Loaded: " & vbTab  & objDiskDrive.MediaLoaded
    Wscript.Echo "Media Type: " & vbTab &  objDiskDrive.MediaType
    Wscript.Echo "Model: " & vbTab &  objDiskDrive.Model
    Wscript.Echo "Name: " & vbTab &  objDiskDrive.Name
    Wscript.Echo "Partitions: " & vbTab & objDiskDrive.Partitions
    Wscript.Echo "PNP DeviceID: " & vbTab &  objDiskDrive.PNPDeviceID
    Wscript.Echo "SCSI Bus: " & vbTab &  objDiskDrive.SCSIBus
    Wscript.Echo "SCSI Logical Unit: " & vbTab &  _
        objDiskDrive.SCSILogicalUnit
    Wscript.Echo "SCSI Port: " & vbTab &  objDiskDrive.SCSIPort
    Wscript.Echo "SCSI TargetId: " & vbTab &  objDiskDrive.SCSITargetId
    Wscript.Echo "Sectors Per Track: " & vbTab &  _
        objDiskDrive.SectorsPerTrack
    Wscript.Echo "Signature: " & vbTab &  objDiskDrive.Signature
    Wscript.Echo "Size: " & vbTab &  objDiskDrive.Size
    Wscript.Echo "Status: " & vbTab &  objDiskDrive.Status
    Wscript.Echo "Total Cylinders: " & vbTab &  _
        objDiskDrive.TotalCylinders
    Wscript.Echo "Total Heads: " & vbTab &  objDiskDrive.TotalHeads
    Wscript.Echo "Total Sectors: " & vbTab &  objDiskDrive.TotalSectors
    Wscript.Echo "Total Tracks: " & vbTab &  objDiskDrive.TotalTracks
    Wscript.Echo "Tracks Per Cylinder: " & vbTab &  _
        objDiskDrive.TracksPerCylinder
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Volume Mount Points

Description
Enumerates all the volume mount points on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("SELECT * FROM Win32_MountPoint")

For Each objItem In colItems
  WScript.Echo "Directory: " & objItem.Directory
  WScript.Echo "Volume: " & objItem.Volume
  WScript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Volume Properties

Description
Retrieves the properties of all the volumes installed on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Volume")

For Each objItem In colItems
    WScript.Echo "Automount: " & objItem.Automount
    WScript.Echo "Block Size: " & objItem.BlockSize
    WScript.Echo "Capacity: " & objItem.Capacity
    WScript.Echo "Caption: " & objItem.Caption
    WScript.Echo "Compressed: " & objItem.Compressed
    WScript.Echo "Device ID: " & objItem.DeviceID
    WScript.Echo "Dirty Bit Set: " & objItem.DirtyBitSet
    WScript.Echo "Drive Letter: " & objItem.DriveLetter
    WScript.Echo "Drive Type: " & objItem.DriveType
    WScript.Echo "File System: " & objItem.FileSystem
    WScript.Echo "Free Space: " & objItem.FreeSpace
    WScript.Echo "Indexing Enabled: " & objItem.IndexingEnabled
    WScript.Echo "Label: " & objItem.Label
    WScript.Echo "Maximum File Name Length: " & objItem.MaximumFileNameLength
    WScript.Echo "Name: " & objItem.Name
    WScript.Echo "Quotas Enabled: " & objItem.QuotasEnabled
    WScript.Echo "Quotas Incomplete: " & objItem.QuotasIncomplete
    WScript.Echo "Quotas Rebuilding: " & objItem.QuotasRebuilding
    WScript.Echo "Serial Number: " & objItem.SerialNumber
    WScript.Echo "Supports Disk Quotas: " & objItem.SupportsDiskQuotas
    WScript.Echo "Supports File-Based Compression: " & _
        objItem.SupportsFileBasedCompression
    WScript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the AutoChk Timeout Value

Description
Sets the auto-delay time for Autochk.exe to 30 seconds.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAutoChkSettings = objWMIService.ExecQuery _
    ("Select * from Win32_AutochkSetting")

For Each objAutoChkSetting in colAutoChkSettings
    objAutoChkSetting.UserInputDelay = 30
    objAutoChkSetting.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Mount a Volume

Description
Mounts volume Z to the file system. If you modify this script to mount a different volume (such as X), note that the volume name in your WQL query must include the drive letter followed by a colon and then followed by two slashes. Thus drive X would be listed as X:\\.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Volume Where Name = 'Z:\\'")

For Each objItem in colItems
     objItem.Mount()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Prevent AutoChk From Running

Description
Ensures that Autochk.exe will not run against drive C the next time the computer reboots, even if the "dirty bit" has been set on drive C.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDisk = objWMIService.Get("Win32_LogicalDisk")

errReturn = objDisk.ExcludeFromAutoChk(Array("C:"))

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Volume

Description
Changes the volume label for drive C to "Finance Volume."

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDrives = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk where DeviceID = 'C:'")

For Each objDrive in colDrives
    objDrive.VolumeName = "Finance Volume"
    objDrive.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Run ChkDsk

Description
Runs ChkDsk.exe against drive D on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const FIX_ERRORS = True

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='D:'")

errReturn = objDisk.ChkDsk(FIX_ERRORS)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Schedule AutoChk

Description
Schedules Autochk.exe to run against drive C the next time the computer reboots.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objDisk = objWMIService.Get("Win32_LogicalDisk")

errReturn = objDisk.ScheduleAutoChk(Array("C:"))

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify ChkDsk Volume Status

Description
Indicates whether or not any hard drives on a computer have the "dirty bit" set, and should have Chkdsk.exe run.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const LOCAL_HARD_DISK = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = LOCAL_HARD_DISK ")

For Each objDisk in colDisks
    Wscript.Echo "Device ID: "& vbTab &  objDisk.DeviceID
    Wscript.Echo "Drive Type: "& vbTab & objDisk.VolumeDirty
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that All Drives are Ready

Description
Demonstration script that uses the FileSystemObject to ensure that all drives are ready (i.e., media is inserted) before echoing the drive letter and available disk space. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives

For Each objDrive in colDrives
    If objDrive.IsReady = True Then
        Wscript.Echo "Drive letter: " & objDrive.DriveLetter
        Wscript.Echo "Free space: " & objDrive.FreeSpace
    Else
        Wscript.Echo "Drive letter: " & objDrive.DriveLetter
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Disk Quota Entry on the Local Computer

Description
Creates a custom disk quota entry for a user named kenmyer. This script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")

colDiskQuotas.Initialize "C:\", True
Set objUser = colDiskQuotas.AddUser("kenmyer")
Set objUser = colDiskQuotas.FindUser("kenmyer")
objUser.QuotaLimit = 50000000

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a New Quota Entry

Description
Creates a new disk quota entry for the user fabrikam\bob.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"

Set objAccount = objWMIService.Get _
    ("Win32_Account.Domain='fabrikam',Name='bob'")
Set objDisk = objWMIService.Get _
    ("Win32_LogicalDisk.DeviceID='C:'")
Set objQuota = objWMIService.Get _
    ("Win32_DiskQuota").SpawnInstance_

objQuota.QuotaVolume = objDisk.Path_.RelPath
objQuota.User = objAccount.Path_.RelPath
objQuota.Limit = 10485760
objQuota.WarningLimit = 8388608
objQuota.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Disk Quota Entry on the Local Computer

Description
Deletes the disk quota entry for a user named kenmyer. This script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")

colDiskQuotas.Initialize "C:\", True
set objUser = colDiskQuotas.FindUser("kenmyer")
colDiskQuotas.DeleteUser(objUser)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete an Existing Quota Entry

Description
Deletes a disk quota entry for the user fabrikam\bob.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strDrive = "C:"
strDomain = "fabrikam"
strUser = "bob"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objQuota = objWMIService.Get _
    ("Win32_DiskQuota.QuotaVolume='Win32_LogicalDisk.DeviceID=""" " & _
        " & strDrive & """',User='Win32_Account.Domain=""" " & _
            " & strDomain & """,Name=""" & strUser & """'")

objQuota.Delete_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Disk Quotas

Description
Enables disk quotas for drive C on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENFORCE_QUOTAS = 1

StrComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_QuotaSetting Where VolumePath = 'C:\\'")

For Each objDisk in colDisks
    objDisk.State = ENFORCE_QUOTAS
    objDisk.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Disk Quotas on the Local Computer

Description
Enables disk quotas for drive C on the local computer. To enable disk quotas for a different drive, change C:\ in line two to the appropriate drive letter (for example, D:\). To disable disk quotas, set the value of the constant ENABLE_QUOTAS to 0. To enable, but not enforce, disk quotas, set this value to 1. This script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE_QUOTAS = 2

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "C:\", True
colDiskQuotas.QuotaState = ENABLE_QUOTAS

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List a Quota Entry

Description
Lists disk quota information for the user fabrikam\bob.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objQuota = objWMIService.Get _
    ("Win32_DiskQuota.QuotaVolume='Win32_LogicalDisk.DeviceID=""C:""'," & _
        "User='Win32_Account.Domain=""fabrikam"",Name=""bob""'")

Wscript.Echo objQuota.Limit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Quota Entries

Description
Enumerates disk quota information (including user name, warning and quota limits, and disk space used) for each disk quota entry on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDiskQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota")

For each objQuota in colDiskQuotas
    Wscript.Echo "Disk Space Used: " & vbTab &  objQuota.DiskSpaceUsed
    Wscript.Echo "Limit: " & vbTab &  objQuota.Limit
    Wscript.Echo "Quota Volume: " & vbTab &  objQuota.QuotaVolume
    Wscript.Echo "Status: " & vbTab &  objQuota.Status
    Wscript.Echo "User: " & vbTab &  objQuota.User
    Wscript.Echo "Warning Limit: " & vbTab &  objQuota.WarningLimit
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Quota Entries on the Local Computer

Description
Enumerates disk quota information (including user name, warning and quota limits, and disk space used) for each disk quota entry on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "C:\", True

For Each objUser in colDiskQuotas
    Wscript.Echo "Logon name: " & objUser.LogonName
    Wscript.Echo "Quota limit: " & objUser.QuotaLimit
    Wscript.Echo "Quota threshold: " & objUser.QuotaThreshold
    Wscript.Echo "Quota used: " & objUser.QuotaUsed
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Quota Settings

Description
Enumerates the disk quota settings for each drive on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuotaSettings = objWMIService.ExecQuery _
    ("Select * from Win32_QuotaSetting")

For Each objQuotaSetting in colQuotaSettings
    Wscript.Echo "Default Limit: " & objQuotaSetting.DefaultLimit
    Wscript.Echo "Default Warning Limit: " &  _
        objQuotaSetting.DefaultWarningLimit
    Wscript.Echo "Exceeded Notification: " &  _
        objQuotaSetting.ExceededNotification
    Wscript.Echo "State: " & objQuotaSetting.State
    Wscript.Echo "Volume Path: " & objQuotaSetting.VolumePath
    Wscript.Echo "Warning Exceeded Notification: " & _
        objQuotaSetting.WarningExceededNotification
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Quota Settings on the Local Computer

Description
Enumerates the disk quota settings for drive C on the local computer. To enumerate disk quota settings for a different drive, change C:\ in line two to the appropriate drive letter (for example, D:\).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "C:\", True

If colDiskQuotas.QuotaState = 2 Then
    Wscript.Echo "Quota state: Enabled and enforced"
ElseIf colDiskQuotas.QuotaState = 1 Then
    Wscript.Echo "Quota state: Enabled but not enforced"
Else
    Wscript.Echo "Quota state: Disabled"
End If

Wscript.Echo "Default quota limit: " & colDiskQuotas.DefaultQuotaLimit
Wscript.Echo "Default warning limit: " & _
    colDiskQuotas.DefaultQuotaThreshold
Wscript.Echo "Record quota violations in event log: " & _
    colDiskQuotas.LogQuotaLimit
Wscript.Echo "Record warnings in event log: " & _
    colDiskQuotas.LogQuotaThreshold

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Disk Space by User Using Disk Quotas

Description
Uses disk quotas to report the amount of disk space being used by each individual user on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuotas = objWMIService.ExecQuery("Select * from Win32_DiskQuota")

For Each objQuota in colQuotas
    Wscript.Echo "Volume: "& objQuota.QuotaVolume
    Wscript.Echo "User: "& objQuota.User
    Wscript.Echo "Disk Space Used: "& objQuota.DiskSpaceUsed
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Locate A Quota Entry

Description
Lists quota information for the user fabrikam\bob.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objQuota = objWMIService.Get _
    ("Win32_DiskQuota.QuotaVolume='Win32_LogicalDisk.DeviceID=""C:""'," & _
        "User='Win32_Account.Domain=""fabrikam"",Name=""bob""'")

Wscript.Echo objQuota.Limit

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Disk Quota Entry on the Local Computer

Description
Modifies the disk quota warning threshold and disk space limit for a user named kenmyer. This script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "C:\", True
set objUser = colDiskQuotas.FindUser("kenmyer")

objUser.QuotaThreshold = 90000000
objUser.QuotaLimit = 100000000

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify an Existing Quota Entry

Description
Modifies the disk quota limit for the user fabrikam\bob.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
    ("Win32_Account.Domain='fabrikam',Name='bob'")
Set objDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='C:'")
Set objQuota = objWMIService.Get _
    ("Win32_DiskQuota.QuotaVolume= " & _
      "'Win32_LogicalDisk.DeviceID=""C:""'," & _
         "User='Win32_Account.Domain=""fabrikam"",Name=""bob""'")

objQuota.Limit = 11111111
objQuota.Put_

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Disk Quota Settings

Description
Changes the warning threshold and default quota limits for drive C.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuotaSettings = objWMIService.ExecQuery _
    ("Select * from Win32_QuotaSetting")

For Each objQuotaSetting in colQuotaSettings
    objQuotaSetting.DefaultLimit = 10000000
    objQuotaSetting.DefaultWarningLimit = 9000000
    objQuotaSetting.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List NTFS Properties

Description
Retrieves NTFS file system settings from the registry.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

On Error Resume Next

Set objShell = WScript.CreateObject("WScript.Shell")

strRegKey =  objShell.RegRead _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\" _
        & "NtfsDisable8dot3NameCreation")
If IsNull(strRegKey) Then
    Wscript.Echo "No value set for disabling 8.3 file name creation."
ElseIf strRegKey = 1 Then
    WScript.Echo "No 8.3 file names will be created for new files."
ElseIf strRegKey = 0 Then
    Wscript.Echo "8.3 file names will be created for new files."
End If

strRegKey = Null
strRegKey =  objShell.RegRead _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\" _
        & "NtfsAllowExtendedCharacterIn8Dot3Name")
If IsNull(strRegKey) Then
    Wscript.Echo "No value set for allowing extended characters in " _
       & " 8.3 file names."
ElseIf strRegKey = 1 Then
    WScript.Echo "Extended characters are permitted in 8.3 file names."
ElseIf strRegKey = 0 Then
    Wscript.Echo "Extended characters not permitted in 8.3 file names."
End If

strRegKey = Null
strRegKey =  objShell.RegRead _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\" _
        & "NtfsMftZoneReservation")
If IsNull(strRegKey) Then
    Wscript.Echo "No value set for reserving the MFT zone."
ElseIf strRegKey = 1 Then
    WScript.Echo _
        "One-eighth of the disk has been reserved for the MFT zone."
ElseIf strRegKey = 2 Then
    Wscript.Echo "One-fourth of the disk reserved for the MFT zone."
ElseIf strRegKey = 3 Then
    Wscript.Echo "Three-eighths of the disk reserved for the MFT zone."
ElseIf strRegKey = 4 Then
    Wscript.Echo "One half of the disk reserved for the MFT zone."
End If

strRegKey = Null
strRegKey =  objShell.RegRead _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\" _
        & "NtfsDisableLastAccessUpdate")
If IsNull(strRegKey) Then
    Wscript.Echo "No value set for disabling the last access update " _
        & "for files and folder."
ElseIf strRegKey = 1 Then
    WScript.Echo "The last access timestamp will not be updated on files " _
        & "and folders."
ElseIf strRegKey = 0 Then
    Wscript.Echo "The last access timestamp updated on files and " _
         & "folders."
End If

strRegKey = Null
strRegKey =  objShell.RegRead _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\Win31FileSystem")
If IsNull(strRegKey) Then
    Wscript.Echo "No value set for using long file names and " _
        & "timestamps."
ElseIf strRegKey = 1 Then
    WScript.Echo "Long file names and extended timestamps are used."
ElseIf strRegKey = 0 Then
    Wscript.Echo "Long file names and extended timestamps are not used."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the File System Type

Description
Identifies the file system in use for each logical disk on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")

For Each objDisk in colDisks
    Wscript.Echo "Device ID: "& vbTab &  objDisk.DeviceID
    Wscript.Echo "File System: "& vbTab & objDisk.FileSystem
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify File System Properties

Description
Disables the updating of the last access time for files and folders.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Set objShell = WScript.CreateObject("WScript.Shell")
strRegKey =  objShell.RegWrite _
    ("HKLM\System\CurrentControlSet\Control\FileSystem\" _
        & "NtfsDisableLastAccessUpdate" , 1, "REG_DWORD")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor NTFS File Cache Performance

Description
Uses cooked performance counters to monitor the performance of the NTFS file cache.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colCache = objRefresher.AddEnum _
    (objWMIService, "win32_PerfFormattedData_PerfOS_Cache").ObjectSet
objRefresher.Refresh

For i = 1 to 100
    For Each objCache in colCache
        Wscript.Echo "Async Copy Reads Per Second" & _
            objCache.AsyncCopyReadsPerSec
        Wscript.Echo "Async Data Maps Per Second" & _
            objCache.AsyncDataMapsPerSec
        Wscript.Echo "AsyncFastReadsPerSecond" & _
            objCache.AsyncFastReadsPerSec
        Wscript.Echo "Async MDL Reads Per Second" & _
            objCache.AsyncMDLReadsPerSec
        Wscript.Echo "Async Pin Reads Per Second" & _
            objCache.AsyncPinReadsPerSec
        Wscript.Echo "Caption" & vbTab & objCache.Caption
        Wscript.Echo "Copy Read Hits Percent " & _
            objCache.CopyReadHitsPercent
        Wscript.Echo "Copy Reads Per Second" & _
            objCache.CopyReadsPerSec
        Wscript.Echo "Data Flushes Per Second" & _
            objCache.DataFlushesPerSec
        Wscript.Echo "Data Flush Pages Per Second" & _
            objCache.DataFlushPagesPerSec
        Wscript.Echo "Data Map Hits Percent " & _
            objCache.DataMapHitsPercent
        Wscript.Echo "Data Map Pins Per Second" & _
            objCache.DataMapPinsPerSec
        Wscript.Echo "Data Maps Per Second" & _
            objCache.DataMapsPerSec
        Wscript.Echo "Description" & objCache.Description
        Wscript.Echo "Fast Read Not Possibles Per Second" & _
            objCache.FastReadNotPossiblesPerSec
        Wscript.Echo "Fast Read Resource Misses Per Second" & _
            objCache.FastReadResourceMissesPerSec
        Wscript.Echo "Fast Reads Per Second" & _
            objCache.FastReadsPerSec
        Wscript.Echo "Lazy Write Flushes Per Second" & _
            objCache.LazyWriteFlushesPerSec
        Wscript.Echo "Lazy Write Pages Per Second" & _
            objCache.LazyWritePagesPerSec
        Wscript.Echo "MDL Read Hits Percent " & _
            objCache.MDLReadHitsPercent
        Wscript.Echo "MDL Reads Per Second" & _
            objCache.MDLReadsPerSec
        Wscript.Echo "Name" & vbTab & objCache.Name
        Wscript.Echo "Pin Read Hits Percent" & _
            objCache.PinReadHitsPercent
        Wscript.Echo "Pin Reads Per Second" & _
            objCache.PinReadsPerSec
        Wscript.Echo "Read Aheads Per Second" & _
            objCache.ReadAheadsPerSec
        Wscript.Echo "Sync Copy Reads Per Second" & _
            objCache.SyncCopyReadsPerSec
        Wscript.Echo "Sync Data Maps Per Second" & _
            objCache.SyncDataMapsPerSec
        Wscript.Echo "Sync Fast Reads Per Second" & _
            objCache.SyncFastReadsPerSec
        Wscript.Echo "Sync MDL Reads Per Second" & _
            objCache.SyncMDLReadsPerSec
        Wscript.Echo "Sync Pin Reads Per Second" & _
            objCache.SyncPinReadsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a File

Description
Demonstration script that uses the FileSystemObject to copy a file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Set of Files

Description
Demonstration script that uses the FileSystemObject to copy all the .txt files in a folder to a new location.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\*.txt" , "D:\Archive\" , OverwriteExisting

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Custom Document Property

Description
Adds a custom property (TestProperty, with a value of "Test") to the summary information properties for a document named C:\Scripts\Test.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
    ("C:\Scripts\Test.doc")

Set colCustomProperties = objDocument.CustomProperties
errReturn = ColCustomProperties.Add("TestProperty", "Test")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Custom Document Property

Description
Deletes a custom property (TestProperty) from the summary information properties for a document named C:\Scripts\Test.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties_
    ("C:\Scripts\Test.doc")
Set colCustomProperties = objDocument.CustomProperties

For Each strProperty in colCustomProperties
    If strProperty.Name = "TestProperty" Then
        strProperty.Remove()
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a File

Description
Demonstration script that uses the FileSystemObject to delete a file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\FSO\ScriptLog.txt")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Files in a Folder

Description
Demonstration script that deletes all the .txt files in a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const DeleteReadOnly = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\FSO\*.txt"), DeleteReadOnly

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List a Specific Set of Files

Description
Returns a list of all the files larger than 1,000,000 bytes.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
    ExecQuery("Select * from CIM_DataFile where FileSize > 1000000")

For Each objFile in colFiles
    Wscript.Echo objFile.Name & " -- " & objFile.FileSize
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Files in a Folder

Description
Returns a list of all the files in the Scripts folder. If the computer has more than one scripts folder (for example, C:\Scripts and D:\Scripts), files will be returned from each of these folders.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
    ExecQuery("Select * from CIM_DataFile where Path = '\\Scripts\\'")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Files on a Computer

Description
Enumerates all the files on a computer. This is a demonstration script; if actually run, it could take an hour or more to complete, depending on the number of files on the computer. Depending on the number of files and on available memory, this script could also fail before finishing.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery("Select * from CIM_Datafile")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Detailed Summary Information for a File

Description
Uses the Shell's Application object to retrieve detailed summary information including name, size, owner, and file attributes) for all the files in a folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\Scripts")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim arrHeaders(13)

For i = 0 to 13
    arrHeaders(i) = objFolder.GetDetailsOf (objFolder.Items, i)
Next

For Each strFileName in objFolder.Items
    For i = 0 to 13
        If i <> 9 then
            Wscript.echo arrHeaders(i) _
                & ": " & objFolder.GetDetailsOf (strFileName, i)
        End If
    Next
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List File Attributes

Description
Demonstration script that uses the FileSystemObject to enumerate the attributes of a file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\FSO\ScriptLog.txt")

If objFile.Attributes AND 0 Then
    Wscript.Echo "No attributes set."
End If
If objFile.Attributes AND 1 Then
    Wscript.Echo "Read-only."
End If
If objFile.Attributes AND 2 Then
    Wscript.Echo "Hidden file."
End If
If objFile.Attributes AND 4 Then
    Wscript.Echo "System file."
End If
If objFile.Attributes AND 32 Then
    Wscript.Echo "Archive bit set."
End If
If objFile.Attributes AND 64 Then
    Wscript.Echo "Link or shortcut."
End If
If objFile.Attributes AND 2048 Then
    Wscript.Echo "Compressed file."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List File Properties

Description
Demonstration script that uses the FileSystemObject to enumerate the properties of a file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("c:\windows\system32\scrrun.dll")

Wscript.Echo "Date created: " & objFile.DateCreated
Wscript.Echo "Date last accessed: " & objFile.DateLastAccessed
Wscript.Echo "Date last modified: " & objFile.DateLastModified
Wscript.Echo "Drive: " & objFile.Drive
Wscript.Echo "Name: " & objFile.Name
Wscript.Echo "Parent folder: " & objFile.ParentFolder
Wscript.Echo "Path: " & objFile.Path
Wscript.Echo "Short name: " & objFile.ShortName
Wscript.Echo "Short path: " & objFile.ShortPath
Wscript.Echo "Size: " & objFile.Size
Wscript.Echo "Type: " & objFile.Type

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List File Properties

Description
Lists the properties for the file C:\Scripts\Adsi.vbs.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where name = 'c:\\Scripts\\Adsi.vbs'")

For Each objFile in colFiles
    Wscript.Echo "Access mask: " & objFile.AccessMask
    Wscript.Echo "Archive: " & objFile.Archive
    Wscript.Echo "Compressed: " & objFile.Compressed
    Wscript.Echo "Compression method: " & objFile.CompressionMethod
    Wscript.Echo "Creation date: " & objFile.CreationDate
    Wscript.Echo "Computer system name: " & objFile.CSName
    Wscript.Echo "Drive: " & objFile.Drive
    Wscript.Echo "8.3 file name: " & objFile.EightDotThreeFileName
    Wscript.Echo "Encrypted: " & objFile.Encrypted
    Wscript.Echo "Encryption method: " & objFile.EncryptionMethod
    Wscript.Echo "Extension: " & objFile.Extension
    Wscript.Echo "File name: " & objFile.FileName
    Wscript.Echo "File size: " & objFile.FileSize
    Wscript.Echo "File type: " & objFile.FileType
    Wscript.Echo "File system name: " & objFile.FSName
    Wscript.Echo "Hidden: " & objFile.Hidden
    Wscript.Echo "Last accessed: " & objFile.LastAccessed
    Wscript.Echo "Last modified: " & objFile.LastModified
    Wscript.Echo "Manufacturer: " & objFile.Manufacturer
    Wscript.Echo "Name: " & objFile.Name
    Wscript.Echo "Path: " & objFile.Path
    Wscript.Echo "Readable: " & objFile.Readable
    Wscript.Echo "System: " & objFile.System
    Wscript.Echo "Version: " & objFile.Version
    Wscript.Echo "Writeable: " & objFile.Writeable
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List File Version Information

Description
Demonstration script that uses the FileSystemObject to retrieve the file version for a .dll file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Wscript.Echo objFSO.GetFileVersion("c:\windows\system32\scrrun.dll")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Files Using an Asynchronous Query

Description
Uses an asynchronous query to enumerate all the files on a computer. This is primarily a demonstration script; if actually run, it could take an hour or more to complete, depending on the number of files on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const POPUP_DURATION = 120
Const OK_BUTTON = 0

Set objWSHShell = Wscript.CreateObject("Wscript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objSink = WScript.CreateObject("WbemScripting.SWbemSink","SINK_")
objWMIService.ExecQueryAsync objSink, "Select * from CIM_DataFile"
objPopup = objWshShell.Popup("Starting file retrieval", _
    POPUP_DURATION, "File Retrieval", OK_BUTTON)

Sub SINK_OnObjectReady(objEvent, objAsyncContext)
    Wscript.Echo objEvent.Name
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Summary Information for a Set of Files

Description
Lists summary information for all the files in the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FILE_NAME = 0

Set objShell = CreateObject ("Shell.Application")
Set objFolder = objShell.Namespace ("C:\Scripts")

For Each strFileName in objFolder.Items
    Wscript.Echo "File name: " & objFolder.GetDetailsOf _
        (strFileName, FILE_NAME)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Custom Document Property

Description
Modifies a custom property (TestProperty, setting the new value to "New value") found in the summary information properties for a document named C:\Scripts\Test.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
    ("C:\Scripts\Test.doc")

Set colCustomProperties = objDocument.CustomProperties
For Each strProperty in colCustomProperties
    If strProperty.Name = "TestProperty" Then
        strProperty.Value = "New value"
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Document Property Information

Description
Modifies the Category property included in the summary information properties for a document named C:\Scripts\Test.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
    ("C:\Scripts\Test.doc")

objDocument.Category = "Scripting Documents"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify File Attributes

Description
Demonstration script that checks to see if a file is read-only and, if it is not, marks it as read-only. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\FSO\TestScript.vbs")

If objFile.Attributes = objFile.Attributes AND 1 Then
    objFile.Attributes = objFile.Attributes XOR 1
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify File Extensions

Description
Changes the file extension for all the .log files in the C:\Scripts folder to .txt.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set FileList = objWMIService.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='c:\Scripts'} Where " _
        & "ResultClass = CIM_DataFile")

For Each objFile In FileList
    If objFile.Extension = "log" Then
        strNewName = objFile.Drive & objFile.Path & _
            objFile.FileName & "." & "txt"
        errResult = objFile.Rename(strNewName)
    End If
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor File Creation

Description
Temporary event consumer that issues an alert any time a file is created in the C:\Scripts folder. Best when run under Cscript.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts""'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor File Deletion

Description
Temporary event consumer that issues an alert any time a file is deleted from the C:\Scripts folder. Best when run under Cscript.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceDeletionEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts""'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor File Modification

Description
Temporary event consumer that issues an alert any time the file C:\Scripts\Index.vbs is modified. Best when run under Cscript.exe.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    ("SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE " _
        & "TargetInstance ISA 'CIM_DataFile' and " _
            & "TargetInstance.Name='c:\\scripts\\index.vbs'")

Do
    Set objLatestEvent = colMonitoredEvents.NextEvent
    Wscript.Echo "File: " & objLatestEvent.TargetInstance.Name
    Wscript.Echo "New size: " & objLatestEvent.TargetInstance.FileSize
    Wscript.Echo "Old size: " & objLatestEvent.PreviousInstance.FileSize
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a File

Description
Demonstration script that uses the FileSystemObject to move a file from one location to another. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\FSO\ScriptLog.log" , "D:\Archive"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Set of Files

Description
Demonstration script that uses the FileSystemObject to move all the .txt files in a folder to a new location. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\FSO\*.txt" , "D:\Archive\"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move Files

Description
Moves all the Windows Media (.wma) files to the folder C:\Media Archive.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService. _
    ExecQuery("Select * from CIM_DataFile where Extension = 'wma'")

For Each objFile in colFiles
    strCopy = "C:\Media Archive\" & objFile.FileName _
        & "." & objFile.Extension
    objFile.Copy(strCopy)
    objFile.Delete
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Parse a Path Name

Description
Demonstration script that uses the FileSystemObject to return pathname information for a file, including name, extension, complete path, etc. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("ScriptLog.txt")

Wscript.Echo "Absolute path: " & objFSO.GetAbsolutePathName(objFile)
Wscript.Echo "Parent folder: " & objFSO.GetParentFolderName(objFile)
Wscript.Echo "File name: " & objFSO.GetFileName(objFile)
Wscript.Echo "Base name: " & objFSO.GetBaseName(objFile)
Wscript.Echo "Extension name: " & objFSO.GetExtensionName(objFile)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Perform Actions on Files

Description
Uses the Shell object to print all the files in the C:\Logs folder.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

TargetFolder = "C:\Logs"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(TargetFolder)
Set colItems = objFolder.Items

For i = 0 to colItems.Count - 1
    colItems.Item(i).InvokeVerbEx("Print")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a File

Description
Demonstration script that uses the FileSystemObject to rename a file. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\FSO\ScriptLog.txt" , "C:\FSO\BackupLog.txt"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename Files

Description
Renames the file C:\Scripts\Toggle_Service.vbs to C:\Scripts\Toggle_Service.old.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from Cim_Datafile where Name = " _
        & "'c:\\scripts\\toggle_service.vbs'")

For Each objFile in colFiles
    errResult = objFile.Rename("c:\scripts\toggle_service.old")
    Wscript.Echo errResult
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Retrieving Document Property Information

Description
Lists the summary information properties for a document named C:\Scripts\Test.doc.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objPropertyReader = CreateObject("DSOleFile.PropertyReader")
Set objDocument = objPropertyReader.GetDocumentProperties _
    ("C:\Scripts\Test.doc")

Wscript.Echo "Application name: " & objDocument.AppName
Wscript.Echo "Author: " & objDocument.Author
Wscript.Echo "Byte count: " & objDocument.ByteCount
Wscript.Echo "Category: " & objDocument.Category
Wscript.Echo "Character count: " & objDocument.CharacterCount
Wscript.Echo "Character count with spaces: " & _
    objDocument.CharacterCountWithSpaces
Wscript.Echo "CLSID: " & objDocument.CLSID
Wscript.Echo "Comments: " & objDocument.Comments
Wscript.Echo "Company: " & objDocument.Company
Set colCustomProperties = objDocument.CustomProperties
For Each strProperty in colCustomProperties
    Wscript.Echo vbTab & strProperty.Name & ": " & strProperty.Value
Next
Wscript.Echo "Date created: " & objDocument.DateCreated
Wscript.Echo "Date last printed: " & objDocument.DateLastPrinted
Wscript.Echo "Date last saved: " & objDocument.DateLastSaved
Wscript.Echo "Has macros: " & objDocument.HasMacros
Wscript.Echo "Hidden slides: " & objDocument.HiddenSlides
Wscript.Echo "Icon: " & objDocument.Icon
Wscript.Echo "Is read only: " & objDocument.IsReadOnly
Wscript.Echo "Keywords" & objDocument.Keywords
Wscript.Echo "Last edited by: " & objDocument.LastEditedBy
Wscript.Echo "Line count: " & objDocument.LineCount
Wscript.Echo "Location: " & objDocument.Location
Wscript.Echo "Manager: " & objDocument.Manager
Wscript.Echo "Multimedia clips: " & objDocument.MultimediaClips
Wscript.Echo "Name: " & objDocument.Name
Wscript.Echo "Page count: " & objDocument.PageCount
Wscript.Echo "Paragraph count: " & objDocument.ParagraphCount
Wscript.Echo "Presentation format: " & objDocument.PresentationFormat
Wscript.Echo "Presentation notes: " & objDocument.PresentationNotes
Wscript.Echo "ProgID: " & objDocument.ProgID
Wscript.Echo "Revision number: " & objDocument.RevisionNumber
Wscript.Echo "Slide count: " & objDocument.SlideCount
Wscript.Echo "Subject: " & objDocument.Subject
Wscript.Echo "Template: " & objDocument.Template
Wscript.Echo "Thumbnail: " & objDocument.Thumbnail
Wscript.Echo "Title: " & objDocument.Title
Wscript.Echo "Version: " & objDocument.Version
Wscript.Echo "Word count: " & objDocument.WordCount

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Retrieving Extended File Properties

Description
Uses the Shell object to return extended properties for all the files in the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Dim arrHeaders(34)

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Scripts")

For i = 0 to 33
    arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next

For Each strFileName in objFolder.Items
    For i = 0 to 33
        Wscript.Echo i & vbtab & arrHeaders(i) _
            & ": " & objFolder.GetDetailsOf(strFileName, i)
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Files Using a Wildcard Query

Description
Uses the Like keyword to search for all files on a computer that begin with the tilde (~).

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where FileName Like '%~%'")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that a File Exists

Description
Uses the FileSystemObject to determine whether or not the file C:\FSO\ScriptLog.txt exists on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists("C:\FSO\ScriptLog.txt") Then
    Set objFolder = objFSO.GetFile("C:\FSO\ScriptLog.txt")
Else
    Wscript.Echo "File does not exist."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Bind to a Folder Using the Browse for Folder Dialog Box

Description
Uses the Shell object to display the Browse for Folder dialog box. After a folder has been selected, the script reports whether or not the folder is read-only.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
    (WINDOW_HANDLE, "Select a folder:", NO_OPTIONS, "C:\Scripts")
Set objFolderItem = objFolder.Self

objPath = objFolderItem.Path
objPath = Replace(objPath, "\", "\\")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where name = '" & objPath & "'")

For Each objFile in colFiles
    Wscript.Echo "Readable: " & objFile.Readable
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Compress a Folder

Description
Compresses the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults = objFolder.Compress
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Folder

Description
Demonstration script that uses the FileSystemObject to copy a folder to a new location. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const OverWriteFiles = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Scripts" , "C:\FSO" , OverWriteFiles

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Folder Using the Shell Object

Description
Uses the Shell object to copy the folder C:\Scripts to D:\Archives. Displays the Copying Files progress dialog as the folder is being copied.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FOF_CREATEPROGRESSDLG = &H0&

ParentFolder = "D:\Archive"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\Scripts", FOF_CREATEPROGRESSDLG

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Copy a Folder Using WMI

Description
Uses WMI to copy the folder C:\Scripts to D:\Archive.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery( _
    "Select * from Win32_Directory where Name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults  = objFolder.Copy("D:\Archive")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Folder Using the Shell Object

Description
Uses the Shell object to create a new folder named C:\Archive.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

ParentFolder = "C:\"

set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)
objFolder.NewFolder "Archive"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Folder

Description
Demonstration script that uses the FileSystemObject to create a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\FSO")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Folder

Description
Deletes the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where Name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults = objFolder.Delete
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Folder on the Local Computer

Description
Demonstration script that uses the FileSystemObject to delete a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("C:\FSO")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enumerate Subfolders Using Recursion

Description
Demonstration script that uses the FileSystemObject to recursively list all the subfolders (and their subfolders) within a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubfolders FSO.GetFolder("C:\Scripts")

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Wscript.Echo Subfolder.Path
        ShowSubFolders Subfolder
    Next
End Sub

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List a Specific Set of Folders

Description
Returns a list of all the hidden folders on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _
    ("Select * from Win32_Directory Where Hidden = True")

For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All the Folders on a Computer

Description
Returns a list of all the folders on a computer. This can take 15 minutes or more to complete, depending on the number of folders on the computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery("Select * from Win32_Directory")

For Each objFolder in colFolders
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Folder Attributes

Description
Demonstration script that uses the FileSystemObject to enumerate the attributes of a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")

If objFolder.Attributes AND 2 Then
    Wscript.Echo "Hidden folder."
End If
If objFolder.Attributes AND 4 Then
    Wscript.Echo "System folder."
End If
If objFolder.Attributes AND 16 Then
    Wscript.Echo "Folder."
End If
If objFolder.Attributes AND 32 Then
    Wscript.Echo "Archive bit set."
End If
If objFolder.Attributes AND 2048 Then
    Wscript.Echo "Compressed folder."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Folder Properties

Description
Demonstration script that uses the FileSystemObject to enumerate the properties of a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Scripts")

Wscript.Echo "Date created: " & objFolder.DateCreated
Wscript.Echo "Date last accessed: " & objFolder.DateLastAccessed
Wscript.Echo "Date last modified: " & objFolder.DateLastModified
Wscript.Echo "Drive: " & objFolder.Drive
Wscript.Echo "Is root folder: " & objFolder.IsRootFolder
Wscript.Echo "Name: " & objFolder.Name
Wscript.Echo "Parent folder: " & objFolder.ParentFolder
Wscript.Echo "Path: " & objFolder.Path
Wscript.Echo "Short name: " & objFolder.ShortName
Wscript.Echo "Short path: " & objFolder.ShortPath
Wscript.Echo "Size: " & objFolder.Size
Wscript.Echo "Type: " & objFolder.Type

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Folder Properties

Description
Lists the properties of the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService. _
    ExecQuery("Select * from Win32_Directory where name = 'c:\\Scripts'")

For Each objFolder in colFolders
    Wscript.Echo "Archive: " & objFolder.Archive
    Wscript.Echo "Caption: " & objFolder.Caption
    Wscript.Echo "Compressed: " & objFolder.Compressed
    Wscript.Echo "Compression method: " & objFolder.CompressionMethod
    Wscript.Echo "Creation date: " & objFolder.CreationDate
    Wscript.Echo "Encrypted: " & objFolder.Encrypted
    Wscript.Echo "Encryption method: " & objFolder.EncryptionMethod
    Wscript.Echo "Hidden: " & objFolder.Hidden
    Wscript.Echo "In use count: " & objFolder.InUseCount
    Wscript.Echo "Last accessed: " & objFolder.LastAccessed
    Wscript.Echo "Last modified: " & objFolder.LastModified
    Wscript.Echo "Name: " & objFolder.Name
    Wscript.Echo "Path: " & objFolder.Path
    Wscript.Echo "Readable: " & objFolder.Readable
    Wscript.Echo "System: " & objFolder.System
    Wscript.Echo "Writeable: " & objFolder.Writeable
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Folders Based on Creation Date

Description
Lists all the folders on a computer that were created after 3/1/2002.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const LOCAL_TIME = TRUE

Set dtmTargetDate = CreateObject("WbemScripting.SWbemDateTime")
Set dtmConvertedDate = CreateObject("WbemScripting.SWbemDateTime")
dtmTargetDate.SetVarDate "3/1/2004", LOCAL_TIME

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory Where " _
        & "CreationDate > '" & dtmTargetDate & "'")

For each objFolder in colFolders
    dtmConvertedDate.Value = objFolder.CreationDate
    Wscript.Echo objFolder.Name & VbTab & _
        dtmConvertedDate.GetVarDate(LOCAL_TIME)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Shell Object Verbs

Description
Returns a list of Shell object verbs (context menu items) for the Recycle Bin.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

Const RECYCLE_BIN = &Ha&

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(RECYCLE_BIN)
Set objFolderItem = objFolder.Self
Set colVerbs = objFolderItem.Verbs

For i = 0 to colVerbs.Count - 1
    Wscript.Echo colVerbs.Item(i)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Subfolders of a Folder

Description
Uses a WMI Associators of query to list all the subfolders of the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSubfolders = objWMIService.ExecQuery _
    ("Associators of {Win32_Directory.Name='c:\scripts'} " _
        & "Where AssocClass = Win32_Subdirectory " _
            & "ResultRole = PartComponent")

For Each objFolder in colSubfolders
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List the Subfolders of a Folder on the Local Computer

Description
Demonstration script that uses the FileSystemObject to return the folder name and size for all the subfolders in a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")
Set colSubfolders = objFolder.Subfolders

For Each objSubfolder in colSubfolders
    Wscript.Echo objSubfolder.Name, objSubfolder.Size
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Folder Attributes

Description
Demonstration script that uses the FileSystemObject to check if a folder is hidden and, if it is not, hides it. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FSO")

If objFolder.Attributes = objFolder.Attributes AND 2 Then
    objFolder.Attributes = objFolder.Attributes XOR 2
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Folder

Description
Demonstration script that uses the FileSystemObject to move a folder from one location to another. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\Scripts" , "M:\helpdesk\management"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Folder Using the Shell Object

Description
Uses the Shell object to move the folder C:\Scripts to D:\Archives. Displays the Copying Files progress dialog as the folder is being moved.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FOF_CREATEPROGRESSDLG = &H0&

TargetFolder = "D:\Archive"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.MoveHere "C:\Scripts", FOF_CREATEPROGRESSDLG

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Move a Folder Using WMI

Description
Uses WMI to move the folder C:\Scripts to C:\Admins\Documents\Archive\VBScript.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults = objFolder.Rename("C:\Admins\Documents\Archive\VBScript")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Folder

Description
Renames the folder C:\Scripts to C:\Repository.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults = objFolder.Rename("C:\Script Repository")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Folder on the Local Computer

Description
Demonstration script that uses the FileSystemObject to rename a folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFolder "C:\FSO\Samples" , "C:\FSO\Scripts"

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Folders by Date

Description
Finds all the folders created after March 1, 2002.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

dtmTargetDate = "20020301000000.000000-420"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory Where CreationDate > '" & _
        dtmtargetDate & "'")

For Each objFolder in colFolders
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Folders Using Wildcards

Description
Returns a list of all the folders whose path begins with C:\S.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where Name Like '%c:\\S%'")

For Each objFolder in colFolders
    Wscript.Echo "Name: " & objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Uncompress a Folder

Description
Uncompresses the folder C:\Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
    ("Select * from Win32_Directory where name = 'c:\\Scripts'")

For Each objFolder in colFolders
    errResults = objFolder.Uncompress
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Verify that a Folder Exists

Description
Demonstration script that uses the FileSystemObject to verify that a folder exists. If the folder does exist, the script binds to that folder. Script must be run on the local computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists("C:\FSO") Then
    Set objFolder = objFSO.GetFolder("C:\FSO")
Else
    Wscript.Echo "Folder does not exist."
End If

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Network Share

Description
Creates a shared folder named FinanceShare, setting the maximum number of simultaneous connections to 25 and adding a share description.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const FILE_SHARE = 0
Const MAXIMUM_CONNECTIONS = 25

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNewShare = objWMIService.Get("Win32_Share")

errReturn = objNewShare.Create _
    ("C:\Finance", "FinanceShare", FILE_SHARE, _
        MAXIMUM_CONNECTIONS, "Public share for the Finance group.")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Network Share

Description
Stops sharing a shared folder named FinanceShare. This does not delete the folder from the local hard drive, but simply stops making it available over the network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'FinanceShare'")

For Each objShare in colShares
    objShare.Delete
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Published Folder

Description
Deletes a published folder named FinanceShare from Active Directory. This does not delete the share itself, it simply removes it from Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objContainer = GetObject("LDAP://CN=FinanceShare, " _
    & "OU=Finance, DC=fabrikam, DC=com")

objContainer.DeleteObject (0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Shares

Description
Lists all the shared folders on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")

For each objShare in colShares
    Wscript.Echo "Allow Maximum: " & objShare.AllowMaximum
    Wscript.Echo "Caption: " & objShare.Caption
    Wscript.Echo "Maximum Allowed: " & objShare.MaximumAllowed
    Wscript.Echo "Name: " & objShare.Name
    Wscript.Echo "Path: " & objShare.Path
    Wscript.Echo "Type: " & objShare.Type
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Shared Folders Published in Active Directory

Description
Lists all the shared folders that have been published in Active Directory.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select Name, unCName, ManagedBy from " _
    & "'LDAP://DC=Fabrikam,DC=com' where objectClass='volume'"
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Share Name: " & objRecordSet.Fields("Name").Value
    Wscript.Echo "UNC Name: " & objRecordSet.Fields("uNCName").Value
    Wscript.Echo "Managed By: " & objRecordSet.Fields("ManagedBy").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Map a Network Share to a Local Folder

Description
Uses a WMI Associators of query to return the local path of all the network shares on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Associators of {Win32_Share.Name='Scripts'} Where " _
        & "AssocClass=Win32_ShareToDirectory")

For Each objFolder in colShares
    Wscript.Echo objFolder.Name
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Map All Network Shares to Local Folders

Description
Uses a WMI Associators of query to return the local path of a network share named Scripts.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * From Win32_Share")

For Each objShare in colShares
    Set colAssociations = objWMIService.ExecQuery _
        ("Associators of {Win32_Share.Name='" & objShare.Name & "'} " _
            & " Where AssocClass=Win32_ShareToDirectory")
    For Each objFolder in colAssociations
        Wscript.Echo objShare.Name & vbTab & objFolder.Name
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Network Share

Description
Accesses a shared folder named FinanceShare, changes the maximum number of simultaneous connections to 50, and provides a new share description.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery _
    ("Select * from Win32_Share Where Name = 'FinanceShare'")

For Each objShare in colShares
    errReturn = objShare.SetShareInfo(50, _
        "Public share for HR administrators and the Finance Group.")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Publish a Shared Folder in Active Directory

Description
Publishes a shared folder in Active Directory, assigning the folder a description and three keywords.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

Set objComputer = GetObject _
    ("LDAP://OU=Finance, DC=fabrikam, DC=com")

Set objShare = objComputer.Create("volume", "CN=FinanceShare")

objShare.Put "uNCName", "\\atl-dc-02\FinanceShare"
objShare.Put "Description", "Public share for users in the Finance group."
objShare.Put "Keywords", Array("finance", "fiscal", "monetary")
objShare.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Specific Published Folders in Active Directory

Description
Searches Active Directory for any shared folders that have the keyword "finance."

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | Yes
Windows NT 4.0 | Yes
Windows 98 | Yes

Script Code

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = "Select Name, unCName, ManagedBy from "
    & "'LDAP://DC=Reskit,DC=com'" _
        & " where objectClass='volume' and Keywords = 'finance*'"
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    Wscript.Echo "Share Name: " & objRecordSet.Fields("Name").Value
    Wscript.Echo "UNC Name: " & objRecordSet.Fields("uNCName").Value
    Wscript.Echo "Managed By: " & objRecordSet.Fields("ManagedBy").Value
    objRecordSet.MoveNext
Loop

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Terminal Services Direct Connect License Server

Description
Adds the computer atl-ts-01 as a direct connect license server to a computer running Terminal Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.AddDirectConnectLicenseServer("atl-ts-01")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Assign a Terminal Services Initial Program

Description
Assigns the startup program C:\Accounting\Invoice.exe (with a startup folder of C:\Accounting\FY_2003) to users logging on to a computer running Terminal Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const STARTUP_PROGRAM = "c:\accounting\invoice.exe"
Const STARTUP_FOLDER = "c:\accounting\fy_2003"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSEnvironmentSetting")

For Each objItem in colItems
    errResult = objItem.InitialProgram(STARTUP_PROGRAM, STARTUP_FOLDER)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Terminal Service Direct Connect License Server

Description
Removes the computer atl-ts-01 as a direct connect license server for a computer running Terminal Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.DeleteDirectConnectLicenseServer("atl-ts-01")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Forcible Terminal Services Logoff

Description
Enables the ability to forcibly logoff an administrator connected to Terminal Services. To disable forcible logoff, pass the value 1 (rather than 0) to the SetDisableForcibleLogoff method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE_LOGOFF = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetDisableForcibleLogoff(ENABLE_LOGOFF)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Single Session Terminal Service Sessions

Description
Enables single session Terminal Service sessions on a computer. To allow multiple sessions, pass the value 0 (rather than 1) to the SetSingleSession parameter.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetSingleSession(ENABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Terminal Service Connections

Description
Enables Terminal Services connections on a computer running Terminal Services. To disable connections, pass the value 0 (rather than 1) to the SetAllowTSConnections method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE_CONNECTIONS = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Terminal Services

Description
Enables the Accounting terminal on a computer running Terminal Services. To disable the Accounting terminal, set the parameter of the Enable method to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Terminal Where TerminalName = 'Accounting'")

For Each objItem in colItems
    errResult = objItem.Enable(ENABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Terminal Services Active Desktop

Description
Enables Terminal Services Active Desktop on a computer. To disable Active Desktop, set the value of the ActiveDesktop property to 0 instead of 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLED = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    objItem.ActiveDesktop = ENABLED
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Terminal Services Password Prompt

Description
Configure Terminal Services to prompt for a password each time a user logs on. To disable password prompting, pass the value 0 (rather than 1) to the SetPromptForPassword method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSLogonSetting")

For Each objItem in colItems
    errResult = objItem.SetPromptForPassword(ENABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Terminal Services Session Directory

Description
Enable the session directory on a Terminal Services server. To disable the session directory, pass the value 0 (rather than 1) to the SetSessionDirectoryActive method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE_SESSION_DIRECTORY = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSSessionDirectory")

For Each objItem in colItems
    errResult = objItem.SetSessionDirectoryActive(ENABLE_SESSION_DIRECTORY)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Expose the Terminal Services Session Directory Server IP Address

Description
Allow a Terminal Services server to make its session directory IP address available. To prevent a server from exposing its session directory IP address, pass the value 0 (rather than 1) to the SetSessionDirectoryExposeServerIP method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSSessionDirectory")

For Each objItem in colItems
    errResult = objItem.SetSessionDirectoryExposeServerIP(ENABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Service Audit Permissions

Description
Prevents the user fabrikam\bob from being able to query Terminal Services Accounting terminal for session information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const WINSTATION_QUERY = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSAccount Where AccountName = 'fabrikam\\bob' AND " _
        & "TerminalName = 'Accounting'")

For Each objItem in colItems
    errResult = objItem.ModifyAuditPermissions(WINSTATION_QUERY, False)
 ext

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Service Permissions

Description
Gives the user fabrikam\bob the right to connect to another Terminal Services session.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

CONST WINSTATION_CONNECT = 8

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSAccount Where AccountName = 'fabrikam\\bob' " & _
        "AND TerminalName = 'Accounting'")

For Each objItem in colItems
    errResult = objItem.ModifyPermissions(WINSTATION_CONNECT,True)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Service Remote Control Settings

Description
Enables remote user to view, but not actively control, a session. Permission of the logged-on session user is not required.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE_NO_INPUT_NO_NOTIFY = 4

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
  ("Select * from Win32_TSRemoteControlSetting Where " & _
        "TerminalName = 'Accounting'")

For Each objItem in colItems
  errResult = objItem.RemoteControl(ENABLE_NO_INPUT_NO_NOTIFY)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Broken Connection Policy

Description
Enables per-user application of broken connection policies. To apply the same broken connection policies to all users, set the value of the BrokenConnectionPolicy property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    objItem.BrokenConnectionPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Broken Connection Settings

Description
Configures Terminal Services to permanently delete a session in case of a broken connection. To configure Terminal Services to merely disconnect the user from the session instead, pass the value 0 (instead of 1) to the BrokenConnection method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const DISCONNECT_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    errResult = objItem.BrokenConnection(DISCONNECT_USER)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Client Connection Settings

Description
Configures a Terminal Services client so that mapped drives and printers are automatically connected at logon; also enables print jobs to be sent directly to the client’s local printer. These settings can be disabled by setting the appropriate constant value to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const CONNECT_CLIENT_DRIVES = 1
Const CONNECT_PRINTER = 1
Const USE_CLIENT_PRINTER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    errResult = objItem.ConnectionSettings _
        (CONNECT_CLIENT_DRIVES, CONNECT_PRINTER, USE_CLIENT_PRINTER)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Client Logon Settings

Description
Enables per-user application of client logon policies. To apply the same policies to all users, set the value of the ClientLogonInfoPolicy property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSLogonSetting")

For Each objItem in colItems
    objItem.ClientLogonInfoPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Client Settings

Description
Disables audio mapping on a computer running Terminal Services. To enable audio mapping, pass the value 1 (rather than 0) to the SetClientProperty method. To configure a different property value, replace the parameter AudioMapping with the appropriate property name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const DISABLE = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    errResult = objItem.SetClientProperty("AudioMapping", DISABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Client Wallpaper Settings

Description
Disables client wallpaper on a computer running Terminal Services. To enable the use of client wallpaper, pass the value 1 (rather than 0) to the SetClientWallpaper method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const NO_WALLPAPER = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSEnvironmentSetting")

For Each objItem in colItems
    errResult = objItem.SetClientWallpaper(NO_WALLPAPER)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Color Depth

Description
Configures Terminal Services to use 16-bit color for client sessions. To use 8-bit color, pass the value 1 (rather than 3) to the SetColorDepth method. Pass the value 4 to use 24-bit color.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const SIXTEEN_BIT_COLOR = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    errResult = objItem.SetColorDepth(SIXTEEN_BIT_COLOR)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Color Depth Policy

Description
Enables the color depth policy on a computer running Terminal Services. To disable this policy, pass the value 0 (rather than 1) to the SetColorDepthPolicy method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLE = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    errResult = objItem.SetColorDepthPolicy(ENABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Connection Policy

Description
Configures Terminal Services to use per-user connection settings. To apply the same connection settings to all users, set the value of the ConnectionPolicy property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    objItem.ConnectionPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Encryption Level

Description
Configures Terminal Services to use high encryption (parameter value of 3). To use low-encryption, pass the SetEncryptionLevel method a value of 1. Client-compatible encryption uses a value of 2, and FIPS-compliant encryption uses a value of 4.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const HIGH_ENCRYPTION = 3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSGeneralSetting")

For Each objItem in colItems
    errResult = objItem.SetEncryptionLevel(HIGH_ENCRYPTION)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Home Directory

Description
Configures the default home directory on a Terminal Services server to C:\TSUsers.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetHomeDirectory("c:\tsusers")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Initial Program Policy

Description
Configures Terminal Services to assign startup programs on a per-user basis. To have Terminal Services apply the same startup program to all users, set the value of the InitialProgramPolicy property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

CONST PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSEnvironmentSetting")

For Each objItem in colItems
    objItem.InitialProgramPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Logon Policy

Description
Enables new sessions on Terminal Services. To disable new sessions, set the value of the Logons property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const NEW_SESSIONS_ALLOWED = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    objItem.Logons = NEW_SESSIONS_ALLOWED
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Maximum Connections

Description
Sets the maximum number of connections allowed on a Terminal Services network adapter to 100.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const MAXIMUM_CONNECTIONS = 100

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSNetworkAdapterSetting")

For Each objItem in colItems
    objItem.MaximumConnections = MAXIMUM_CONNECTIONS
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Mode

Description
Enables per-session licensing for Terminal Services. To enable per-device licensing, pass the value 2 (rather than 4) to the ChangeMode method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_SESSION = 4

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.ChangeMode(PER_SESSION)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Policy Property

Description
Disables the UseTempFolders policy on a computer running Terminal Services. To enable this policy, pass the value 1 (rather than 0) to the SetPolicyPropertyName method. To configure a different policy, simply replace the method parameter “UseTempFolders” with the appropriate policy name.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const DISABLE_POLICY = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetPolicyPropertyName("UseTempFolders", DISABLE_POLICY)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Profile Path

Description
Sets the Terminal Services profile path on a computer to C:\TSProfiles.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetProfilePath("c:\tsprofiles")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Reconnection Policy

Description
Allows a user to reconnect to a Terminal Services session using any client. To require users to reconnect to a session using the same client they used previously, set the value of the ReconnectionPolicy property to 1 rather than 0.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PREVIOUS_CLIENT = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    objItem.ReconnectionPolicy = PREVIOUS_CLIENT
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Remote Control Policy

Description
Enables Terminal Services to apply per-user remote control policies. To apply the same remote control policies to all users, set the value of the RemoteControlPolicy property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSRemoteControlSetting")

For Each objItem in colItems
    objItem.RemoteControlPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Session Directory IP Address

Description
Configures Terminal Services to use a session directory with the IP address of 192.168.1.3.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSSessionDirectory")

For Each objItem in colItems
    objItem.SessionDirectoryIPAddress = "192.168.1.3"
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Session Directory Location

Description
Sets the session directory location of a Terminal Services server to 192.168.1.3.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSSessionDirectory")

For Each objItem in colItems
    errResult = objItem.SetSessionDirectoryProperty _
        ("SessionDirectoryLocation", "192.168.1.3")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Session Time Limit

Description
Allows unlimited-length active sessions in Terminal Services. To enforce a time limit on active sessions, pass the TimeLimit method a value other than 0. Time limits must be expressed in milliseconds; for example, a one-minute session limit would be expressed as 60000: 60 seconds times 1000 milliseconds. A one-hour time limit would be expressed as 3600000.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const NO_SESSION_LIMIT = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    errResult = objItem.TimeLimit("ActiveSessionLimit", NO_SESSION_LIMIT)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Time Limit Policy

Description
Configures Terminal Services to use per-user time limit policies. To apply the server’s time limit policies to all users, set the value of the TimeLimitPolicy property to 0 instead of 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const PER_USER = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    objItem.TimeLimitPolicy = PER_USER
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Time Zone Redirection

Description
Disables Terminal Service time zone redirection on a computer. To enable time zone redirection, pass the value 1 (instead of 0) to the SetTimeZoneRedirection method.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const DISABLE = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    errResult = objItem.SetTimeZoneRedirection(DISABLE)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services User Permissions

Description
Enables Terminal Services application compatibility. To disable application compatibility, set the value of the UserPermission property to 0 instead of 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ENABLED = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    objItem.UserPermission = ENABLED
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Windows Authentication Setting

Description
Configures Terminal Services to use standard Windows authentication. To disable standard authentication (in order to use a custom authentication package), set the value of the WindowsAuthentication property to 0 rather than 1.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const STANDARD_AUTHENTICATION = 1

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSGeneralSetting")

For Each objItem in colItems
    objItem.WindowsAuthentication = STANDARD_AUTHENTICATION
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Terminal Services Comment

Description
Modifies the descriptive comment attached to a Terminal Services server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSGeneralSetting")

For Each objItem in colItems
    objItem.Comment = "Accounting session."
    objItem.Put_
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify the Terminal Services Logon

Description
Configures the credentials (name, password, and domain) used to log on to Terminal Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const TS_USER = "tsuser"
CONST TS_DOMAIN = "fabrikam"
CONST TS_PASSWORD = "password"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSLogonSetting")

For Each objItem in colItems
    errResult = objItem.ExplicitLogon(TS_USER, TS_DOMAIN, TS_PASSWORD)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Rename a Terminal Service Terminal

Description
Renames the Terminal Services terminal RDP-tcp (the default name) to Accounting.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_Terminal Where TerminalName = 'RDP-tcp'")

For Each objItem in colItems
    errResult = objItem.Rename("Accounting")
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Restore the Default Terminal Service Permissions

Description
Restores the default permission settings for all the Terminal Service accounts on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSPermissionsSetting")

For Each objItem in colItems
    errResult = objItem.RestoreDefaults()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Terminal Service Session Performance

Description
Uses cooked performance counters to monitor Terminal Service session performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_Perf_TermService_TerminalServiceSession").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Handle Count: " & objItem.HandleCount
        Wscript.Echo "Input Asynchronous Frame Error: " & _
            objItem.InputAsyncFrameError
        Wscript.Echo "Input Asynchronous Overflow: " & _
            objItem.InputAsyncOverflow
        Wscript.Echo "Input Asynchronous Overrun: " & objItem.InputAsyncOverrun
        Wscript.Echo "Input Asynchronous Parity Error: " & _
            objItem.InputAsyncParityError
        Wscript.Echo "Input Bytes: " & objItem.InputBytes
        Wscript.Echo "Input Compressed Bytes: " & objItem.InputCompressedBytes
        Wscript.Echo "Input Compress Flushes: " & objItem.InputCompressFlushes
        Wscript.Echo "Input Compression Ratio: " & _
            objItem.InputCompressionRatio
        Wscript.Echo "Input Errors: " & objItem.InputErrors
        Wscript.Echo "Input Frames: " & objItem.InputFrames
        Wscript.Echo "Input Timeouts: " & objItem.InputTimeouts
        Wscript.Echo "Input Transport Errors: " & objItem.InputTransportErrors
        Wscript.Echo "Input Wait For OutputBuffer: " & _
            objItem.InputWaitForOutBuf
        Wscript.Echo "Input Wd Bytes: " & objItem.InputWdBytes
        Wscript.Echo "Input Wd Frames: " & objItem.InputWdFrames
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Output Asynchronous Frame Error: " & _
            objItem.OutputAsyncFrameError
        Wscript.Echo "Output Asynchronous Overflow: " & _
            objItem.OutputAsyncOverflow
        Wscript.Echo "Output Asynchronous Overrun: " & _
            objItem.OutputAsyncOverrun
        Wscript.Echo "OutputAsynchronous Parity Error: " & _
            objItem.OutputAsyncParityError
        Wscript.Echo "Output Bytes: " & objItem.OutputBytes
        Wscript.Echo "Output Compressed Bytes: " & _
            objItem.OutputCompressedBytes
        Wscript.Echo "Output Compress Flushes: " & _
            objItem.OutputCompressFlushes
        Wscript.Echo "Output Compression Ratio: " & _
            objItem.OutputCompressionRatio
        Wscript.Echo "Output Errors: " & objItem.OutputErrors
        Wscript.Echo "Output Frames: " & objItem.OutputFrames
        Wscript.Echo "Output Timeouts: " & objItem.OutputTimeouts
        Wscript.Echo "Output Transport Errors: " & _
            objItem.OutputTransportErrors
        Wscript.Echo "Output Wait For Outout Buffer: " & _
            objItem.OutputWaitForOutBuf
        Wscript.Echo "Output Wd Bytes: " & objItem.OutputWdBytes
        Wscript.Echo "Output Wd Frames: " & objItem.OutputWdFrames
        Wscript.Echo "Page Faults Per Second: " & objItem.PageFaultsPersec
        Wscript.Echo "Page File Bytes: " & objItem.PageFileBytes
        Wscript.Echo "Page File Bytes Peak: " & objItem.PageFileBytesPeak
        Wscript.Echo "Percent Privileged Time: " & _
            objItem.PercentPrivilegedTime
        Wscript.Echo "Percent Processor Time: " & objItem.PercentProcessorTime
        Wscript.Echo "Percent User Time: " & objItem.PercentUserTime
        Wscript.Echo "Pool Nonpaged Bytes: " & objItem.PoolNonpagedBytes
        Wscript.Echo "Pool Paged Bytes: " & objItem.PoolPagedBytes
        Wscript.Echo "Private Bytes: " & objItem.PrivateBytes
        Wscript.Echo "Protocol Bitmap Cache Hit Ratio: " & _
            objItem.ProtocolBitmapCacheHitRatio
        Wscript.Echo "Protocol Bitmap Cache Hits: " & _
            objItem.ProtocolBitmapCacheHits
        Wscript.Echo "Protocol Bitmap Cache Reads: " & _
            objItem.ProtocolBitmapCacheReads
        Wscript.Echo "Protocol Brush Cache Hit Ratio: " & _
            objItem.ProtocolBrushCacheHitRatio
        Wscript.Echo "Protocol Brush Cache Hits: " & _
            objItem.ProtocolBrushCacheHits
        Wscript.Echo "Protocol Brush Cache Reads: " & _
            objItem.ProtocolBrushCacheReads
        Wscript.Echo "Protocol Glyph Cache Hit Ratio: " & _
            objItem.ProtocolGlyphCacheHitRatio
        Wscript.Echo "Protocol Glyph Cache Hits: " & _
            objItem.ProtocolGlyphCacheHits
        Wscript.Echo "Protocol Glyph Cache Reads: " & _)
            objItem.ProtocolGlyphCacheReads
        Wscript.Echo "Protocol Save Screen Bitmap Cache Hit Ratio: " & _
            objItem.ProtocolSaveScreenBitmapCacheHitRatio
        Wscript.Echo "Protocol Save Screen Bitmap Cache Hits: " & _
            objItem.ProtocolSaveScreenBitmapCacheHits
        Wscript.Echo "Protocol Save Screen Bitmap Cache Reads: " & _
            objItem.ProtocolSaveScreenBitmapCacheReads
        Wscript.Echo "Thread Count: " & objItem.ThreadCount
        Wscript.Echo "Total Asynchronous Frame Error: " & _
            objItem.TotalAsyncFrameError
        Wscript.Echo "Total Asynchronous Overflow: " & _
            objItem.TotalAsyncOverflow
        Wscript.Echo "Total Asynchronous Overrun: " & objItem.TotalAsyncOverrun
        Wscript.Echo "Total Asynchronous Parity Error: " & _
            objItem.TotalAsyncParityError
        Wscript.Echo "Total Bytes: " & objItem.TotalBytes
        Wscript.Echo "Total Compressed Bytes: " & objItem.TotalCompressedBytes
        Wscript.Echo "Total Compress Flushes: " & objItem.TotalCompressFlushes
        Wscript.Echo "Total Compression Ratio: " & _
            objItem.TotalCompressionRatio
        Wscript.Echo "Total Errors: " & objItem.TotalErrors
        Wscript.Echo "Total Frames: " & objItem.TotalFrames
        Wscript.Echo "Total Protocol Cache Hit Ratio: " & _
            objItem.TotalProtocolCacheHitRatio
        Wscript.Echo "Total Protocol Cache Hits: " & _
            objItem.TotalProtocolCacheHits
        Wscript.Echo "Total Protocol Cache Reads: " & _
            objItem.TotalProtocolCacheReads
        Wscript.Echo "Total Timeouts: " & objItem.TotalTimeouts
        Wscript.Echo "Total Transport Errors: " & objItem.TotalTransportErrors
        Wscript.Echo "Total Wait For Output Buffer: " & _
            objItem.TotalWaitForOutBuf
        Wscript.Echo "Total Wd Bytes: " & objItem.TotalWdBytes
        Wscript.Echo "Total Wd Frames: " & objItem.TotalWdFrames
        Wscript.Echo "Virtual Bytes: " & objItem.VirtualBytes
        Wscript.Echo "Virtual Bytes Peak: " & objItem.VirtualBytesPeak
        Wscript.Echo "Working Set: " & objItem.WorkingSet
        Wscript.Echo "Working Set Peak: " & objItem.WorkingSetPeak
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Monitor Terminal Services Performance

Description
Uses cooked performance counters to monitor Terminal Services performance.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum(objWMIService, _
    "Win32_PerfFormattedData_TermService_TerminalServices").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Active Sessions: " & objItem.ActiveSessions
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Inactive Sessions: " & objItem.InactiveSessions
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Total Sessions: " & objItem.TotalSessions
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Accounts

Description
Returns information about all the Terminal Services accounts on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSAccount")

For Each objItem in colItems
    Wscript.Echo "Account name: " & objItem.AccountName
    Wscript.Echo "Audit failure: " & objItem.AuditFail
    Wscript.Echo "Audit success: " & objItem.AuditSuccess
    Wscript.Echo "Permissions allowed: " & objItem.PermissionsAllowed
    Wscript.Echo "Permissions denied: " & objItem.PermissionsDenied
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "SID: " & objItem.SID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Client Settings

Description
Returns information about the Terminal Service client settings and policies configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSClientSetting")

For Each objItem in colItems
    Wscript.Echo "Audio mapping: " & objItem.AudioMapping
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Clipboard mapping: " & objItem.ClipboardMapping
    Wscript.Echo "Color depth: " & objItem.ColorDepth
    Wscript.Echo "Color depth policy: " & objItem.ColorDepthPolicy
    Wscript.Echo "COM port mapping: " & objItem.COMPortMapping
    Wscript.Echo "Connect client drives at logon: " & _
        objItem.ConnectClientDrivesAtLogon
    Wscript.Echo "Connection policy: " & objItem.ConnectionPolicy
    Wscript.Echo "Connect printer at logon: " & objItem.ConnectPrinterAtLogon
    Wscript.Echo "Default to client printer: " & objItem.DefaultToClientPrinter
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Drive mapping: " & objItem.DriveMapping
    Wscript.Echo "LPT port mapping: " & objItem.LPTPortMapping
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo "Windows printer mapping: " & objItem.WindowsPrinterMapping
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Environment Properties for a User Account

Description
Returns Terminal Services environment properties for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

Wscript.Echo "Connect Client Drives At Logon: " & _
    objUser.ConnectClientDrivesAtLogon
Wscript.Echo "Connect Client Printers At Logon: " & _
    objUser.ConnectClientPrintersAtLogon
Wscript.Echo "Default To Main Printer: " & objUser.DefaultToMainPrinter
Wscript.Echo "Terminal Services Initial Program: " & _
    objUser.TerminalServicesInitialProgram
Wscript.Echo "Terminal Services Work Directory: " & _
    objUser.TerminalServicesWorkDirectory

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Environment Settings

Description
Returns information about the Terminal Service client environment settings configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
("Select * from Win32_TSEnvironmentSetting")

For Each objItem in colItems
    Wscript.Echo "Client wallpaper: " & objItem.ClientWallpaper
    Wscript.Echo "Initial program path: " & objItem.InitialProgramPath
    Wscript.Echo "Initial program policy: " & objItem.InitialProgramPolicy
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Start in: " & objItem.Startin
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services General Settings

Description
Returns general information about how Terminal Services has been configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSGeneralSetting")

For Each objItem in colItems
    Wscript.Echo "Comment: " & objItem.Comment
    Wscript.Echo "Minimum encryption level: " & objItem.MinEncryptionLevel
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo "Terminal protocol: " & objItem.TerminalProtocol
    Wscript.Echo "Transport: " & objItem.Transport
    Wscript.Echo "Windows authentication: " & objItem.WindowsAuthentication
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Logon Settings

Description
Returns information about the Terminal Service logon policies configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSLogonSetting")

For Each objItem in colItems
    Wscript.Echo "Client logon information policy: " & _
        objItem.ClientLogonInfoPolicy
    Wscript.Echo "Domain: " & objItem.Domain
    Wscript.Echo "Prompt for password: " & objItem.PromptForPassword
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo "User name: " & objItem.UserName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Network Adapter List Settings

Description
Lists the network adapters that can be configured for Terminal Services.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSNetworkAdapterListSetting")

For Each objItem in colItems
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Network Adapter ID: " & objItem.NetworkAdapterID
    Wscript.Echo "Network Adapter IP Address: " & objItem.NetworkAdapterIP
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Network Adapter Settings

Description
Lists Terminal Services network adapter settings, including the maximum number of connections allowed.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSNetworkAdapterSetting")

For Each objItem in colItems
    Wscript.Echo "Maximum Connections: " & objItem.MaximumConnections
    Wscript.Echo "Network Adapter ID: " & objItem.NetworkAdapterID
    Wscript.Echo "Network Adapter Name: " & objItem.NetworkAdapterName
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal Name: " & objItem.TerminalName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Permission Settings

Description
Lists Terminal Services permission settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSPermissionsSetting")

For Each objItem in colItems
  Wscript.Echo "Caption: " & objItem.Caption
  Wscript.Echo "Description: " & objItem.Description
  Wscript.Echo "Setting ID: " & objItem.SettingID
  Wscript.Echo "Terminal name: " & objItem.TerminalName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Profile Properties

Description
Returns Terminal Services profile information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.Echo "Terminal Services Profile Path : " & _
    objUser.TerminalServicesProfilePath
WScript.Echo "Terminal Services Home Directory: " & _
    objUser.TerminalServicesHomeDirectory
WScript.Echo "Terminal Services Home Drive: " & _
    objUser.TerminalServicesHomeDrive
WScript.Echo "Allow Logon: " & objUser.AllowLogon

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Remote Control Settings

Description
Returns information about Terminal Service remote control as configured on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSRemoteControlSetting")

For Each objItem in colItems
    Wscript.Echo "Level of control: " & objItem.LevelofControl
    Wscript.Echo "Remote control policy: " & objItem.RemoteControlPolicy
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Session Directory Settings

Description
Returns configuration information for all the Terminal Service session directories found on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSSessionDirectory")

For Each objItem in colItems
    Wscript.Echo "Session Directory active: " & objItem.SessionDirectoryActive
    Wscript.Echo "Session Directory cluster name: " & _
        objItem.SessionDirectoryClusterName
    Wscript.Echo "Session Directory expose server IP address: " & _
        objItem.SessionDirectoryExposeServerIP
    Wscript.Echo "Session Directory IP address: " & _
        objItem.SessionDirectoryIPAddress
    Wscript.Echo "Session Directory location: " & _
        objItem.SessionDirectoryLocation
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Session Settings

Description
Returns Terminal Service session configuration information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
    Wscript.Echo "Active session limit: " & objItem.ActiveSessionLimit
    Wscript.Echo "Broken connection action: " & objItem.BrokenConnectionAction
    Wscript.Echo "Broken connection policy: " & objItem.BrokenConnectionPolicy
    Wscript.Echo "Disconnected session limit: " & _
        objItem.DisconnectedSessionLimit
    Wscript.Echo "Idle session limit: " & objItem.IdleSessionLimit
    Wscript.Echo "Reconnection policy: " & objItem.ReconnectionPolicy
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo "Time limit policy: " & objItem.TimeLimitPolicy
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Terminal Settings

Description
Lists the Terminal Service configuration settings on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")

For Each objItem in colItems
    Wscript.Echo "Active Desktop: " & objItem.ActiveDesktop
    Wscript.Echo "Allow TS connections: " & objItem.AllowTSConnections
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Delete temporary folders: " & objItem.DeleteTempFolders
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "Direct connect license servers: " & _
        objItem.DirectConnectLicenseServers
    Wscript.Echo "Disable forcible logoff: " & objItem.DisableForcibleLogoff
    Wscript.Echo "Help: " & objItem.Help
    Wscript.Echo "Home directory: " & objItem.HomeDirectory
    Wscript.Echo "Licensing description: " & objItem.LicensingDescription
    Wscript.Echo "Licensing name: " & objItem.LicensingName
    Wscript.Echo "Licensing type: " & objItem.LicensingType
    Wscript.Echo "Logons: " & objItem.Logons
    Wscript.Echo "Profile path: " & objItem.ProfilePath
    Wscript.Echo "Server name: " & objItem.ServerName
    Wscript.Echo "Setting ID: " & objItem.SettingID
    Wscript.Echo "Single session: " & objItem.SingleSession
    Wscript.Echo "Terminal Server mode: " & objItem.TerminalServerMode
    Wscript.Echo "Time zone redirection: " & objItem.TimeZoneRedirection
    Wscript.Echo "User permission: " & objItem.UserPermission
    Wscript.Echo "Use temporary folders: " & objItem.UseTempFolders
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Terminals

Description
Returns configuration information for all the Terminal Service terminals on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TerminalSetting")

For Each objItem in colItems
  Wscript.Echo "Caption: " & objItem.Caption
  Wscript.Echo "Description: " & objItem.Description
  Wscript.Echo "Setting ID: " & objItem.SettingID
  Wscript.Echo "Terminal name: " & objItem.TerminalName
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Terminals

Description
Returns a list of all the Terminal Service terminals on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Terminal")

For Each objItem in colItems
    Wscript.Echo "Terminal name: " & objItem.TerminalName
    Wscript.Echo "Terminal enabled: " & objItem.fEnableTerminal
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Terminal Services Account

Description
Adds a new Terminal Service account for fabrikam\bob, giving this account guest access rights.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const GUEST_ACCESS = 0

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSPermissionsSetting")

For Each objItem in colItems
    errResult = objItem.AddAccount("fabrikam\bob", GUEST_ACCESS)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Clear Terminal Services Properties for a User Account

Description
Clears the Terminal Services userParameters attribute for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "userParameters", 0
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Terminal Services Account

Description
Deletes the Terminal Services account for fabrikam\bob. Note that in the WQL query you must separate the domain name (fabrikam) and the user name (bob) using two slashes rather than one. Thus the account fabrikam\kenmyer would be listed as fabrikam\\kenmyer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | Yes
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TSAccount Where AccountName = 'FABRIKAM\\bob'")

For Each objItem in colItems
    errResult = objItem.Delete()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Enable Remote Control Settings for a User Account

Description
Configures the EnableRemoteControl attribute for the MyerKen Active Directory user account. Other constant values are included in the script as a reference.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const Disable = 0
Const EnableInputNotify = 1
Const EnableInputNoNotify = 2
Const EnableNoInputNotify = 3
Const EnableNoInputNoNotify = 4

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
objUser.EnableRemoteControl = EnableNoInputNoNotify

objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Profile Properties

Description
Returns Terminal Services profile information for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.echo "Terminal Services Profile Path : " & _
    objUser.TerminalServicesProfilePath
WScript.echo "Terminal Services Home Directory: " & _
    objUser.TerminalServicesHomeDirectory
WScript.echo "Terminal Services Home Drive: " & _
    objUser.TerminalServicesHomeDrive
WScript.echo "Allow Logon: " & objUser.AllowLogon

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Properties for a User

Description
Retrieve a user's Terminal Services Profile settings.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = GetObject("LDAP://cn=youngrob,ou=r&d,dc=fabrikam,dc=com")

WScript.Echo objUser.Name & " Terminal Services Profile Settings"
WScript.Echo "--------------------------------------------------"

WScript.Echo "Allow Logon: " & objUser.AllowLogon
WScript.Echo "Terminal Services Home Directory: " & _
    objUser.TerminalServicesHomeDirectory
WScript.Echo "Terminal Services Home Drive: " & _
    objUser.TerminalServicesHomeDrive
WScript.Echo "Terminal Services Profile Path: " & _
    objUser.TerminalServicesProfilePath

WScript.Echo "Enable Remote Control: " & objUser.EnableRemoteControl

WScript.Echo "Broken Connection Action: " & objUser.BrokenConnectionAction
WScript.Echo "Max Connection Time: " & objUser.MaxConnectionTime
WScript.Echo "Max Disconnection Time: " & objUser.MaxDisconnectionTime
WScript.Echo "Max Idle Time: " & objUser.MaxIdleTime
WScript.Echo "Reconnection Action: " & objUser.ReconnectionAction

WScript.Echo "Connect Client Drives At Logon: " & _
    objUser.ConnectClientDrivesAtLogon
WScript.Echo "Connect Client Printers At Logon: " & _
    objUser.ConnectClientPrintersAtLogon
WScript.Echo "Default To Main Printer: " & _
    objUser.DefaultToMainPrinter
WScript.Echo "Terminal Services Initial Program: " & _
    objUser.TerminalServicesInitialProgram
WScript.Echo "Terminal Services Work Directory: " & _
    objUser.TerminalServicesWorkDirectory

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Remote Control Properties for a User Account

Description
Retrieves Terminal Services Remote Control attribute values for the MyerKen user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const Disable = 0
Const EnableInputNotify = 1
Const EnableInputNoNotify = 2
Const EnableNoInputNotify = 3
Const EnableNoInputNoNotify = 4

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

intEnableRemoteControl  = objUser.EnableRemoteControl

Select Case intEnableRemoteControl
    Case Disable  WScript.Echo "Remote control disabled"
    Case EnableInputNotify
        WScript.Echo "Remote control enabled"
        WScript.Echo "User permission required"
        WScript.Echo "Interact with the session"
    Case EnableInputNoNotify
        WScript.Echo "Remote control enabled"
        WScript.Echo "User permission not required"
        WScript.Echo "Interact with the session"
    Case EnableNoInputNotify
        WScript.Echo "Remote control enabled"
        WScript.Echo "User permission required"
        WScript.Echo "View the session"
    Case EnableNoInputNoNotify
        WScript.Echo "Remote control enabled"
        WScript.Echo "User permission not required"
        WScript.Echo "View the session"
End Select

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Terminal Services Session Properties

Description
Retrieves Terminal Services session properties for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

WScript.echo "Maximum Disconnection Time : " & objUser.MaxDisconnectionTime
WScript.echo "Maximum Connection Time: " & objUser.MaxConnectionTime
WScript.echo "Maximum Idle Time: " & objUser.MaxIdleTime
WScript.echo "Broken Connection Action: " & objUser.BrokenConnectionAction
WScript.echo "Reconnection Action : " & objUser.ReconnectionAction

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Environment Properties for a User Account

Description
Configures the Terminal Services environment properties for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const Enabled = 1
Const Disabled = 0

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.ConnectClientDrivesAtLogon = Enabled
objUser.ConnectClientPrintersAtLogon = Enabled
objUser.DefaultToMainPrinter = Enabled
objUser.TerminalServicesInitialProgram = "cmd"
objUser.TerminalServicesWorkDirectory = "c:\temp"
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Profile Properties for a User Account

Description
Configures Terminal Services profile attributes for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const Enabled = 1
Const Disabled = 0

Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.TerminalServicesProfilePath = ""
objUser.TerminalServicesHomeDirectory = ""
objUser.TerminalServicesHomeDrive = ""
objUser.AllowLogon = Enabled
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Terminal Services Session Properties for a User Account

Description
Configures Terminal Services session attributes for the MyerKen Active Directory user account.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Const Enabled = 1
Const Disabled = 0

Set objUser = GetObject _
  ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")

objUser.MaxDisconnectionTime = 2880
objUser.MaxConnectionTime = 1440
objUser.MaxIdleTime = 180
objUser.BrokenConnectionAction = Enabled
objUser.ReconnectionAction = Enabled
objUser.SetInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a DVD Drive to a Virtual Machine

Description
Adds a DVD drive to a Virtual Machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

errReturn = objVM.AddDVDROMDrive(0,1,0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Hard Disk Connection to a Virtual Machine

Description
Adds a hard disk connection to a Virtual Machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
Set objDrive = objVM.AddHardDiskConnection _
    ("c:\Virtual Machines\Windows 2000 Server Hard Disk.vhd",0,0,0)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a SCSI Controller to a Virtual Machine

Description
Adds a SCSI controller to a Virtual Machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.AddSCSIController()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Attach a DVD Host Drive to all Virtual Machines

Description
Adds a DVD drive to all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.AttachHostDrive("D")
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Attach a DVD Image to all Virtual Machines

Description
Attaches a DVD image to all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.AttachImage _
            ("C:\Virtual Machines\Images\VMAdditions013107.iso")
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Attach a Floppy Drive to All Virtual Machines

Description
Attaches a floppy drive to all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.AttachHostDrive("A")
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Attach a Floppy Image to All Virtual Machines

Description
Attaches a floppy image to all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.AttachImage _
            ("C:\Virtual Machines\Additions\Dos Virtual Machine Additions.vfd")
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Compact a Virtual Hard Disk

Description
Compacts all the virtual hard disks on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colHardDiskConnections = objVM.HardDiskConnections
    For Each objDrive in colHardDiskConnections
        Set objHardDisk = objDrive.HardDisk
        objHardDisk.Compact()
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Floppy Image

Description
Creates a new Virtual Server floppy image.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Const vmFloppyDiskImage_HighDensity = 2

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateFloppyDiskImage _
    ("C:\Virtual Machines\Images\\Test.vfd", vmFloppyDiskImage_HighDensity)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Virtual Server Dynamic Hard Disk

Description
Creates a new Virtual Server dynamic hard disk.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateDynamicVirtualHardDisk _
    ("C:\Virtual Machines\Disks\Scripted_HardDisk.vhd", 20)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Virtual Server Fixed Hard Disk

Description
Creates a new Virtual Server fixed hard disk.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateFixedVirtualHardDisk _
    ("C:\Virtual Machines\Disks\Fixed_HardDisk.vhd", 20)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Discard Virtual Server Undo Disks

Description
Discards the undo disks for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.DiscardUndoDisks()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine DVD Information

Description
Lists DVD information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Attachment: " & objDrive.Attachment
        Wscript.Echo "Bus number: " & objDrive.BusNumber
        Wscript.Echo "Bus type: " & objDrive.BusType
        Wscript.Echo "Device number: " & objDrive.DeviceNumber
        Wscript.Echo "Host drive letter: " & objDrive.HostDriveLetter
        Wscript.Echo "Image file: " & objDrive.ImageFile
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine Floppy Drive Information

Description
Lists floppy drive information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Attachment: " & objDrive.Attachment
        Wscript.Echo "Drive number: " & objDrive.DriveNumber
        Wscript.Echo "Host drive letter: " & objDrive.HostDriveLetter
        Wscript.Echo "Image file: " & objDrive.ImageFile
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine SCSI Controller Information

Description
Lists SCSI controller information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colSCSIControllers = objVM.SCSIControllers
    For Each objController in colSCSIControllers
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "ID: " & objController.ID
        Wscript.Echo "Is bus shared: " & objController.IsBusShared
        Wscript.Echo "SCSI ID: " & objController.SCSIID
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Floppy Image Type

Description
Lists the image type for a virtual server floppy image.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
strImageType = objVS.GetFloppyDiskImageType _
    ("C:\Virtual Machines\Images\Dos Virtual Machine Additions.vfd")
Wscript.Echo "Image type: " & strImageType

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Hard Disk Connection Information

Description
Lists hard disk connection information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colHardDiskConnections = objVM.HardDiskConnections
    For Each objDrive in colHardDiskConnections
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Bus number: " & objDrive.BusNumber
        Wscript.Echo "Bus type: " & objDrive.BusType
        Wscript.Echo "Device number: " & objDrive.DeviceNumber
        Set objHardDisk = objDrive.HardDisk
        Wscript.Echo "Hard disk file: " & objHardDisk.File
        Wscript.Echo "Host drive identifier: " & _
            objHardDisk.HostDriveIdentifier
        Wscript.Echo "Host free disk space: " & objHardDisk.HostFreeDiskSpace
        Wscript.Echo "Host volume identifier: " & _
            objHardDisk.HostVolumeIdentifier
        Wscript.Echo "Size in guest: " & objHardDisk.SizeInGuest
        Wscript.Echo "Size on host: " & objHardDisk.SizeOnHost
        Wscript.Echo "Type: " & objHardDisk.Type
        Set objUndoDrive = objDrive.UndoHardDisk
        Wscript.Echo "Hard disk file: " & objUndoDrive.File
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Hard Disk Information

Description
Lists the disk type for a Virtual Server hard disk.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objHardDisk = objVS.GetHardDisk _
    ("C:\Virtual Machines\Disks\Windows 2000 Server Hard Disk.vhd")
Wscript.Echo "Hard disk type: " & objHardDisk.Type

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Merge Virtual Machine Undo Disks

Description
Merges undo disks for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.MergeUndoDisks()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release a Virtual Machine DVD Image

Description
Release a DVD image for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colDVDDrives = objVM.DVDROMDrives
For Each objDrive in colDVDDrives
    errReturn = objDrive.ReleaseImage()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release a Virtual Machine Floppy Drive

Description
Release the floppy drives for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.ReleaseHostDrive()
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release a Virtual Machine Floppy Image

Description
Release the floppy images for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.ReleaseImage()
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Release a Virtual Machine Host Drive

Description
Release the host drives for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.ReleaseHostDrive
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove a Virtual Machine DVD Drive

Description
Removes all the DVD drives for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colDVDDrives = objVM.DVDROMDrives
For Each objDrive in colDVDDrives
    errReturn = objVM.RemoveDVDROMDrive(objDrive)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove a Virtual Machine SCSI Controller

Description
Removes all the SCSI controllers for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
Set colControllers = objVM.SCSIControllers

For Each objController in colControllers
    objVM.RemoveSCSIController(objController)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Remove a Virual Server Hard Disk Connection

Description
Removes all the hard disk connections for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colConnections = objVM.HardDiskConnections
For Each objConnection in colConnections
    objVM.RemoveHardDiskConnection(objConnection)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Virtual Machine

Description
Creates a virtual machine named Script Machine.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateVirtualMachine("Scripted Machine", _
    "C:\Scripts\Shared Virtual Machines\Scripted")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Virtual Machine

Description
Deletes a virtual machine named Scripted Machine.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Scripted Machine")

errReturn = objVS.DeleteVirtualMachine(objVM)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Discard the Saved State of a Virtual Machine

Description
Discards the saved state of a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

errReturn = objVM.DiscardSavedState()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Install Virtual Machine Additions

Description
Installs Virtual Machine Additions for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objGuestOS = objVM.GuestOS
objGuestOS.InstallAdditions()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Guest Operating System Information for a Virtual Machine

Description
Lists the Guest operating system information for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objGuestOS = objVM.GuestOS
Wscript.Echo "Additions version: " &  objGuestOS.AdditionsVersion
Wscript.Echo "Can shut down: " &  objGuestOS.CanShutdown
Wscript.Echo "Heartbeat percentage: " &  objGuestOS.HeartbeatPercentage
Wscript.Echo "Is heart beating: " &  objGuestOS.IsHeartbeating
Wscript.Echo "Is host time synchronization enabled: " & _
    objGuestOS.IsHostTimeSyncEnabled
Wscript.Echo "OS name: " &  objGuestOS.OSName

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Basic Virtual Machine Information

Description
Lists configuration information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Wscript.Echo "Account name: " & objVM.accountname
    Wscript.Echo "Account name and password: " & objVM.Accountnameandpassword
    Wscript.Echo "Autostart at launch: " & objVM.Autostartatlaunch
    Wscript.Echo "Autostart at launch delay: " & objVM.Autostartatlaunchdelay
    Wscript.Echo "Baseboard serial number: " & objVM.Baseboardserialnumber
    Wscript.Echo "BIOS GUID: " & objVM.BIOSGUID
    Wscript.Echo "BIOS serial number: " & objVM.BIOSerialNumber
    Wscript.Echo "Chassis asset tag: " & objVM.ChassisAssetTag
    Wscript.Echo "Chassis serial number: " & objVM.ChassisSerialNumber
    Wscript.Echo "Config ID: " & objVM.ConfigID
    Wscript.Echo "Display: " & objVM.Display
    Wscript.Echo "File: " & objVM.File
    Wscript.Echo "Floppy autodetect enabled: " & objVM.FloppyAutoDetectEnabled
    Wscript.Echo "Gues OS: " & objVM.GuestOS
    Wscript.Echo "Has MMX: " & objVM.HasMMX
    Wscript.Echo "Has SSE: " & objVM.HasSSE
    Wscript.Echo "Has SSE2: " & objVM.HasSSE2
    Wscript.Echo "Keyboard: " & objVM.Keyboard
    Wscript.Echo "Memory: " & objVM.Memory
    Wscript.Echo "Mouse: " & objVM.Mouse
    Wscript.Echo "Name: " & objVM.Name
    Wscript.Echo "Notes: " & objVM.Notes
    Wscript.Echo "Processor speed: " & objVM.ProcessorSpeed
    Wscript.Echo "Run as defined account: " & objVM.RunAsDefinedAccount
    Wscript.Echo "Saved state file path: " & objVM.SavedStateFilePath
    Wscript.Echo "Shutdown action on quit: " & objVM.ShutdownActionOnQuit
    Wscript.Echo "State: " & objVM.State
    Wscript.Echo "Undoable: " & objVM.Undoable
    Wscript.Echo "Undo action: " & objVM.UndoAction
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine Keyboard Information

Description
Lists keyboard information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set objKeyboard = objVM.Keyboard
    Wscript.Echo objVM.Name
    Wscript.Echo "Has exclusive access: " & objKeyboard.HasExclusiveAccess
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine Mouse Information

Description
Lists mouse information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set objMouse = objVM.Mouse
    Wscript.Echo objVM.Name
    Wscript.Echo "Horizontal position: " & objMouse.HorizontalPosition
    Wscript.Echo "Scroll wheel position: " & objMouse.ScrollWheelPosition
    Wscript.Echo "Using absolute coordinates position: " & _
        objMouse.UsingAbsoluteCoordinatesPosition
    Wscript.Echo "Vertical position: " & objMouse.VerticalPosition
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine Parallel Port Information

Description
Lists parallel port information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colPorts = objVM.ParallelPorts
    For Each objPort in colPorts
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Name: " & objPort.Name
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Machine Serial Port Information

Description
Lists serial port information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colPorts = objVM.SerialPorts
    For Each objPort in colPorts
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Connect immediately: " & objPort.ConnectImmediately
        Wscript.Echo "Name: " & objPort.Name
        Wscript.Echo "Type: " & objPort.Type
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Accountant Information

Description
Lists accountant information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colAccountants = objVM.Accountant
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Allowable maximum system capacity: " & _
            colAccountants.AllowableMaximumSystemCapacity
        Wscript.Echo "Allowable reserved system capacity: " & _
            colAccountants.AllowableReservedSystemCapacity
        Wscript.Echo "CPU utilization: " & colAccountants.CPUUtilization

        i = 1
        Wscript.Echo "CPU utilization history:"
        For Each intCPUUtilization in colAccountants.CPUUtilizationHistory
            Wscript.Echo vbTab & i & " -- " & intCPUUtilization
            i = i + 1
        Next

        Wscript.Echo "Disk bytes read: " & colAccountants.DiskBytesRead
        Wscript.Echo "Disk bytes written: " & colAccountants.DiskBytesWritten
        Wscript.Echo "Host disk utilization: " & _
            colAccountants.HostDiskUtilization
        Wscript.Echo "Host memory utilization: " & _
            colAccountants.HostMemoryUtilization
        Wscript.Echo "Maximum system capacity: " & _
            colAccountants.MaximumSystemCapacity
        Wscript.Echo "Network bytes received: " & _
            colAccountants.NetworkBytesReceived
        Wscript.Echo "Network bytes sent: " & colAccountants.NetworkBytesSent
        Wscript.Echo "Relative weight: " & colAccountants.RelativeWeight
        Wscript.Echo "Reserved system capacity: " & _
            colAccountants.ReservedSystemCapacity
        Wscript.Echo "Uptime: " & colAccountants.Uptime
        Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Display Information

Description
Lists display information for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set objDisplay = objVM.Display
    Wscript.Echo objVM.Name
    Wscript.Echo "Height: " & objDisplay.Height
    Wscript.Echo "Video mode: " & objDisplay.VideoMode
    Wscript.Echo "Width: " & objDisplay.Width
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Host Information

Description
Lists Virtual Server host computer information.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objHost = objVS.HostInfo

Wscript.Echo "Logical processor count: " & objHost.LogicalProcessorCount
Wscript.Echo "Memory: " & objHost.Memory
Wscript.Echo "Memory available: " & objHost.MemoryAvail
Wscript.Echo "Memory available string: " & objHost.MemoryAvailString
Wscript.Echo "Memory total string: " & objHost.MemoryTotalString
Wscript.Echo "MMX: " & objHost.MMX
Wscript.Echo "Operating system: " & objHost.OperatingSystem
Wscript.Echo "OS major version: " & objHost.OSMajorVersion
Wscript.Echo "OS minor version: " & objHost.OSMinorVersion
Wscript.Echo "OS service pack string: " & objHost.OSServicePackString
Wscript.Echo "OS version string: " & objHost.OSVersionString
Wscript.Echo "Parallel port: " & objHost.ParallelPort
Wscript.Echo "Physical processor count: " & objHost.PhysicalProcessorCount
Wscript.Echo "Processor features string: " & objHost.ProcessorFeaturesString
Wscript.Echo "Processor manufacturer string: " & _
    objHost.ProcessorManufacturerString
Wscript.Echo "Processor speed: " & objHost.ProcessorSpeed
Wscript.Echo "Processor speed string: " & objHost.ProcessorSpeedString
Wscript.Echo "Processor version string: " & objHost.ProcessorVersionString
Wscript.Echo "SSE: " & objHost.SSE
Wscript.Echo "SSE2: " & objHost.SSE2
Wscript.Echo "3DNow!: " & objHost.ThreeDNow
Wscript.Echo "UTC time: " & objHost.UTCTime

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Properties

Description
Lists configuration settings for Virtual Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")

Wscript.Echo "Available system capacity: " & objVS.AvailableSystemCapacity
Wscript.Echo "Default additions path: " & objVS.DefaultAdditionsPath
Wscript.Echo "Default VM configuration path: " & _
    objVS.DefaultVMConfigurationPath
Wscript.Echo "Default VN configuration path: " & _
    objVS.DefaultVNConfigurationPath
Wscript.Echo "Disk image search paths: " & objVS.DiskImageSearchPaths
Wscript.Echo "Existing configuration paths: " & _
    objVS.ExistingConfigurationPaths
Wscript.Echo "Maximum floppy drives per VM: " & objVS.MaximumFloppyDrivesPerVM
Wscript.Echo "Maximum memory per VM: " & objVS.MaximumMemoryPerVM
Wscript.Echo "Maximum network adapters per VM: " & _
    objVS.MaximumNetworkAdaptersPerVM
Wscript.Echo "Maximum number of IDE buses: " & objVS.MaximumNumberOfIDEBuses
Wscript.Echo "Maximum nmber of SCSI controllers: " & _
    objVS.MaximumNumberOfSCSIControllers
Wscript.Echo "Maximum parallel ports per VM: " & _
    objVS.MaximumParallelPortsPerVM
Wscript.Echo "Maximum serial ports per VM: " & objVS.MaximumSerialPortsPerVM
Wscript.Echo "Minimum memory per VM: " & objVS.MinimumMemoryPerVM
Wscript.Echo "Name: " & objVS.Name
Wscript.Echo "Product ID: " & objVS.ProductID
Wscript.Echo "Script search paths: " & objVS.ScriptSearchPaths
Wscript.Echo "Suggested maximum memory per VM: " & _
    objVS.SuggestedMaximumMemoryPerVM
Wscript.Echo "Uptime: " & objVS.Uptime
Wscript.Echo "Version: " & objVS.Version
Wscript.Echo "VMRC admin address: " & objVS.VMRCAdminAddress
Wscript.Echo "VMRC admin port number: " & objVS.VMRCAdminPortNumber
Wscript.Echo "VMRC authenticator: " & objVS.VMRCAuthenticator
Wscript.Echo "VMRC enabled: " & objVS.VMRCEnabled
Wscript.Echo "VMRC encryption certificate: " & objVS.VMRCEncryptionCertificate
Wscript.Echo "VMRC encryption certificate request: " & _
    objVS.VMRCEncryptionCertificateRequest
Wscript.Echo "VMRC encryption enabled: " & objVS.VMRCEncryptionEnabled
Wscript.Echo "VMRC idle connection timeout: " & objVS.VMRCIdleConnectionTimeout
Wscript.Echo "VMRC idle connection timeout enabled: " & _
    objVS.VMRCIdleConnectionTimeoutEnabled
Wscript.Echo "VMRC X-Resolution: " & objVS.VMRCXResolution
Wscript.Echo "VMRC Y-Resolution: " & objVS.VMRCYResolution

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Security Information

Description
Lists security information for Virtual Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objSecurity = objVS.Security

Wscript.Echo "Group name: " & objSecurity.GroupName
Wscript.Echo "Group SID: " & objSecurity.GroupSID
Wscript.Echo "Owner name: " & objSecurity.OwnerName
Wscript.Echo "Owner name: " & objSecurity.OwnerSID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Support Driver Information

Description
Lists information about support drives for Virtual Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colDrivers = objVS.SupportDrivers

For Each objDriver in colDrivers
    Wscript.Echo "Date: " & objDriver.Date
    Wscript.Echo "Description: " & objDriver.Description
    Wscript.Echo "Manufacturer: " & objDriver.Manufacturer
    Wscript.Echo "Provider: " & objDriver.Provider
    Wscript.Echo "Type: " & objDriver.Type
    Wscript.Echo "Version: " & objDriver.Version
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Tasks

Description
Lists all current Virtual Server tasks.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colTasks = objVS.Tasks

For Each objTask in colTasks
     Wscript.Echo "Description: " & objTask.Description
     Wscript.Echo "ID: " & objTask.ID
     Wscript.Echo "Is cancellable: " & objTask.IsCancelable
     Wscript.Echo "Is complete: " & objTask.IsComplete
     Wscript.Echo "Percent completed: " & objTask.PercentCompleted
     Wscript.Echo "Result: " & objTask.Result
     Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Virtual Machine Property

Description
Modifies the Notes property for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

objVM.Notes = "This is a Windows 2000 virtual machine."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Virtual Machine Scheduling Parameters

Description
Modifies the scheduling parameters for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objAccountant = objVM.Accountant
errReturn = objAccountant.SetSchedulingParameters(99,99,99)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Virtual Server Display Dimensions

Description
Modifies the display dimensions for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objDisplay = objVM.Display
errReturn = objDisplay.SetDimensions(800,600)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Pause a Virtual Machine

Description
Pauses a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.Pause()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Register a Virtual Machine

Description
Registers a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.RegisterVirtualMachine("Windows 2000 Server", _
    "C:\Virtual Machines")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Resume a Virtual Machine

Description
Resumes a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.Resume()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Return Virtual Machine Mouse Button Status

Description
Returns mouse button status for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objMouse = objVM.Mouse
errReturn = objMouse.GetButton(1)
Wscript.Echo errReturn

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Save the Virtual Machine State

Description
Saves a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

errReturn = objVM.Save()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a Virtual Machine

Description
Locates a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Wscript.Echo "File: " & objVM.File

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Shut Down the Guest Operating System on a Virtual Machine

Description
Shuts down a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objGuestOS = objVM.GuestOS
objGuestOS.Shutdown()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Start a Virtual Machine

Description
Starts a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

objVM.Startup()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Turn Off a Virtual Machine

Description
Turns off a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

objVM.Turnoff()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unregister a Virtual Machine

Description
Unregisters a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
errReturn = objVS.UnregisterVirtualMachine(objVM)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Add a Network Adapter to a Virtual Machines

Description
Adds a network adapter to a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.AddNetworkAdapter()

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Attach a Virtual Network to a Virtual Network Adapter

Description
Attaches a virtual network named Internal Network to a network adapter on a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objNetwork = objVS.FindVirtualNetwork("Internal Network")

Set colNetworkAdapters = objVM.NetworkAdapters
For Each objNetworkAdapter in colNetworkAdapters
    errReturn = objNetworkAdapter.AttachToVirtualNetwork(objNetwork)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Create a Virtual Network

Description
Create a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateVirtualNetwork _
    ("Scripted Network","C:\Virtual Machines")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete a Virtual Network

Description
Deletes a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Scripted Network")
errReturn = objVS.DeleteVirtualNetwork(objNetwork)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Delete All Virtual Machine Network Adapters

Description
Deletes all the network adapters for a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
Set colNetworkAdapters = objVM.NetworkAdapters
For Each objAdapter in colNetworkAdapters
    objVM.RemoveNetworkAdapter(objAdapter)
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Detach a Network Adapter from a Virtual Machine

Description
Detaches all the network adapters found on a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colNetworkAdapters = objVM.NetworkAdapters
For Each objNetworkAdapter in colNetworkAdapters
    errReturn = objNetworkAdapter.DetachFromVirtualNetwork()
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List All Virtual Networks

Description
Lists all the virtual networks on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set colNetworks = objVS.VirtualNetworks

For Each objNetwork in colNetworks
    Wscript.Echo "Bytes dropped: " & objNetwork.BytesDropped
    Wscript.Echo "Bytes received: " & objNetwork.BytesReceived
    Wscript.Echo "Bytes sent: " & objNetwork.BytesSent
    Wscript.Echo "File: " & objNetwork.File
    Wscript.Echo "Host adapter: " & objNetwork.HostAdapter
    Wscript.Echo "Name: " & objNetwork.Name
    Wscript.Echo "Notes: " & objNetwork.Notes
    Wscript.Echo "Packets dropped: " & objNetwork.PacketsDropped
    Wscript.Echo "Packets received: " & objNetwork.PacketsReceived
    Wscript.Echo "Packets sent: " & objNetwork.PacketsSent
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Network Adapter Information for All Virtual Machines

Description
Lists network adapters for all the virtual machines on a computer.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colNetworkAdapters = objVM.NetworkAdapters
    For Each objAdapter in colNetworkAdapters
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Network adapter ID: " & objAdapter.ID
        Wscript.Echo "Ethernet address: " & objAdapter.EthernetAddress
        Wscript.Echo "Is ethernet address dynamic: " & _
            objAdapter.IsEthernetAddressDynamic
        Wscript.Echo "Virtual machine: " & objAdapter.VirtualMachine
        Wscript.Echo "Virtual network: " & objAdapter.VirtualNetwork
        Wscript.Echo
    Next
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual DHCP Server Information

Description
Lists Virtual DHCP Server information for a network named Internal Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Internal Network")

Set objDHCPServer = objNetwork.DHCPVirtualNetworkServer
Wscript.Echo "Default gateway address: " & objDHCPServer.DefaultGatewayAddress
Wscript.Echo "DNS servers: " & objDHCPServer.DNSServers
Wscript.Echo "Ending IP address: " & objDHCPServer.EndingIPAddress
Wscript.Echo "Is enabled: " & objDHCPServer.IsEnabled
Wscript.Echo "Lease rebinding time: " & objDHCPServer.LeaseRebindingTime
Wscript.Echo "Lease renewal time: " & objDHCPServer.LeaseRenewalTime
Wscript.Echo "Lease time: " & objDHCPServer.LeaseTime
Wscript.Echo "Network: " & objDHCPServer.Network
Wscript.Echo "Network mask: " & objDHCPServer.NetworkMask
Wscript.Echo "Server IP address: " & objDHCPServer.ServerIPAddress
Wscript.Echo "Starting IP address: " & objDHCPServer.StartingIPAddress
Wscript.Echo "WINS Server: " & objDHCPServer.WINSServers

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify a Virtual Network Property

Description
Modifies the Notes property for a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Scripted Network")

objNetwork.Notes = "This note was added via a script."

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Modify Virtual Server DHCP Lease Times

Description
Modifies the DHCP lease times for a virtual network named Internal Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Internal Network")

Set objDHCPServer = objNetwork.DHCPVirtualNetworkServer
errReturn = objDHCPServer.ConfigureDHCPLeaseTimes(129630,64830,97230)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Register a Virtual Network

Description
Registers a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.RegisterVirtualNetwork _
    ("Scripted Network","C:\Virtual Machines")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a Virtual Network

Description
Locates a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Scripted Network")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Unregister a Virtual Network

Description
Unregisters a virtual network named Scripted Network.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objNetwork = objVS.FindVirtualNetwork("Scripted Network")
errReturn = objVS.UnregisterVirtualNetwork(objNetwork)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Current User Virtual Server Access Rights

Description
Lists Virtual Server access rights for the logged-on user.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objSecurity = objVS.Security
Set objAccessRights = objSecurity.CurrentUserAccessRights

Wscript.Echo "Change permissions: " & objAccessRights.ChangePermissions
Wscript.Echo "Delete access: " & objAccessRights.DeleteAccess
Wscript.Echo "Execute access: " & objAccessRights.ExecuteAccess
Wscript.Echo "Flags: " & objAccessRights.Flags
Wscript.Echo "Name: " & objAccessRights.Name
Wscript.Echo "Read access: " & objAccessRights.ReadAccess
Wscript.Echo "Read permissions: " & objAccessRights.ReadPermissions
Wscript.Echo "SID: " & objAccessRights.SID
Wscript.Echo "Special access: " & objAccessRights.SpecialAccess
Wscript.Echo "Type: " & objAccessRights.Type
Wscript.Echo "Write access: " & objAccessRights.WriteAccess

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Access Rights

Description
Lists Virtual Server access rights.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objSecurity = objVS.Security
Set colAccessRights = objSecurity.AccessRights

For Each objAccessRight in colAccessRights
    Wscript.Echo "Change permissions: " & objAccessRight.ChangePermissions
    Wscript.Echo "Delete access: " & objAccessRight.DeleteAccess
    Wscript.Echo "Execute access: " & objAccessRight.ExecuteAccess
    Wscript.Echo "Flags: " & objAccessRight.Flags
    Wscript.Echo "Name: " & objAccessRight.Name
    Wscript.Echo "Read access: " & objAccessRight.ReadAccess
    Wscript.Echo "Read permissions: " & objAccessRight.ReadPermissions
    Wscript.Echo "SID: " & objAccessRight.SID
    Wscript.Echo "Special access: " & objAccessRight.SpecialAccess
    Wscript.Echo "Type: " & objAccessRight.Type
    Wscript.Echo "Write access: " & objAccessRight.WriteAccess
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for a Virtual Server Security Entry

Description
Locates the security entry for a Virtual Server user named bob on a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objSecurity = objVM.Security
Set objEntry = objSecurity.FindEntry("bob",0)

Wscript.Echo objEntry.Name
Wscript.Echo objEntry.SID

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Search for Virtual Server Access Rights

Description
Locates Virtual Server access rights for the Administrators group.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objSecurity = objVS.Security

Set objAccessRights = objSecurity.FindEntry("Administrators",0)
Wscript.Echo objAccessRights.Name

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Click a Mouse Button in a Virtual Machine

Description
Clicks a mouse button inside a virtual machine named Windows 2000.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objMouse = objVM.Mouse
errReturn = objMouse.Click(2)

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Click a Mouse Button in a Virtual Machine

Description
Clicks the left mouse button in a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objMouse = objVM.Mouse
errReturn = objMouse.SetButton(1, TRUE)
Wscript.Echo errReturn

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Display the Client Control About Box

Description
Displays the About Box for the Virtual Server client control.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objClientControl = CreateObject("MSVMRCActiveXClient.VMRCClientControl")
objClientControl.AboutBox

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Client Control Connection Information

Description
Lists connection information for the Virtual Server client control.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

Set objClientControl = CreateObject("MSVMRCActiveXClient.VMRCClientControl")
objClientControl.ShowConnectionInfo

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server Client Control Properties

Description
Lists Virtual Server client control properties.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objClientControl = CreateObject("MSVMRCActiveXClient.VMRCClientControl")
Wscript.Echo "Administrator mode: " & objClientControl.AdministratorMode
Wscript.Echo "Autosize: " & objClientControl.AutoSize
Wscript.Echo "Enabled: " & objClientControl.Enabled
Wscript.Echo "Host key: " & objClientControl.HostKey
Wscript.Echo "Menu back color: " & objClientControl.MenuBackColor
Wscript.Echo "Menu enabled: " & objClientControl.MenuEnabled
Wscript.Echo "Menu font color: " & objClientControl.MenuFontColor
Wscript.Echo "Menu font size: " & objClientControl.MenuFontSize
Wscript.Echo "Menu height: " & objClientControl.MenuHeight
Wscript.Echo "Ready state: " & objClientControl.ReadyState
Wscript.Echo "Reduced-colors mode: " & objClientControl.ReducedColorsMode
Wscript.Echo "Server address: " & objClientControl.ServerAddress
Wscript.Echo "Server display height: " & objClientControl.ServerDisplayHeight
Wscript.Echo "Server display name: " & objClientControl.ServerDisplayName
Wscript.Echo "Server display width: " & objClientControl.ServerDisplayWidth
Wscript.Echo "Server port: " & objClientControl.ServerPort
Wscript.Echo "State: " & objClientControl.State
Wscript.Echo "View-only mode: " & objClientControl.ViewOnlyMode

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


List Virtual Server VMRC Authenticators

Description
Lists Virtual Server VMRC authenticators.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set colAuthenticators = objVS.VMRCAuthenticators
For Each objAuthenticator in colAuthenticators
    Wscript.Echo "Name: " & objAuthenticator.Name
    Wscript.Echo "Description: " & objAuthenticator.Description
    Wscript.Echo "Type: " & objAuthenticator.Type
    Wscript.Echo
Next

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Press a Key in a Virtual Machine

Description
Presses the left CTRL and the Escape key within a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objKeyboard = objVM.Keyboard
errReturn = objKeyboard.PressKey("Key_LeftCtrl")
errReturn = objKeyboard.PressKey("Key_Escape")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.


Type ASCII Text in a Virtual Machine

Description
Types the string "Test string." within a virtual machine named Windows 2000 Server.

Supported Platforms

Windows Server 2003 | Yes
Windows XP | No
Windows 2000 | No
Windows NT 4.0 | No
Windows 98 | No

Script Code

On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set objKeyboard = objVM.Keyboard
errReturn = objKeyboard.TypeASCIIText("Test string.")

For online peer support, join the microsoft.public.windows.server.scripting community on the msnews.microsoft.com news server. To provide feedback or report bugs in sample scripts or the Scripting Guide, please contact Microsoft TechNet.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.