{"id":101,"date":"2006-10-22T01:36:33","date_gmt":"2006-10-21T23:36:33","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=101"},"modified":"2006-12-29T17:16:46","modified_gmt":"2006-12-29T15:16:46","slug":"discovery-och-installation-av-agenter-via-manualmctxt","status":"publish","type":"post","link":"https:\/\/contoso.se\/blog\/?p=101","title":{"rendered":"Discovery and installation of agenter with ManualMC.txt"},"content":{"rendered":"<p><font face=\"Calibri\" size=\"3\">MOM 2005 use the file ManualMC.txt as a alternative to add computers that will be monitored. MOM will install agent on all computers that are in the file, but it can be boring mission to keep that file updated all the time. I have done a script that will quest Active Directory for computers in a OU. The result will then be written to ManualMC.txt. You can also add some machines in the script, so all computers don&#8217;t need to be in the same OU. \u00c2\u00a0Setup this script as a schedule task to run sometime every day.<\/font><\/p>\n<p><font face=\"Calibri\" size=\"3\">Next time MOM run discovery a agent will be installed on all machines, or they will be placed under pending actions. That depends on your global settings. If you don&#8217;t want a machine to have a agent anymore, you can delete the name from ManualMC.txt and MOM will uninstall the agent at next discovery. <\/font><\/p>\n<p><font face=\"Calibri\" size=\"3\">Machines in ManualMC.txt will be excluded if there is a exclude rule in the discovery settings.<\/font><\/p>\n<p><font face=\"Calibri\" size=\"3\">You will find ManualMC.txt here %SYSTEM ROOT%\\Program Files\\Microsoft Operations Manager 2005\\<\/font><\/p>\n<p><font face=\"Calibri\" size=\"3\">This will be a default function in SCOM 2007. Before your start working with the script you will need to change<\/font><\/p>\n<ul>\n<li>\n<div><font face=\"Calibri\" size=\"3\">LDAP path<\/font><\/div>\n<\/li>\n<li>\n<div><font face=\"Calibri\" size=\"3\">Path to the ManualMC.txt file<\/font><\/div>\n<\/li>\n<li>\n<div><font face=\"Calibri\" size=\"3\">Computer name for computers that always will be included. If you want to add more than two you can add more Computer(X) lines, and also add the first Dom Computer (2) number.<\/font><\/div>\n<\/li>\n<\/ul>\n<p><code \/><code>'===========================================<br \/>\n'Machines that always will be included<br \/>\n'===========================================<\/p>\n<p>Dim Computers(2)<\/p>\n<p>Computers(0) = \"APP03.DOMAIN.LOCAL\"<br \/>\nComputers(1) = \"APP02.DOMAIN.LOCAL\"<br \/>\nComputers(2) = \"APP01.DOMAIN.LOCAL\"<\/p>\n<p>'===========================================<br \/>\n'Add machines from list above<br \/>\n'===========================================<\/p>\n<p>Dim i<br \/>\nDim OutStr<\/p>\n<p>Const ForAppending = 8<br \/>\nConst ForWriting = 2<\/p>\n<p>Set objFSO = CreateObject(\"Scripting.FileSystemObject\")<br \/>\nSet objFile = objFSO.OpenTextFile _<br \/>\n(\"C:\\manualmc.txt \", ForWriting)<\/p>\n<p>For i = 0 to UBound(Computers)<br \/>\nobjFile.WriteLine Computers(i)<br \/>\nNext<\/p>\n<p>'===========================================<br \/>\n'Query Active Directory for computer objects<br \/>\n'===========================================<\/p>\n<p>Const ADS_SCOPE_SUBTREE = 2<\/p>\n<p>Set objConnection = CreateObject(\"ADODB.Connection\")<br \/>\nSet objCommand = CreateObject(\"ADODB.Command\")<br \/>\nobjConnection.Provider = \"ADsDSOObject\"<br \/>\nobjConnection.Open \"Active Directory Provider\"<\/p>\n<p>Set objCOmmand.ActiveConnection = objConnection<br \/>\nobjCommand.CommandText = _<br \/>\n\"Select Name, Location from 'LDAP:\/\/OU=Fabrikam,DC=europe,DC=fabrikam,DC=net' \" _<br \/>\n& \"Where objectClass='computer'\"<br \/>\nobjCommand.Properties(\"Page Size\") = 1000<br \/>\nobjCommand.Properties(\"Searchscope\") = ADS_SCOPE_SUBTREE<br \/>\nSet objRecordSet = objCommand.Execute<br \/>\nobjRecordSet.MoveFirst<\/p>\n<p>'===========================================<br \/>\n'Add machines from Active Directory result<br \/>\n'===========================================<\/p>\n<p>Do Until objRecordSet.EOF<br \/>\nobjFile.WriteLine objRecordSet.Fields(\"Name\").Value<br \/>\nobjRecordSet.MoveNext<br \/>\nLoop<\/p>\n<p>'===========================================<br \/>\n'Close file<br \/>\n'===========================================<\/p>\n<p>objFile.Close<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MOM 2005 use the file ManualMC.txt as a alternative to add computers that will be monitored. MOM will install agent on all computers that are in the file, but it can be boring mission to keep that file updated all the time. I have done a script that will quest Active Directory for computers in &hellip; <a href=\"https:\/\/contoso.se\/blog\/?p=101\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2,13],"tags":[],"class_list":["post-101","post","type-post","status-publish","format-standard","hentry","category-microsoft-operations-manager-2005","category-scripts"],"_links":{"self":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=101"}],"version-history":[{"count":0,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}