Tải bản đầy đủ (.pdf) (1,109 trang)

Addison wesley managing windows with VBScript and WMI apr 2004 ISBN 0321213343

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.88 MB, 1,109 trang )






TableofContents
Examples

ManagingWindows®withVBScriptand
WMI
ByDonJones

Publisher :AddisonWesley
PubDate :March26,2004
ISBN :0-321-21334-3
Pages :640
Slots :1.0


"Finally,astep-by-stepVBScriptingbookto
makeyoulooklikeaprogrammerwithoutthe
timeandsweat!Don'twasteyourtime
searchingtheInternetforexamples-thisbook
doesitforyou!"
-GregA.Marino,SeniorSystems
Engineer/Consultant,WesttownConsulting
Group,Inc.
VisualBasicScripting(VBScript)and
WindowsManagementInstrumentation



(WMI)arevitaltoolsforsystems
administratorsgrapplingwiththeincreasing
complexityofWindowstechnologies.
However,busyadminshavebeenwithouta
straightforwardguidetoscripting...untilnow.
ManagingWindows(R)withVBScriptandWMI
explainshowWindowsadministratorscan
effectivelyuseVBScripttoautomatecommon
administrativetasksandsimplifycomplex
ones.Detailedcoverageofsecurityconcerns
providesadminswiththemeansforsafely
usingVBScriptinWindowsenvironments.The
bookisorganizedaroundtheproblemsyou
facedaily,withreusableexamplesand
coverageofWindowsNT,Windows2000,
WindowsXP,andWindows2003.
Thisuser-friendlyreferencedemystifies
scriptingandthenshowsyouhowtoproduce
newscriptsfromscratch.Youwillbe
producingusefulscriptsrightawayasyou
studytheVBScriptlanguageandlearnhowto
controlnearlyeveryaspectoftheWindows
operatingsystemwithWMIandtheActive
DirectoryServicesInterface(ASDI).Youwill
beabletobuildyourownadministrativeWeb


pagesanduseadvancedscripting
technologiessuchasscriptencryption,
scriptingcomponents,andscriptsecurity.The

bookcloseswithstillmoreready-made
examplescriptsaccompaniedbycomplete
line-by-lineexplanations.TheCDincludesall
thecodefromthebookandtrialversionsof
PrimalScript3.0andVbsEdit.Acompanion
Websiteprovidesupdatesanderrata.
Insideyouwillfindanswerstosuchquestions
as:
Howdoyouwriteeffectivelogonscripts?
Chapter11
Howdoyouwritescriptsthatqueryand
modifyuserandgroupinformation?
Chapter16
HowcanyouquerytheIPaddressesfrom
multiplenetworkadaptersinmultiple
remotecomputers?Chapter19
Howcanyoudesign,write,run,test,and
debugyourownadministrativeWeb
pages?Chapter24


Howcanyoureusecodebetweenvarious
scripts?Chapter25








TableofContents
Examples

ManagingWindows®withVBScriptand
WMI
ByDonJones

Publisher :AddisonWesley
PubDate :March26,2004
ISBN :0-321-21334-3
Pages :640
Slots :1.0



Copyright

PraiseforManagingWindows®withVBScriptandWMI

Preface
WhoShouldReadThisBook?

HowtoUseThisBook




PreparingtoUseThisBook
TypographicalElements



Acknowledgments

AbouttheAuthor

PartI:IntroductiontoWindowsAdministrativeScripting
Chapter1.ScriptingConceptsandTerminology

WhatIsScripting?




ScriptHosts




TheComponentObjectModel(COM)



Review



ActiveXScriptingLanguages
CriticalScriptingSecurityIssues

Chapter2.RunningScripts





WindowsScriptHost




Command-LineScripts




WritingYourFirstScript




DebuggingYourFirstScript




NotepadandScriptEditors
RunningYourFirstScript
Review
Chapter3.TheComponentsofaScript
ATypicalVBScript





Functions




MainScript



Review




Subroutines
CommentsandDocumentation

