{"id":68493,"date":"2005-11-18T16:16:00","date_gmt":"2005-11-18T16:16:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/11\/18\/how-can-i-verify-that-adam-is-installed\/"},"modified":"2005-11-18T16:16:00","modified_gmt":"2005-11-18T16:16:00","slug":"how-can-i-verify-that-adam-is-installed","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-verify-that-adam-is-installed\/","title":{"rendered":"How Can I Verify that ADAM is Installed?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I verify that ADAM is installed?<BR><BR>&#8212; CW<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, CW. Although former President Ronald Reagan is usually given credit for the phrase \u201cTrust but verify,\u201d we\u2019ve always thought that sounded more like the sort of thing a system administrator would say: \u201cOf <I>course<\/I> I trust you when you say you installed ADAM on that computer. I just need to <I>verify<\/I> that it was installed. That\u2019s a whole different thing.\u201d<\/P>\n<P>So how <I>can<\/I> you verify that ADAM (<A href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dnclinic\/html\/scripting01132004.asp\" target=\"_blank\"><B>Active Directory Application Mode<\/B><\/A>) is installed on a computer? Here\u2019s one way, a scripting solution that is also usually credited to former President Reagan:<\/P><PRE class=\"codeSample\">strComputer = &#8220;.&#8221;<\/p>\n<p>Set objWMIService = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\cimv2&#8221;)<\/p>\n<p>Set colServices = objWMIService.ExecQuery _\n    (&#8220;Select * from Win32_Service where Name Like &#8216;%ADAM_%'&#8221;)<\/p>\n<p>If colServices.Count = 0 Then\n    Wscript.Echo &#8220;ADAM is not installed.&#8221;\nElse\n    For Each objService in colServices\n        Wscript.Echo objService.Name &amp; &#8221; &#8212; &#8221; &amp; objService.State\n    Next\nEnd If\n<\/PRE>\n<P>This script relies on the fact that ADAM runs as a service: if the script uncovers an instance of the ADAM service then you know that ADAM is installed. Admittedly, there\u2019s a catch here: each instance of ADAM runs as a separate service with a separate name. Fortunately, there\u2019s also an easy way to determine whether <I>any<\/I> instance of ADAM is installed. And that\u2019s exactly what we\u2019re going to talk about next.<\/P>\n<P>The script begins by connecting to the WMI service on the local computer; as usual, you can modify this script to work against a remote machine simply by assigning the computer name to the variable strComputer. We then encounter this line of code:<\/P><PRE class=\"codeSample\">Set colServices = objWMIService.ExecQuery _\n    (&#8220;Select * from Win32_Service where Name Like &#8216;%ADAM_%'&#8221;)\n<\/PRE>\n<P>What we\u2019re doing here is using the <B>Like<\/B> operator to return all services where the service name includes the characters <B>ADAM_<\/B>. When using WMI\u2019s LIKE operator the two percentage signs stand for \u201canything.\u201d That means our query reads, \u201cGet me all the services that have the characters <B>ADAM_<\/B> somewhere in the Name property. I don\u2019t care what comes before or after the ADAM_; I just care that the string ADAM_ appears <I>somewhere<\/I> in the Name.\u201d<\/P>\n<P>Why do we do this? Well, as we noted, each instance of ADAM runs as a separate service; however, each service name <I>will<\/I> begin with the characters ADAM_. For example, if you have an instance of ADAM named Fabrikam the service name will be ADAM_Fabrikam; if you have an instance of ADAM named Contoso the service name will be ADAM_Contoso. We\u2019ve constructed our query to ensure that either of those two instances &#8211; or any other services with the characters ADAM_ in the Name &#8211; will be returned as part of the services collection.<\/P>\n<TABLE id=\"EFE\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Of course, you might be thinking, \u201cWait a second, Scripting Guys: isn\u2019t the LIKE operator supported only on Windows XP and Windows Server 2003? What if I\u2019m running ADAM on Windows 2000?\u201d Well, you are correct: the LIKE operator is supported only on Windows XP and Windows Server 2003. However, that shouldn\u2019t pose much of a problem here because ADAM itself is supported only on Windows XP and Windows Server 2003. Because you can\u2019t run ADAM on Windows 2000 you don\u2019t have to worry about whether ADAM is installed on a Windows 2000 machine; it isn\u2019t. Granted, you <I>will<\/I> have to run this script on a Windows XP or Windows Server 2003 machine. But if you\u2019re using ADAM we\u2019re assuming you\u2019ll be able to find one of those computers without too much trouble.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>After retrieving the collection of services we run into this If Then Else block: <\/P><PRE class=\"codeSample\">If colServices.Count = 0 Then\n    Wscript.Echo &#8220;ADAM is not installed.&#8221;\nElse\n    For Each objService in colServices\n        Wscript.Echo objService.Name &amp; &#8221; &#8212; &#8221; &amp; objService.State\n    Next\nEnd If\n<\/PRE>\n<P>What we\u2019re doing here is checking to see if the <B>Count<\/B> property of the returned collection is equal to 0. The Count tells us how many items are in the collection: if the Count is equal to 0 then there are <I>no<\/I> items in the collection. In turn, that means no instances of ADAM are installed on the computer and we echo back that very message.<\/P>\n<P>If the Count is greater than 0 that means at least one instance of ADAM was found. In that case, we set up a simple For Each loop to loop through all the instances of ADAM and, for each one, report back the instance Name and State (that is running, stopped, paused, etc.). <\/P>\n<P>That\u2019s all you have to do; just run this script and &#8211; what\u2019s that? What do you mean you don\u2019t trust us? Oh, we see: you <I>do<\/I> trust us, you just want to verify that the script actually works. We understand: that\u2019s a whole different thing. Give it a try and see what happens.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I verify that ADAM is installed?&#8212; CW Hey, CW. Although former President Ronald Reagan is usually given credit for the phrase \u201cTrust but verify,\u201d we\u2019ve always thought that sounded more like the sort of thing a system administrator would say: \u201cOf course I trust you when you say you installed [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[720,31,24,3,39,5],"class_list":["post-68493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-active-directory-application-mode-adam","tag-operating-system","tag-other-directory-services","tag-scripting-guy","tag-services","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I verify that ADAM is installed?&#8212; CW Hey, CW. Although former President Ronald Reagan is usually given credit for the phrase \u201cTrust but verify,\u201d we\u2019ve always thought that sounded more like the sort of thing a system administrator would say: \u201cOf course I trust you when you say you installed [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=68493"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=68493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=68493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=68493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}