{"id":2054,"date":"2011-01-19T06:30:38","date_gmt":"2011-01-19T05:30:38","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=2054"},"modified":"2011-01-19T06:30:38","modified_gmt":"2011-01-19T05:30:38","slug":"deploy-opsmgr-agent-to-untrusted-zones-with-opalis","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=2054","title":{"rendered":"Deploy OPSMGR agent to untrusted zones with Opalis"},"content":{"rendered":"<p>When the agent is located in a domain separate from the domain where the Operations Manager management server is located, and no two-way trust exists between the two AD forests, certificates must be used so that authentication can take place between the agent and management server. A gateway server could also be included in\u00c2\u00a0a solution to a scenario like that. To configure a agent to authenticate with certificate there is a number of steps to carry out. I have a couple of blog posts around that <a href=\"http:\/\/contoso.se\/blog\/?p=831\">here<\/a>, <a href=\"http:\/\/contoso.se\/blog\/?p=706\">here<\/a>\u00c2\u00a0and <a href=\"http:\/\/contoso.se\/blog\/?p=680\">here<\/a>. As you can see it is a pretty complicated process and easy that you miss a step or something is not configure in the correct way. A solution to that could be to use a Opalis workflow. Opalis will then carry out all the steps for you, and in the same way every time. In this blogpost I will show you a workflow like that.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2057\" title=\"opalis_dmz01\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz01-300x121.jpg\" alt=\"\" width=\"300\" height=\"121\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz01-300x121.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz01.jpg 960w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>As you can see in the picture the workflow is devided into a number of policies. When you are building larger and complex policies it is a good practice to break it down to smaller parts. You can then also call the different parts from different policies and re-use your policies in different scenarios.\u00c2\u00a0I tried to put all info that I will change often in variables, for example domain name, shared folder path and CA name. It is much easier to change one variable then change configuration of\u00c2\u00a010 objects. The following list will give you a overview of each policy in the workflow. Note that it is only variables starting with 4.X that this workflow use.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2060\" title=\"opalis_dmz02\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz02-300x98.jpg\" alt=\"All the variables\" width=\"300\" height=\"98\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz02-300x98.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz02.jpg 563w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<ul>\n<li>4.1 is the main policy, the one that will trigger the other ones. It starts with creating a sub-folder in a shared folder. This folder is used for all kind of file transfer between management server, CA, Opalis and the\u00c2\u00a0agent. The 4.1 policy also includes two objects in the end that delete temporary folders on all machines that has been involved.<\/li>\n<li>4.2 is used to verify name resolution between the Opalis server and the agent.<\/li>\n<li>4.3 is used to install the CA root certificate on the agent. I presuppose that the root CA is already trusted by the Operations Manager management server. The policy also presuppose that the root CA is in the shared folder.<\/li>\n<li>4.4 generate a certificate request file and copy it to the shared folder. The file is generate on the agent. The shared folder is a folder on the network that all involved machines can access. It is important to make sure all the involved accounts have read and writte permissions to this folder.<\/li>\n<li>4.5 Copy the certificate request file from the shared folder to the CA. It submitts the\u00c2\u00a0request and receives a certificate (.CER).\u00c2\u00a0The certificate is then copied over to the shared folder. This step presuppose that the CA autoapprove the certificate. I dont want to include any manually steps, so a auto approving CA was a need. You can configure your CA to only auto approve based on templates used, more info about that <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc782243(WS.10).aspx\">here<\/a>.<\/li>\n<li>4.6 Copy the certificate from the shared folder to the agent. It then adds the certificate to the local certificate store<\/li>\n<li>4.7 Copy the agent files from the shared folder to the agent. Installs the agent and verify that the Operations Manager agent service is running on the machine<\/li>\n<li>4.8 Configure Operations Manager to use the certificate and restarts the Operations Manager service<\/li>\n<\/ul>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz09.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2070\" title=\"opalis_dmz09\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz09-300x116.jpg\" alt=\"\" width=\"300\" height=\"116\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz09-300x116.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz09.jpg 565w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>This is the shared folder before deploying any agents. the folder includes a sub-folder with agent installation files, in my example is the AMD64 folder renamed to Agent. The shared folder also includes the CA root certificate and a powershell script. The powershell script is used in policy 4.8. It includes on line<\/p>\n<blockquote><p>Get-ChildItem cert:\\LocalMachine\\My | where-object {$_.Issuer -eq &#8220;CN=skynet-DC01-CA, DC=skynet, DC=local&#8221;} | foreach {$_.SerialNumber} | out-file C:\\temp_scom\\cert.txt<\/p><\/blockquote>\n<p>The powershell command will get the serial number of the agent certificate. We will need to write this to the registry of the machine so the Operations Manager agent know which certificate to use. As you can see the command list all certificates issued by a specified CA, skynet-DC01-CA. It then writes the serial number to C:\\temp_scom\\cert.txt. If you have multiple certificates installed from the CA you will need to add a couple of criteria, so filter the correct certificate out.<\/p>\n<p>The workflow includes a total of eight policies. We will now go into each one of them a bit deeper.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2062\" title=\"opalis_dmz03\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz03-300x191.jpg\" alt=\"\" width=\"300\" height=\"191\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz03-300x191.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz03.jpg 567w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.2 simple verify that the Opalis machine can get a IP of the target machine. If this is not working, nothing else in the workflow will work. It is always a good idea to start by checking all dependencies in your workflow, before you start changing anything. A idea could also be to add more tests to test that all involved accounts can write on the correct machines and folders.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2063\" title=\"opalis_dmz04\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz04-300x126.jpg\" alt=\"\" width=\"300\" height=\"126\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz04-300x126.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz04.jpg 891w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.3 policy starts with a creation of a new folder on the\u00c2\u00a0agent, the target machine. This folder, default C:\\temp_scom, will\u00c2\u00a0be used as temporary\u00c2\u00a0area for all files the workflow copy or generate. The second object is a \u00c2\u00a0file copy object. It is the root CA certificate that is being copied from the shared folder on the network\u00c2\u00a0to the agent. The last two objects first insert the certificate to the store and then adds it as a Trusted Publisher. Note that some of the &#8220;run program&#8221; or &#8220;run command&#8221; object will run until they timeout and is stopped, that will generate a warning but the policy will continue.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2064\" title=\"opalis_dmz05\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz05-300x143.jpg\" alt=\"\" width=\"300\" height=\"143\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz05-300x143.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz05.jpg 772w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u00c2\u00a0The 4.4 policy generates a certificate request file on the agent. It dose this by first writing a INF file and then using Certreq create a new request from an .inf file. The policy then copy the request file over to the shared folder (the .req file).<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2066\" title=\"opalis_dmz06\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz06-300x95.jpg\" alt=\"\" width=\"300\" height=\"95\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz06-300x95.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz06.jpg 893w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.5 policy start by creating a temporary folder on the CA. It then copy the certificate request from the shared folder to the temporary folder. Then with the CertReq command the certificate request is submitted to the CA. As I have configured the CA to auto approve requests the CertReq will also save the new certificate direct. The last object copy the new agent certificate to the shared folder.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz07.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2068\" title=\"opalis_dmz07\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz07-300x143.jpg\" alt=\"\" width=\"300\" height=\"143\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz07-300x143.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz07.jpg 769w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.6 policycopy the new agent certificate from the shared folder to the agent machine. It the adds the certificate to the local certificate store.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz08.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2069\" title=\"opalis_dmz08\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz08-300x178.jpg\" alt=\"\" width=\"300\" height=\"178\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz08-300x178.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz08.jpg 788w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.7 policy includes a number of steps. It start with creating a folder on the target machine for the agent installation files, default C:\\temp_scom\\agent. It then copies the agent installation files from the shared folder to the new temporary file.<\/p>\n<p><a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz10.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2072\" title=\"opalis_dmz10\" src=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz10-300x111.jpg\" alt=\"\" width=\"300\" height=\"111\" srcset=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz10-300x111.jpg 300w, http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/opalis_dmz10.jpg 806w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The 4.8 policy start by copy the getserial.ps1 script from the shared folder to the agent. This script export the serial number of the new agent certificate. The second object runs this powershell script. The next two steps reads the serial number from the text file that the powershell script generated, and write it as a platform notification. Next step add the serial number to the register in the correct order. The Operations Manager agent service is then restarted.<\/p>\n<p>That was all policies included in the workflow. Some minutes after this the target machine will show up in Operations Manager.\u00c2\u00a0In most environments it will show up\u00c2\u00a0under pending management (configure it\u00c2\u00a0at\u00c2\u00a0Administration\/Global Settings\/Security) and a Operations Manager administrator needs to approve it. This blog posted showed you one way to use Opalis together with Operations Manager, when deploying agents to machines in untrusted environments. A task that can be pretty complicated a includes a lot of steps. With Opalis you simple include a target machine name and click Start \ud83d\ude42<\/p>\n<p>For ideas and info how to build your workflow fault-tolerance, please read <a href=\"http:\/\/contoso.se\/blog\/?p=1919\">this<\/a> post. It could also be a idea to add some more platform event objects or write to logfile objects, to get some info from the workflow. Make sure that you have a unrestricted executionpolicy on your target machine, so the getserial.ps1 script can run. Make sure no firewall is blocking the traffic and also that the target machine have powershell installed. Also, spend a couple of minutes to make sure all involved accounts have access to write and read to the shared folder. If you want to download the workflow click <a href=\"http:\/\/contoso.se\/blog\/wp-content\/uploads\/2011\/01\/4-SCOM-Agent-2.zip\">4 SCOM Agent 2<\/a>.<\/p>\n<p>Please note that this is provided \u00e2\u20ac\u0153as is\u00e2\u20ac\u009d with no warranties at all<strong>.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When the agent is located in a domain separate from the domain where the Operations Manager management server is located, and no two-way trust exists between the two AD forests, certificates must be used so that authentication can take place between the agent and management server. A gateway server could also be included in\u00c2\u00a0a solution &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=2054\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","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":[58,19],"tags":[],"class_list":["post-2054","post","type-post","status-publish","format-standard","hentry","category-opalis","category-operations-manager-2007"],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2054"}],"version-history":[{"count":20,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2054\/revisions"}],"predecessor-version":[{"id":2086,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2054\/revisions\/2086"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2054"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}