Chapter4.DesigningaScript
CreatingaTaskList




SelectingtheAppropriateTools





ValidatingUserInput




CreatingScriptLibraries

CreatingModulestoPerformTasks
PlanningforErrors
Review


PartII:VBScriptTutorial
Chapter5.Functions,Objects,Variables,andMore

WhatAreVariables?




WhatAreFunctions?




WhatAreObjects?





WhatAreStatementsandSubroutines?
Review
Chapter6.InputandOutput
DisplayingMessages




AskingforInput



Review






Command-LineParametersasInput

Chapter7.ManipulatingNumbers
NumbersinVBScript
BasicArithmetic
AdvancedArithmetic





BooleanMath




ConvertingNumericDataTypes



Review




ConvertingOtherDataTypestoNumericData

Chapter8.ManipulatingStrings
StringsinVBScript




WorkingwithSubstrings




ChangingStrings





ConvertingOtherDataTypestoStringData




Chapter9.ManipulatingOtherTypesofData

ConcatenatingStrings
FormattingStrings
Review

WorkingwithDatesandTimes




WorkingwithArrays



Review




WorkingwithBytes

Chapter10.ControllingtheFlowofExecution

ConditionalExecution




Loops



Review




PuttingItAllTogether

Chapter11.Built-inScriptingObjects
TheWScriptObject



TheNetworkObject




TheShellObject




Review




TheShortcutObject

Chapter12.WorkingwiththeFileSystem
TheFileSystemObjectLibrary




WorkingwithDrives




WorkingwithFiles




OtherFSOMethodsandProperties



Review

WorkingwithFolders

ReadingandWritingTextFiles
CreatingaLogFileScanner

Chapter13.PuttingItAllTogether:YourFirstScript





DesigningtheScript




WritingFunctionsandSubroutines




TestingtheScript

WritingtheMainScript
Review

PartIII:WindowsManagementInstrumentationandActiveDirectory
ServicesInterface
Chapter14.WorkingwithADSIProviders

UsingADSIObjects







UsingtheWinNTProvider




OtherProviders




UsingtheLDAPProvider
Review
Chapter15.ManipulatingDomains
QueryingDomainInformation




ChangingDomainSettings




PuttingItAllTogether





WorkingwithOUs
Review
Chapter16.ManipulatingUsersandGroups
CreatingUsersandGroups




QueryingUserInformation




WorkingwithGroups



Review

ChangingUserSettings
PuttingItAllTogether




Chapter17.UnderstandingWMI





ExploringWMI'sCapabilities




UsingtheWMITools



Review





TheWMIHierarchy
InstallingWMI
ReallyIt'sThisEasy

Chapter18.QueryingBasicWMIInformation
TheWMIQueryLanguage(WQL)
DeterminingWhattoQuery
TestingtheQuery






WritingtheQueryinVBScript



UsingtheQueryResults




AlternativeMethods




Review
Chapter19.QueryingComplexWMIInformation
UnderstandingWMIRelationships




AssociatingWMIInstances




TestingtheQuery





AnotherExample




WritingtheQuery
WritingtheQueryinVBScript
Review
Chapter20.PuttingItAllTogether:YourFirstWMI/ADSIScript
DesigningtheScript




WritingFunctionsandSubroutines




TestingtheScript

WritingtheMainScript
Review


PartIV:CreatingAdministrativeWebPages
Chapter21.ActiveServerPagesCrashCourse


AboutASP




VBScriptinASP




TheRequestObject




TestingASPScripts




TheResponseObject
ASampleASPScript
Review
Chapter22.AddingAdministrativeScripttoaWebPage
TheBasicWebPage




AddingFunctionsandSubroutines





TheResult



AddingInlineScript
Review
Chapter23.WebPageSecurityOverview
TheASPSecurityContext





ProhibitedBehaviors



IIS4.0,5.0,and5.1versusIIS6.0



NTFSandIISSecurity



WritingSecureASPCode




Review






Chapter24.PuttingItAllTogether:YourFirstAdministrativeWebPages
CheckingUserAccountStatus
AdministeringIIS
Review


PartV:AdvancedScriptingTechniques
Chapter25.ModularScriptProgramming

IntroductiontoWindowsScriptComponents






ScriptingandXML
Review
Chapter26.UsingScriptComponents
ObtainingtheComponent





ReviewingtheComponent



Review




UsingtheComponent

Chapter27.EncodedScripts
InstallingtheScriptEncoder




WritingEncodedScripts



Review





RunningEncodedScripts

Chapter28.ScriptingSecurity
WhyScriptingCanBeDangerous




SecurityImprovementsinWindowsXPandWindowsServer2003




RunningOnlySignedScripts



Review

DigitallySigningScripts
WaystoImplementSafeScripting


PartVI:Ready-to-RunExamples
Chapter29.LogonandLogoffScripts

NTandActiveDirectoryLogonScripts






ActiveDirectorySpecificLogonScripts



ActiveDirectoryLogoffScripts



Review



Chapter30.WindowsandDomainAdministrationScripts



AutomatingUserCreation



FindingInactiveUsers



CollectingSystemInformation









Review

Chapter31.NetworkAdministrationScripts
ShuttingDownRemoteComputers




ListingRemoteShares




UninstallRemoteMSIPackages




ListingHotFixesandSoftware




FindingOutWhoHasaFileOpen
AddingUsersfromExcel

Review
Chapter32.WMIandADSIScripts
TheAll-PurposeWMIQueryScript




TheAll-PurposeWMIUpdateScript




TheAll-PurposeADSIObjectQueryScript




MassPasswordChangeswithADSI

TheAll-PurposeADSIObjectCreationScript
TheAll-PurposeADSIObjectDeletionScript
Review


PartVII:Appendix
Administrator'sQuickScriptReference

A





B




D




F



H

C
E
G




I



J





K



M



N




O




Q



S




T




U



W



L

P
R

V

CD-ROMWarranty


Copyright
Manyofthedesignationsusedbymanufacturersandsellersto
distinguishtheirproductsareclaimedastrademarks.Where
thosedesignationsappearinthisbook,andAddison-Wesley
wasawareofatrademarkclaim,thedesignationshavebeen
printedwithinitialcapitallettersorinallcapitals.
WindowsisaregisteredtrademarkofMicrosoftCorporationin

theUnitedStatesandothercountries
ScreenshotsreprintedbypermissionfromMicrosoft
Corporation.
Theauthorandpublisherhavetakencareinthepreparationof
thisbook,butmakenoexpressedorimpliedwarrantyofany
kindandassumenoresponsibilityforerrorsoromissions.No
liabilityisassumedforincidentalorconsequentialdamagesin
connectionwithorarisingoutoftheuseoftheinformationor
programscontainedherein.
Thepublisheroffersdiscountsonthisbookwhenorderedin
quantityforbulkpurchasesandspecialsales.Formore
information,pleasecontact:
U.S.CorporateandGovernmentSales(800)382-3419

ForsalesoutsideoftheU.S.,pleasecontact:
InternationalSales(317)581-3793

VisitAddison-WesleyontheWeb:www.awprofessional.com
LibraryofCongressCataloging-in-PublicationData


Jones,Don.ManagingWindowswithVBScriptandWMI/Don
Jones.p.cm.Includesindex.ISBN0-321-21334-3(pbk.:alk.
paper)1.MicrosoftWindows(Computerfile)2.Operating
systems(Computers)3.VBScript(Computerprogram
language)I.Title.QA76.76.O63J66232004005.4'4682dc22
2003026069
Copyright©2004byPearsonEducation,Inc.
Allrightsreserved.Nopartofthispublicationmaybe
reproduced,storedinaretrievalsystem,ortransmitted,inany

form,orbyanymeans,electronic,mechanical,photocopying,
recording,orotherwise,withoutthepriorconsentofthe
publisher.PrintedintheUnitedStatesofAmerica.Published
simultaneouslyinCanada.
Forinformationonobtainingpermissionforuseofmaterialfrom
thiswork,pleasesubmitawrittenrequestto:
PearsonEducation,Inc.RightsandContractsDepartment75
ArlingtonStreet,Suite300Boston,MA02116Fax:(617)8487047
Textprintedonrecycledpaper
12345678910CRS0807060504
Firstprinting,March2004

Dedication
ThisisforChris.
Forsevenyears,you'vegivenmenothingbutlove,support,
andencouragement,andIcanneverthankyouenough.


PraiseforManagingWindows®with
VBScriptandWMI
"Thisisthe'must-have'scriptingguideforadministrators
ofalllevels.Itshowswhatyouneedtogetthejobdone
andhow."
JosephNiemi,SystemsEngineer
"Finally,astep-by-stepVBScriptingbooktomakeyoulook
likeaprogrammer,withoutthetimeandsweat!Don't
wasteyourtimesearchingtheInternetforexamples;this
bookdoesitforyou!"
GregA.Marino,SeniorSystemsEngineerandConsultant
WesttownConsultingGroup,Inc.

"Eachchapterislikehavingapersonaltutoratyourside
throughtheiterativeprocessofscripting,nomatterwhat
yourexperiencelevel.Whetheryouarewritingcomplex
scriptsorsimplyautomatingrepetitivetasks,Ifoundthis
booktrulyhitsthemarkastherighttooltogetthejob
done."
JoelYoker,ProgramManager
MicrosoftCorporation
"ThisbookwillprovideanytechnicalreaderwitharealworldunderstandingofhowtouseVBScriptwithWMI.
Theexamplesareclearandpertinenttotheneedsofthe
day-to-daysystemadministrator."
BobReselman,Principal
CognitiveArtsandTechnologies


Preface
MicrosoftintroducedVisualBasic,ScriptingEditioncommonly
knownasVBScriptinthemid-'90s,positioningitasanative
replacementforWindows'agingcommand-linebatchlanguage,
whichwasbasedonMicrosoft'searliestoperatingsystem,MSDOS.VBScriptwasintendedtobeeasytolearn,powerful,and
flexible.Thelanguagewasincludedasanadd-ontoWindows
95andWindowsNT4.0,wasanoptionalinstallationcomponent
includedinWindows98,andwasincludedinalleditionsof
WindowsMe,Windows2000,WindowsXP,andWindowsServer
2003.
SoftwaredevelopersimmediatelyseizeduponVBScriptforWeb
programming,particularlyinActiveServerPages,Microsoft's
rapid-developmentprogrammingframeworkfortheWeb.
However,WindowsadministratorsoneofVBScript'sinitialtarget
audienceswereleftcold.VBScriptseemedtobemuchmore

complicatedthanadministrators'belovedMS-DOS-basedbatch
language,andmanydidn'tseetheneedtolearnanentirely
newbatchlanguage.
WhenWindows2000andActiveDirectorycamealong,however,
administratorsfoundthatWindowsadministrationhadbecome
agreatdealmorecomplex.Suddenly,administratorswere
searchingforResourceKitandotherutilitiesthatoffered
automatedadministration,especiallyforrepetitivetasks.Active
DirectoryenabledtheuseofVBScriptforlogonandlogoff
scripts,whichseemedtopromisemoreadvanceduse
environmentmanipulation.Ataroundthesametime,
Microsoft'snaïvetéinreleasingapowerfullanguagelike
VBScriptwithabsolutelynosecuritycontrolsresultedinahuge
waveofhigh-impactVBScript-basedviruses,forcing
administratorstolockdowntheirenvironmentsandremove
VBScriptasanoptionbothforvirusesandforadministrative


tools.
Asaregularspeakeratsomeofthecountry'stoptechnical
conferencesthatfocusonWindowstechnologies,includingMCP
TechMentor,thepastfewyearsI'vegivenhalf-andfull-day
sessionsonVBScriptingforWindowsadministrators,andthe
sessionshavebeenincrediblypopular.Inthesesessions,Itry
toprovidejustenoughVBScriptexperiencetomakescripting
possible,andthenconcentrateonaccomplishingcommon
administrativetaskswithVBScript.Ialsocoverthesecurity
concernsofVBScriptandprovideadministratorswiththemeans
forsafelyusingVBScriptintheirenvironments.Thisbookis
essentiallyawrittenformofthosesessions,greatlyexpanded

withmorecoverageofWindowsManagementInstrumentation
andotheradvancedtopics,andwithmorecoverageofVBScript
securityissuesandresolutions.
I'mnotouttoturnyouintoaprogrammer.Infact,oneofthe
realsuccessesofVBScriptisthatyoudon'tneedtobea
programmertouseit.Mostofwhatyou'llbedoinginthisbook
involvesusingVBScripttotellWindowstodothingsforyou;
you'llbeabletoignoremuchofVBScript'scomplexity,usingit
asasortofelectronicgluetocombinevariousoperatingsystem
functions.


WhoShouldReadThisBook?
TheonlyassumptionIhaveaboutyouisthatyoualreadyknow
howtoadministersomeversionofMicrosoftWindows.You'll
findthatmostofthematerialinthisbookissuitablefor
WindowsNT,Windows2000,andWindowsServer2003
environments,anditwillcontinuetobeusefulthroughfuture
versionsofWindows.Idonotassumethatyouhaveany
backgroundinprogramming,andI'mnotgoingtogiveyoua
programmingbackground.
YoushouldhaveadesiretolearnhowtousewhatIcall"the
batchlanguageofthetwenty-firstcentury"andawishtomove
awayfromclumsierandoftenmorecomplexbatchfilesbasedon
theMS-DOSbatchlanguage.Althoughsomefolksliketorefer
tobatchfilesasscripts,Idon't;andwhenyouseehoweasy
andflexibleVBScriptis,you'llunderstandwhy!


HowtoUseThisBook

YoucanreadthisbookinorderfromtheIntroductiontothe
Appendix.However,ifyoualreadyhavesomeexperiencewith
VBScript,orifyoujustwanttodiverightintothemore
completeexamplescripts,youcanskiparoundasmuchasyou
like.I'veorganizedthisbookinthesamewaythatIorganize
myliveVBScriptingsessionsatconferences,soyoumayfeel
thatit'ssometimebeforeyoureallygetintothemeatof
scripting.Iassureyou,though,thateachexampleinthis
bookstartinginChapter1isfocusedonWindowsadministration.
You'llgetyourfeetwetrightaway!
I'vealsoincludedInThisChapterelementsatthestartofeach
chapterandComingUpelementsattheendofeachchapter.
Thesearebriefparagraphsthatareintendedtohelpsetthe
stageandhelpyoudecideifyouneedtoreadaparticular
chapterornot.They'llalsohelpyoudecidewhichchapterto
readnextbasedonyourindividualneedsandinterests.Ihope
thattheseelementsalongwiththecross-referencesI've
includedineachchapterwillhelpyouzipstraighttothe
scriptinginformationthatyouneedmost.
Tohelpyoudecidewheretostart,here'sabriefoverviewof
eachchapter.

PartI:IntroductiontoWindowsAdministrative
Scripting
PartIservesasanintroductiontotheworldofscriptingand
providesyouwithamethodologyforapproachingadministrative
tasksfromascriptingstandpoint.Oneofthemostdifficultparts
aboutproducingnewscriptsfromscratchisthe"WheredoI
start?"factor,andI'llprovideyouwithaframeworkforfiguring



thatouteverytime.

Chapter1:ScriptingConceptsandTerminology
AsI'vealreadyimplied,administrativescriptingisn'thard-core
programming.Instead,it'susingVBScriptasasortofelectronic
gluetosecurevariousbitsoftheWindowsoperatingsystem
together.Inthischapter,I'llintroduceyoutothosevariousbits
andsetthestagewithsomebasicterminologythatyou'lluse
throughoutthisbook.

Chapter2:RunningScripts
Writingascriptisn'tmuchfunifyoucan'trunthescript,andso
thischapterwillfocusonthetechnologiesusedtoexecute
scripts.Youmightbesurprisedtolearnhowmanydifferent
Microsoftproductssupportscripting.Inthischapter,I'llshow
youhowfaryourscriptingskillscanreallytakeyou.I'llalso
introduceyoutosomescriptingtoolsthatcanmakewritingand
debuggingscriptsabiteasier.

Chapter3:TheComponentsofaScript
Inthischapter,I'llpresentacompleteadministrativescript,and
thenbreakitdownline-by-linetoexplainitsvarious
components.Althoughthischapterisn'tnecessarytolearning
administrativescripting,itwillhelpyouwritescriptsthatare
morereliableandeasiertotroubleshoot.

Chapter4:DesigningaScript
AsI'vementionedalready,oneofthetoughestaspectsabout



scriptingcanbefiguringoutwheretostart.Inthischapter,I'll
provideyouwithaframeworkthatyoucanuseasastarting
pointforeverynewscriptingproject.I'llalsointroduceyouto
someconceptsthatmanyscriptingbooksignore,suchas
planningforerrorsandcreatingauseful"resourcekit"ofscript
componentsthatyoucanreusethroughoutyourscripting
projects.

PartII:VBScriptTutorial
Here'syourofficialcrashcoursetotheVBScriptlanguage:just
enoughtomakeadministrationviascriptapossibility!Thebest
partisthatIwon'tusethetrite"Hello,world"examplesthat
booksforsoftwaredevelopersoftenstartoutwith.Instead,I'll
makeeveryexampleusefultoyouasaWindowsadministrator.
Thatmeansyou'llbeproducingsimple,usefulscriptsatthe
sametimeyou'relearningVBScript.Whatcouldbebetter?

Chapter5:Functions,Objects,Variables,and
More
Inthischapter,I'llshowyouthebasicbuildingblocksofany
scriptandintroduceyoutosomesamplescriptsthatuseeach
buildingblockinaparticularadministrativetask.Thisisreally
themeatofadministrativescripting,andyou'llbeabletowrite
usefulscriptswhenyou'refinishedwiththischapter.

Chapter6:InputandOutput
Youcanmakeyourscriptsmoreflexiblebyaddingtheabilityto
dynamicallychangecomputer,user,anddomainnames,along
withotherinformation.Inthischapter,I'llshowyouhowyour

scriptcancollectinformationitneedstorunanddynamically


alteritselftotakeadvantageofthatinformation.

Chapter7:ManipulatingNumbers
Thischapterwillexplainhowscriptscanmanipulatenumbers,
makingiteasiertocreatescriptsthatworkwithnumericdata,
suchasuseraccountdata.I'llalsointroduceyoutoVBScript's
numericdatahandlingandconversioncommands,puttingyou
onthepathtosomegreatscriptingtechniques.

Chapter8:ManipulatingStrings
Stringsafancywordfortextdataareattheheartofmost
scriptingtasks.Inthischapter,I'llshowyouhowVBScriptdeals
withstringsandhowyoucaneasilyintegratethemintoyour
scripts.

Chapter9:ManipulatingOtherTypesofData
Asidefromtextandnumbers,yourscriptsmayneedtodeal
withdates,times,bytes,andotherformsofdatatoaccomplish
specificadministrativetasks.Inthischapter,I'llshowyouhow
VBScripthandlestheseotherdatatypesandhowyoucanuse
theminyourownscripts.

Chapter10:ControllingtheFlowofExecution
Thebestadministrativescriptscanrespondtochanging
conditionswithinternallogic,calledcontrol-of-flow.Inthis
chapter,I'llshowyouhowyourscriptscanbemadetoevaluate
variousconditionsandrespondaccordingly,performrepetitive

tasks,andmuchmore.


Chapter11:Built-inScriptingObjects
MuchofVBScript'spowercomesfromitscapabilitytojoin
variousoperatingsystemobjects,andinthischapter,I'll
introduceyoutoyourfirstsetofthoseobjects.You'lllearnhow
tomanipulatenetworkinformation,mapdrives,andmuch
moreprettymucheverythingyouneedtowriteeffectivelogon
scripts.

Chapter12:WorkingwiththeFileSystem
Acommonuseofscriptingistomanipulatefilesandfolders,
andinthischapter,I'llintroduceyoutotheVBScript
FileSystemObject,whichprovidesacompleteobjectmodelfor
workingwiththefilesystem.You'lllearntobuildautilitythat
scansIISlogfilesforerrormessages,ausefulscriptforany
environment!

Chapter13:PuttingItAllTogether:YourFirst
Script
Thisiswhereyou'llputeverythingfromPartIItogether.You'll
becreatingascriptthatrotatesIISlogfiles,keepingthepast
30days'worthoffilesinaspecialarchivefolder.I'llguideyou
throughthecompleteprocessofdesigning,writing,testing,and
troubleshootingthescript.Infact,I'lldeliberatelyintroduce
somelogicerrorsintothescriptsothatyoucanseethe
debuggingprocessinaction.

PartIII:WindowsManagementInstrumentation

andActiveDirectoryServicesInterface


WiththeglueofVBScriptunderyourbelt,I'lldiveintothetwo
mostpowerfultechnologiesforadministeringWindows:
WindowsManagementInstrumentation(WMI)andtheActive
DirectoryServicesInterface(ADSI).Thesetechnologiesprovide
administrativeaccessto,andcontrolover,nearlyeveryaspect
oftheWindowsoperatingsystem,fromWindowsNTto
WindowsServer2003.

Chapter14:WorkingwithADSIProviders
Despiteitsname,ADSIisn'tjustforActiveDirectory.Inthis
chapter,I'llshowyouhowADSIcanbeusedtointerfacewith
NT,ActiveDirectory,NovellNDS,ExchangeServer,andother
typesofdirectoryservices.I'llprovidesomebasicexamplesof
thetypesoftasksyoucanperformwithADSItogetyou
started.

Chapter15:ManipulatingDomains
WiththeADSIbasicsoutoftheway,I'llfocusonmanipulating
domaininformationinascript.You'lllearnhowtoquerydomain
information,modifydomainpolicieslikepasswordlength,and
muchmore.

Chapter16:ManipulatingUsersandGroups
Inthischapter,you'lllearnhowtowritescriptsthatqueryand
modifyuserandgroupinformation.Thisisoneofthemost
commontasksyou'llperformwithVBScript,andI'llinclude
plentyofusefulexamples.


Chapter17:UnderstandingWMI


WMIprovidesahookintojustabouteveryportionofthe
Windowsoperatingsystem,makingitanincrediblyusefultool
foradministrativescripts.Inthischapter,I'llintroduceyouto
WMIandshowyouapreviewofwhatyoucanuseitforinyour
environment.

Chapter18:QueryingBasicWMIInformation
Doyouwanttofindoutwhichusersinyourorganizationhavea
Pentium4computer?Thischapterwillshowyouhowtowrite
yourownbasicWMIqueries,includingthosethatinvolve
remotemachines.You'llalsolearnbasicWMImanipulation,
whichletsyoumodifylocalandremotemachinesettingsfrom
withinascript.

Chapter19:QueryingComplexWMIInformation
SomeWMIqueriesaremorecomplex,suchasqueryingtheIP
addressesfrommultiplenetworkadaptersinmultipleremote
computers.Thischapterprovidesclearexamplesofthesemore
complexWMItasks,helpingyoulearntowriteenterprise
managementscripts.

Chapter20:PuttingItAllTogether:YourFirst
WMI/ADSIScript
Thisiswhereitallcomestogether.I'llwalkyouthroughthe
processofdesigning,writing,testing,anddebugginga
completeWMI/ADSIscriptfromscratch.You'llfinishthis

chapterwithaconcreteexampleoftheadministrative
capabilitiesofthesetechnologies,andthenyou'llbereadyto
startwritingyourownscripts.


×