<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Automation on Neale&#39;s Corner</title>
        <link>https://enlow.co.uk/categories/automation/</link>
        <description>Recent content in Automation on Neale&#39;s Corner</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language>
        <lastBuildDate>Mon, 25 Mar 2019 00:00:00 +0000</lastBuildDate><atom:link href="https://enlow.co.uk/categories/automation/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>Managing a DRS group with vRealize Orchestrator</title>
        <link>https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/</link>
        <pubDate>Mon, 25 Mar 2019 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/</guid>
        <description>&lt;p&gt;The use case for this challenge was a small (8-10 ESXi hosts) cluster, that only a subset of servers were &amp;lsquo;assigned&amp;rsquo; with Windows datacenter licenses - so in order to maintain compliance all the Windows VMs would need to run on those hosts. The natural choice for ensuring this happens is a &amp;ldquo;must run&amp;rdquo; DRS rule between a group of VMs and a group of hosts and the automation step for this is ensuring that the VM group is accurate by only containing VMs that are still in the cluster and contains all Windows VMs in the cluster. Thus, the plan is use vRealize Orchestrator to manage the DRS group.&lt;/p&gt;
&lt;p&gt;This technique (and workflow) will be left open enough for it to be used with any type of Operating System, after all I believe Red Hat also license on a per-hypervisor basis.&lt;/p&gt;
&lt;h4 id=&#34;core&#34;&gt;Core
&lt;/h4&gt;&lt;p&gt;The schema of the workflow is pictured below.&lt;/p&gt;
&lt;figure&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/images/image-13-1024x213.png&#34;
	
	
	
	loading=&#34;lazy&#34;
	
	
&gt;&lt;/p&gt;
&lt;figcaption&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The flow is one of the simplest we can make ! The steps are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Retrieve the configuration variables from the ConfigurationElement.&lt;/li&gt;
&lt;li&gt;Get the VMs from the cluster (exit the workflow if it has none).&lt;/li&gt;
&lt;li&gt;Get the DRS Group from the name (exit if it does not exist).&lt;/li&gt;
&lt;li&gt;Loop through the VMs and add/remove them to the DRS group as necessary.&lt;/li&gt;
&lt;li&gt;Send an email report if changes are made.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It has a single input of a ConfigurationElement, with the following variables. The description should make it apparent what each variable is used for.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-14.png&#34;
	width=&#34;778&#34;
	height=&#34;132&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-14_hu_5d4003f78d3f6dd0.png 480w, https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-14_hu_78786cfcb17a2ce4.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;589&#34;
		data-flex-basis=&#34;1414px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The magic of the workflow is the updating of the DRS rule, which the below script covers:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-16.png&#34;
	width=&#34;481&#34;
	height=&#34;275&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-16_hu_54ec3002e9fbd3f5.png 480w, https://enlow.co.uk/p/managing-a-drs-group-with-vrealize-orchestrator/images/image-16_hu_ac0747f4fcc18b3f.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;174&#34;
		data-flex-basis=&#34;419px&#34;
	
&gt;&lt;/p&gt;
&lt;h4 id=&#34;where-next&#34;&gt;Where next
&lt;/h4&gt;&lt;p&gt;As it stands now, we can schedule the workflow to run at the end of the day and allow DRS to place the VMs correctly.&lt;/p&gt;
&lt;p&gt;However, to really ensure that the VM is running on the correct host we would invoke this workflow on every creation and addition to the cluster. This is possible when using LogInsight - configured as a destination for the ESXi hosts&amp;rsquo; syslogs - to call Orchestrator via a Webhook when the appropriate events are received.&lt;/p&gt;
&lt;p&gt;Now that we can dynamically change a DRS rule, this is starting to open up possibilities. Stay tuned :)&lt;/p&gt;
&lt;h4 id=&#34;summary&#34;&gt;Summary
&lt;/h4&gt;&lt;p&gt;You can download the workflow package using the button below. Please let me know if you found this useful !&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://enlow.co.uk/wp-content/uploads/2019/03/uk.co_.enlow_.drs_.package&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;&lt;br&gt;
&lt;/a&gt;&lt;a class=&#34;link&#34; href=&#34;http://enlow.co.uk/wp-content/uploads/2019/03/uk.co_.enlow_.drs_.package&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Download package file&lt;/a&gt;&lt;/p&gt;</description>
        </item>
        <item>
        <title>Updating a HP iLO using Rest API and vRealize Orchestrator</title>
        <link>https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/</link>
        <pubDate>Mon, 18 Mar 2019 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/</guid>
        <description>&lt;p&gt;A security vulnerability against Hewlett Packard iLOs was announced last year (link - &lt;a class=&#34;link&#34; href=&#34;https://www.rapid7.com/db/modules/auxiliary/admin/hp/hp_ilo_create_admin_account&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://www.rapid7.com/db/modules/auxiliary/admin/hp/hp_ilo_create_admin_account&lt;/a&gt;), along with the required firmware to patch. No doubt there are some amazing tools by HP that will allow firmware to be patched across an estate, but as I don&amp;rsquo;t have access to them I need to find another way to get firmware out to 20+ servers.&lt;/p&gt;
&lt;p&gt;There is an API (documentation at &lt;a class=&#34;link&#34; href=&#34;https://hewlettpackard.github.io/ilo-rest-api-docs/ilo4/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://hewlettpackard.github.io/ilo-rest-api-docs/ilo4/&lt;/a&gt;) which is quite straight forward to use, so we&amp;rsquo;ll have a look at using Postman to update an iLO and then use vRealize Orchestrator to implement a workflow.&lt;/p&gt;
&lt;h4 id=&#34;using-postman&#34;&gt;Using Postman
&lt;/h4&gt;&lt;p&gt;Throughout this I will be using the headers below, though the second one is only required when updating the firmware.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea3b6ffa8.png&#34;
	width=&#34;538&#34;
	height=&#34;53&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea3b6ffa8_hu_d497410c5ea35e3e.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea3b6ffa8_hu_aa5948b3526b066d.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;1015&#34;
		data-flex-basis=&#34;2436px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;To start, we&amp;rsquo;ll ask the iLO for a Manager interface, which will provide links to the services it offers. Authentication is handled by the headers on a per-request basis. We won&amp;rsquo;t need to manage session or tokens :)&lt;/p&gt;
&lt;p&gt;The initial request is a GET to https://&amp;lt;FQDN/IP&amp;gt;/redfish/v1/managers/ as below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5e98da20e8.png&#34;
	width=&#34;836&#34;
	height=&#34;581&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5e98da20e8_hu_8f19e856d5cfbc0a.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5e98da20e8_hu_1e67e038247ff7c1.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;143&#34;
		data-flex-basis=&#34;345px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The data returned contains an array with the name &amp;ldquo;Members&amp;rdquo; that will point to the URL for the manager for the iLO. We&amp;rsquo;re going to use that to get the details for the manager - there is a lot of data here so I&amp;rsquo;m not going to post it all. There are two points of interest for us - firstly the current firmware version:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea96db8af.png&#34;
	width=&#34;272&#34;
	height=&#34;157&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea96db8af_hu_9cdaf4a765c1ee06.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ea96db8af_hu_9f939eb64653f864.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;173&#34;
		data-flex-basis=&#34;415px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;Secondly the links to services - we are interested in the UpdateService.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eaecef4ce.png&#34;
	width=&#34;460&#34;
	height=&#34;452&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eaecef4ce_hu_f15fc58704d95963.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eaecef4ce_hu_d2ced477cfce2b78.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;101&#34;
		data-flex-basis=&#34;244px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;We will use the location provided to access the service - which will allow the current firmware status to be retrieved and an update to be triggered.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eb7cdba9c.png&#34;
	width=&#34;788&#34;
	height=&#34;509&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eb7cdba9c_hu_e765b4d6726baf53.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5eb7cdba9c_hu_5b51c3d78971ac19.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;154&#34;
		data-flex-basis=&#34;371px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The documentation has some reference on what to do - &lt;a class=&#34;link&#34; href=&#34;https://hewlettpackard.github.io/ilo-rest-api-docs/ilo4/#links-updateuri-extref-and-links-updateuri-extref&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://hewlettpackard.github.io/ilo-rest-api-docs/ilo4/#links-updateuri-extref-and-links-updateuri-extref&lt;/a&gt; - which is pictured below.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ed00a4bfa.png&#34;
	width=&#34;240&#34;
	height=&#34;261&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ed00a4bfa_hu_c6f17de2e5aa61fd.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ed00a4bfa_hu_aadaac0b853b745e.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;91&#34;
		data-flex-basis=&#34;220px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;However, other documentation at http://h22208.www2.hpe.com/eginfolib/servers/docs/HPRestfultool/iLo4/data_model_reference.html#HpiLOFirmwareUpdate details the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5edaee7ecb.png&#34;
	width=&#34;780&#34;
	height=&#34;402&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5edaee7ecb_hu_5acb0efc95e118d8.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5edaee7ecb_hu_637885d8a355b4fc.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;194&#34;
		data-flex-basis=&#34;465px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;This explains we&amp;rsquo;ll need to include an &amp;ldquo;Action&amp;rdquo; parameter in our request. To update the iLO we will need to host the firmware on a webserver that is accessible from the iLO address - this blog entry isn&amp;rsquo;t going to cover how to do this (I&amp;rsquo;m assuming that you&amp;rsquo;ve got a webserver to hand and you&amp;rsquo;re allowing the extension/content-type to be downloaded. Remember to test it manually before trying to automate, especially if your environment is subject to network controls)&lt;/p&gt;
&lt;p&gt;Our POST request body will look as follows:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ef28893b9.png&#34;
	width=&#34;493&#34;
	height=&#34;214&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ef28893b9_hu_f06530d1e4bc1367.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc5ef28893b9_hu_af0f633e35ff6de9.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;230&#34;
		data-flex-basis=&#34;552px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The iLO will restart when complete - there is no need to manually trigger this, though it is generally a good idea to ensure it has completed. To do this, we will call the GET request to the UpdateService/ URL and check the &amp;ldquo;State&amp;rdquo; value - it will change to the following values:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UPDATING&lt;/li&gt;
&lt;li&gt;COMPLETED&lt;/li&gt;
&lt;li&gt;(The request will fail when the iLO automatically restarts)&lt;/li&gt;
&lt;li&gt;IDLE&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So if we get a value of COMPLETED or IDLE then we can check the iLO version. However, given that a value of COMPLETED will follow with a period of silence it is more prudent to wait for the IDLE - which I believe we will also receive in the result of failure.&lt;/p&gt;
&lt;h3 id=&#34;using-vrealize-orchestrator&#34;&gt;Using vRealize Orchestrator
&lt;/h3&gt;&lt;p&gt;Now to find a way to put the above into Orchestrator - the workflow to upgrade an iLO is:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60c9b8427b.png&#34;
	width=&#34;1324&#34;
	height=&#34;506&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60c9b8427b_hu_91dad65412a873a9.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60c9b8427b_hu_e0db6b6bf3813ebb.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;261&#34;
		data-flex-basis=&#34;627px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The workflow has the following inputs:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60d6498f61.png&#34;
	width=&#34;779&#34;
	height=&#34;246&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60d6498f61_hu_976ed18640662a07.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60d6498f61_hu_9dd39b25b8c61cc0.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;316&#34;
		data-flex-basis=&#34;760px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The check version value will, if set to true, retrieve the version from the iLO and compare it to the values in the new_major and new_minor fields. If the firmware version on the iLO is newer then the firmware installation will not proceed. This check is dependent on human accuracy as there is no way of reliably retrieving the firmware version from the file, thus if the incorrect version is entered then installation will fail.&lt;/p&gt;
&lt;p&gt;The heart of using vRO to drive this process is dynamically creating REST hosts in code, sending the requests and dealing with the response. Taking a look in the vRO workflow &amp;ldquo;Invoke a dynamic REST operation&amp;rdquo; we can see how VMware have done it:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/images/img_5bc60e877ecc8-1024x209.png&#34;
	
	
	
	loading=&#34;lazy&#34;
	
	
&gt;&lt;/p&gt;
&lt;p&gt;The important things to note are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We need to create a REST Host object, and then use it to create a transient host.&lt;/li&gt;
&lt;li&gt;We need to specify the base url and authentication on the transient host object.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However if we invoke a REST call over HTTPS without importing the certificate it will fail, so we will need to handle this failure by importing the certificate and re-running the REST invocation.&lt;/p&gt;
&lt;p&gt;This is handled by the Import Cert ?/Import a certificate/Log Cert Import elements. This is done by catching the exception that is thrown.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60f4848f98.png&#34;
	width=&#34;1228&#34;
	height=&#34;218&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60f4848f98_hu_a0ab6e092094ee9b.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5bc60f4848f98_hu_e92be2955487afe3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;563&#34;
		data-flex-basis=&#34;1351px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;We now need to can connect to the manager address and find out the location of the UpdateService service - which we did earlier in Postman. Doing this in some javascript looks like the following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7efc986cc.png&#34;
	width=&#34;1230&#34;
	height=&#34;534&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7efc986cc_hu_ef95c81cbd20ecf9.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7efc986cc_hu_8e54a57fcc6420eb.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;230&#34;
		data-flex-basis=&#34;552px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The main part of this workflow is upgrading the firmware - we need to POST the update:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f6a7ac3b.png&#34;
	width=&#34;1380&#34;
	height=&#34;262&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f6a7ac3b_hu_3e574656e70ffb8a.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f6a7ac3b_hu_f5d235398b18b135.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;526&#34;
		data-flex-basis=&#34;1264px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;And then loop until we reach the IDLE state. When we exit the loop we can check if the version is different from before we started the process. This will give us our success/failure result to return to the user. The loop is as below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f892ee2b.png&#34;
	width=&#34;1293&#34;
	height=&#34;666&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f892ee2b_hu_292b607d71ea5211.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7f892ee2b_hu_a419c2f611cc4ed7.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;194&#34;
		data-flex-basis=&#34;465px&#34;
	
&gt;&lt;/p&gt;
&lt;h3 id=&#34;wrapping-it-up-&#34;&gt;Wrapping it Up !
&lt;/h3&gt;&lt;h4 id=&#34;updating-multiple-ilos&#34;&gt;Updating multiple iLOs
&lt;/h4&gt;&lt;p&gt;This is quite straight forward - there are two approaches.&lt;/p&gt;
&lt;p&gt;The first one will duplicate the workflow and then adjust the input to take an array of addresses (This does however mean that the credentials to access the iLO must be the same). The schema will be changed to loop through the addresses.&lt;/p&gt;
&lt;p&gt;The second approach is the one I favour - we create a new workflow which has duplicate inputs, with the exception of an addition for an array of addresses. The workflow loops through the addresses and calls our original workflow with the other inputs. This method means that we only have one workflow which contains the code that upgrades the iLO, so there is less to manage/maintain.&lt;/p&gt;
&lt;p&gt;The workflow in this case will look like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7ca56b8be.png&#34;
	width=&#34;775&#34;
	height=&#34;380&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7ca56b8be_hu_c693e5a6901dc9b0.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7ca56b8be_hu_403db8c135b17252.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;203&#34;
		data-flex-basis=&#34;489px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;with the following inputs:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7cd162439.png&#34;
	width=&#34;723&#34;
	height=&#34;349&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7cd162439_hu_bc753960779340e7.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7cd162439_hu_df4af61d02a12dbb.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;207&#34;
		data-flex-basis=&#34;497px&#34;
	
&gt;&lt;/p&gt;
&lt;h4 id=&#34;updating-an-esxi-cluster-using-a-custom-attribute&#34;&gt;Updating an ESXi Cluster using a custom attribute
&lt;/h4&gt;&lt;p&gt;To take this a step further, each ESXi host has a custom attribute with the address of its iLO (work Host so address is blanked):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7dde6fd08.png&#34;
	width=&#34;581&#34;
	height=&#34;218&#34;
	srcset=&#34;https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7dde6fd08_hu_e4e1d3065476a2fa.png 480w, https://enlow.co.uk/p/updating-a-hp-ilo-using-rest-api-and-vrealize-orchestrator/images/img_5c0e7dde6fd08_hu_e709322125d86c12.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;266&#34;
		data-flex-basis=&#34;639px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;A workflow is created that will get all the hosts in the cluster, and for each host retrieve the custom attribute. If a value exists, then the original workflow is called to upgrade the firmware. This workflow will only upgrade one physical server at a time, even though there is (or should not be) any impact on the running workloads. It&amp;rsquo;s just less risky, and isn&amp;rsquo;t that what our job is really about ? ;)&lt;/p&gt;
&lt;p&gt;The challenge here will be ensuring that hosts have a completed (and valid) address for the iLO.&lt;/p&gt;
&lt;h4 id=&#34;vsphere-client-integration&#34;&gt;vSphere Client Integration
&lt;/h4&gt;&lt;p&gt;Still using the Flash Client because it allows you to call vRealize Orchestrator workflows ? Yep, me too. We can export the workflows we&amp;rsquo;ve created here to make them available on the context menu for hosts and clusters - thus making the upgrade even easier !&lt;/p&gt;
&lt;h4 id=&#34;further-automation--improvements&#34;&gt;Further Automation / Improvements
&lt;/h4&gt;&lt;p&gt;Taking this further would be to wrap this in an interface (custom HTTP, ansible, etc) that allows end users to provide the firmware file and the host(s) or cluster(s) to upgrade.&lt;/p&gt;
&lt;p&gt;This is beyond the scope of this post, but could be provisioned through your DevOps platform of choice. Let me know your thoughts on this one !&lt;/p&gt;
&lt;h3 id=&#34;summary&#34;&gt;Summary
&lt;/h3&gt;&lt;p&gt;The workflow(s) and associated actions/etc are all available to download via the button below.&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://enlow.co.uk/wp-content/uploads/2019/03/uk.co_.enlow_.hp_.ilo_.package&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Download package file&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope you&amp;rsquo;ve found this useful, please let me know your feedback and whether it helped. Thanks for reading :)&lt;/p&gt;</description>
        </item>
        <item>
        <title>Managing Snapshots with vRO</title>
        <link>https://enlow.co.uk/p/managing-snapshots-with-vro/</link>
        <pubDate>Mon, 25 Feb 2019 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/managing-snapshots-with-vro/</guid>
        <description>&lt;p&gt;One of the main issues that face departments on their virtualisation journey is how they are managing snapshots:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Who can take them&lt;/li&gt;
&lt;li&gt;Who can delete them&lt;/li&gt;
&lt;li&gt;How long do they stick around for&lt;/li&gt;
&lt;li&gt;Name/Description formatting policy&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I consider them &amp;rsquo;low hanging fruit&amp;rsquo; on the management tree - how an organisation approaches this is defined by policy and there shouldn&amp;rsquo;t be anything too contentious involved. There are also options to have the snapshots deleted automatically, with most management software providing the function. If you don&amp;rsquo;t have this, then a vSphere alarm can be created to warn on snapshots sizes.&lt;/p&gt;
&lt;p&gt;There was no option to automatically remove snapshots that was in accordance with the policy that was agreed at a previous role, so it was time to automate something :). One of the items revolved around communication to the snapshot owner - it is very important to inform them that the snapshot will be automatically removed and when it has been. Another item was where some snapshots that might be automatically cleared up would need to be held for longer - perhaps as a part of a Root Cause Analysis investigation.&lt;/p&gt;
&lt;h4 id=&#34;requirements&#34;&gt;Requirements
&lt;/h4&gt;&lt;p&gt;From the above, the requirements are this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Inform the user who took the snapshot that it will be deleted in X days, daily until deleted. (X should be configurable).&lt;/li&gt;
&lt;li&gt;Inform the user that the snapshot has been deleted.&lt;/li&gt;
&lt;li&gt;Report to a team/email address details on all snapshots present and estimate the space use.&lt;/li&gt;
&lt;li&gt;Exclude Virtual Machines from having their snapshots automatically deleted.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These will mean that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The workflow will always produce a report. Therefore our input values should include an email address.&lt;/li&gt;
&lt;li&gt;A means of identifying a Virtual Machine as being excluded. We could supply a list, or a naming format to match, a tag or a custom attribute.&lt;/li&gt;
&lt;li&gt;Given that we can retrieve the username of the person who created the snapshot (it is contained within the event), we still need a means of identifying the email address of the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My preference for the second item above is to use a tag as we can retrieve VMs easier from a management perspective.&lt;/p&gt;
&lt;p&gt;The identity source for the vCenter is assumed to be Active Directory, thus we would have the further assumption that no local accounts are allowed (or only in exceptional circumstances) and will be taking snapshots. We can therefore use the Active Directory plugin to query for the user and retrieve the email address. However we should also handle the edge case that the user does not have an email address set, or it is not valid - therefore we will issue warning emails to an appropriate team that the end user was not/cannot be warned of the snapshot expiry.&lt;/p&gt;
&lt;p&gt;In summary, our input values are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;# Days when start to warn end users of deletion.&lt;/li&gt;
&lt;li&gt;# Days when the snapshot should be deleted.&lt;/li&gt;
&lt;li&gt;Email address in case of errors.&lt;/li&gt;
&lt;li&gt;Email address for the report.&lt;/li&gt;
&lt;li&gt;Tag name for VMs to be excluded from snapshot management.&lt;/li&gt;
&lt;li&gt;A &amp;lsquo;WhatIf&amp;rsquo; to control whether action is taken.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Our vRO server will also need to have the Active Directory plugin active and configured.&lt;/p&gt;
&lt;p&gt;We also need to deal with another assumption - there can be more than one snapshot on a VM, and multiple snapshots may need to be deleted on each day.&lt;/p&gt;
\[Hindsight\]&lt;p&gt;&lt;br&gt;
After creating the workflows I added another couple of inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Minimum age of VM snapshot to appear on the report.&lt;/li&gt;
&lt;li&gt;Subject of the report.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;workflows&#34;&gt;Workflows
&lt;/h4&gt;&lt;p&gt;I write vRO workflows in a decentralised manner - for example if I am to do something with a Virtual Machine I have a workflow for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Virtual Machine&lt;/li&gt;
&lt;li&gt;The Cluster&lt;/li&gt;
&lt;li&gt;(Sometimes) The Datacenter&lt;/li&gt;
&lt;li&gt;vCenter Server&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This can add up to a lot of workflows, but it allows for testing and iterating changes easily. I will often put a &amp;ldquo;WhatIf&amp;rdquo; input on the Virtual Machine workflow so that I can test the workflows that function at a higher level - this ties in with the identified inputs earlier. So in this case, the workflow design mirrors the above (but without a datacenter script).&lt;/p&gt;
&lt;p&gt;Additionally, when communicating to people the details of a VM with a snapshot I include Custom Attributes and Tags. So the workflows below will contain some tagging actions that I really need to release ;)&lt;/p&gt;
&lt;h5 id=&#34;virtual-machine&#34;&gt;Virtual Machine
&lt;/h5&gt;&lt;p&gt;This workflow will need to do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get the snapshot information for a VM.&lt;/li&gt;
&lt;li&gt;Calculate snapshot size (if possible).&lt;/li&gt;
&lt;li&gt;Get the tags for a VM.&lt;/li&gt;
&lt;li&gt;Add information to the report.&lt;/li&gt;
&lt;li&gt;Check the tag to see if the VM will have it&amp;rsquo;s snapshots automatically managed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the VM is to be automatically managed, it will need to do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the snapshot is older than the warning age, send a warning to the snapshot creator, or the errors address.&lt;/li&gt;
&lt;li&gt;If the snapshot is older than the deletion age, send a notification to the snapshot creator, or the errors address.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;ve separate the above into two lists as I think the logic flows naturally in this way - the first list will apply to every VM that we examine whereas the second will only apply to those VMs with snapshots that we will manage. Thus we can break the logic up into two workflows.&lt;/p&gt;
&lt;p&gt;Disclaimer: I&amp;rsquo;m assuming some familiarity with Orchestrator here, and there are plenty of other awesome blogs introducing the tool, so I&amp;rsquo;m going to dive in to some completed workflows.&lt;/p&gt;
&lt;p&gt;The schema for the first flow is below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image.png&#34;
	width=&#34;951&#34;
	height=&#34;778&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image_hu_ca228819a2854b6.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image_hu_ac8532ac801bd852.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;122&#34;
		data-flex-basis=&#34;293px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;Some notable steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Excluded from snaps - This is where the tag is checked.&lt;/li&gt;
&lt;li&gt;Automatic Management - This is where the WhatIf is handled.&lt;/li&gt;
&lt;li&gt;Manage Snapshots - We call the workflow to manage them. This sits inside a loop that will examine all the snapshots on a VM.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some scripts are included to help with generating the report :)&lt;/p&gt;
&lt;p&gt;The schema for Managing Snapshots is here:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-1.png&#34;
	width=&#34;785&#34;
	height=&#34;627&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-1_hu_f12000405c04baea.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-1_hu_29889c44363e0dcd.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;125&#34;
		data-flex-basis=&#34;300px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The notable steps for this workflow are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;getEmailAddressForUser - this will query Active Directory for the mail attribute for the user identified earlier.&lt;/li&gt;
&lt;li&gt;Remove Snapshot - deletes the snapshot and sets a task object so the workflows/entire process operates synchronously.&lt;/li&gt;
&lt;li&gt;Customise Email - these write the warning and notification emails to be sent to the end user.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id=&#34;cluster-workflow&#34;&gt;Cluster Workflow
&lt;/h5&gt;&lt;p&gt;This workflow retrieves all the VMs in the cluster and runs the main VM workflow against it. Nothing special here :)&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-3.png&#34;
	width=&#34;803&#34;
	height=&#34;571&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-3_hu_f603823e5a7f413f.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-3_hu_35009c07f1ea6a6.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;140&#34;
		data-flex-basis=&#34;337px&#34;
	
&gt;&lt;/p&gt;
&lt;h5 id=&#34;clusters--vcenter-servers-workflow&#34;&gt;Clusters / vCenter Servers Workflow
&lt;/h5&gt;&lt;p&gt;This is fairly standard workflow that goes through all the clusters on a vCenter Server and runs the Cluster workflow. It follows a standard pattern of retrieving a set of items and iterating through them. The end of the schema is devoted to sending the report email.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-2.png&#34;
	width=&#34;841&#34;
	height=&#34;767&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-2_hu_efaab48d18be370.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-2_hu_2647f530706c78d7.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;109&#34;
		data-flex-basis=&#34;263px&#34;
	
&gt;&lt;/p&gt;
&lt;h5 id=&#34;configuration-element&#34;&gt;Configuration Element
&lt;/h5&gt;&lt;p&gt;As I wrote this a while ago, I put all the configuration inside a Configuration Element so that configuration variables could be updated once a workflow was scheduled. Please excuse my naming format, it does the job but the names made sense at the time I promise !&lt;/p&gt;
&lt;p&gt;These names match the inputs that the workflows take:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-4.png&#34;
	width=&#34;820&#34;
	height=&#34;316&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-4_hu_4f71f68befdce92c.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-4_hu_cb68cbdd31bc82.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;259&#34;
		data-flex-basis=&#34;622px&#34;
	
&gt;&lt;/p&gt;
&lt;h4 id=&#34;emails&#34;&gt;Emails
&lt;/h4&gt;&lt;p&gt;Here is an example of the report email running on a live environment:&lt;/p&gt;
&lt;figure&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-5.png&#34;
	width=&#34;881&#34;
	height=&#34;541&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-5_hu_8bc89fc8a1bdb9f.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-5_hu_5b56084f3c944716.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;162&#34;
		data-flex-basis=&#34;390px&#34;
	
&gt;&lt;/p&gt;
&lt;figcaption&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;An example of the email notification a user receives about their snapshot (some field values have been removed):&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-6.png&#34;
	width=&#34;421&#34;
	height=&#34;288&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-6_hu_e66f887406faf538.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-6_hu_e09a4a206fc5f4d8.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;146&#34;
		data-flex-basis=&#34;350px&#34;
	
&gt;&lt;/p&gt;
&lt;h4 id=&#34;download&#34;&gt;Download
&lt;/h4&gt;&lt;p&gt;The workflows, actions and configuration element is available to download here. The package includes the following workflows&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-7.png&#34;
	width=&#34;233&#34;
	height=&#34;147&#34;
	srcset=&#34;https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-7_hu_5f5eb853662bf00e.png 480w, https://enlow.co.uk/p/managing-snapshots-with-vro/images/image-7_hu_944729b87de21430.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;158&#34;
		data-flex-basis=&#34;380px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;Once the package is imported, run one of the workflows and let me know what you think ! You&amp;rsquo;ll be able to run the cluster and VM workflows without having to configure a Configuration Element.&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://enlow.co.uk/wp-content/uploads/2019/02/uk.co_.enlow_.snapshots.package&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Download package file&lt;/a&gt;&lt;/p&gt;
&lt;h4 id=&#34;improvements&#34;&gt;Improvements
&lt;/h4&gt;&lt;p&gt;The most obvious improvement to this workflow would be to made the notifications optional and controlled via an input. Maybe something for a rainy day ;)&lt;/p&gt;
&lt;p&gt;Let me know if this was useful or interesting to you !&lt;/p&gt;</description>
        </item>
        <item>
        <title>Detaching Devices from a Cluster</title>
        <link>https://enlow.co.uk/p/detaching-devices-from-a-cluster/</link>
        <pubDate>Mon, 14 Aug 2017 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/detaching-devices-from-a-cluster/</guid>
        <description>&lt;p&gt;When working with block storage we occasionally need to remove a storage device from the hosts it is connected to. When using the Web Client we can detach devices on a per-host basis, but there is nothing to detach from all its attached hosts.&lt;/p&gt;
&lt;p&gt;What we do have is a helpful KB article on how to remove/detach a datastore -Â &lt;a class=&#34;link&#34; href=&#34;https://kb.vmware.com/kb/2004605&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://kb.vmware.com/kb/2004605&lt;/a&gt;Â and a PowerCLI file that contains some functions. However the functions revolve around managing actions on datastores as opposed to devices that are connected and could be used for RDMs.&lt;/p&gt;
&lt;p&gt;Most LUNs are masked to all the hosts in a cluster so that, whether the device is an RDM or has a VMFS datastore on it, VMs can run on any host in the cluster. To deal with this use case, I use a script that will detach a device from every host in a cluster. If the device does not exist on Â a host then an error is displayed and the script moves on to the next device/host.&lt;/p&gt;
&lt;p&gt;Before we can detach a device we need to ensure the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is not used for a datastore.&lt;/li&gt;
&lt;li&gt;It is not in use as a RDM.&lt;/li&gt;
&lt;li&gt;The perennially reserved flag is not set for the device on the host.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The last point comes from the KB article above - if the flag is set (and it should be for any RDMs) then it could prevent the device from being unmounted successfully. So although clearing the flag is not required, clearing it ensures the best chance of success.&lt;/p&gt;
&lt;p&gt;So, our script will start off with the following - we will accept a cluster to unmount/detach the device(s) from, an array of device identifiers, and a switch that will allow us to do checks without actually detaching anything.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[Parameter(Mandatory=$true,ValueFromPipeline)][VMware.VimAutomation.ViCore.Impl.V1.Inventory.ClusterImpl] $Cluster,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[Parameter(Mandatory=$true)][String[]] $LUNIdentifiers,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[switch]$CheckUsage = $false
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;For the sake of time, we will make the assumption that all devices are masked to all hosts in the cluster - so when checking what the device is used for we will only check on the first host in the cluster. The following code will get the VMs in the cluster (for checking RDM usage in the next step) and the host that we will use for checking.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$vms = $Cluster | Get-VM;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$cluster_host = $Cluster | Get-VMHost | sort Name | select -First 1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$LUNs_To_Detach = @();
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$LUNIdentifiers | % {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	$lunid = $_;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$lun = get-scsilun -VMHost $cluster_host | ? { $_.CanonicalName -eq $lunid }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Finally we will use the Get-ESXCLI cmdlet to check if the perennially reserved flag is set.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$myesxcli = get-esxcli -VMHost ESXhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;When all our checks are complete, we can loop through the hosts in the cluster and attempt to detach the LUN.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	$Cluster | get-vmhost | sort Name | % {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		write-host &amp;#34;Detaching LUNs from $($_.Name)&amp;#34; -Foreground Yellow
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$esx = $_;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$storSys = Get-View $_.Extensiondata.ConfigManager.StorageSystem
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		foreach ($lunid in $LUNs_To_Detach){				
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$lun = Get-ScsiLun -VmHost $esx | ? { $_.CanonicalName -eq $lunid }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($lun -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				# Ensure the LUN is attached 
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				if ($lun.ExtensionData.OperationalState -eq &amp;#34;ok&amp;#34;) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					write-host &amp;#34;Detaching LUN $lun&amp;#34; # from $($esx.Name)&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					$storSys.DetachScsiLun($lun.ExtensionData.Uuid)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					write-host &amp;#34;Detach Complete&amp;#34; -Foreground Green
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				} elseif ($lun.ExtensionData.OperationalState -eq &amp;#34;off&amp;#34;) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					Write-Host &amp;#34;LUN is already unmounted on this host.&amp;#34; -Foreground Green;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				} else {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					Write-Host &amp;#34;OperationalState is $($lun.ExtensionData.OperationalState)&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			} else {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Write-Host &amp;#34;Could not find LUN $lun on host $esx.Name&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The entire script is available from my github &lt;a class=&#34;link&#34; href=&#34;https://github.com/nelons/psscripts/blob/master/vsphere/Detach-ClusterLUNs.ps1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;here&lt;/a&gt;. As always, feel free to fork and make pull requests if you find a mistake.&lt;/p&gt;</description>
        </item>
        <item>
        <title>Using Orchestrator to automatically upgrade Tools</title>
        <link>https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/</link>
        <pubDate>Wed, 08 Mar 2017 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/</guid>
        <description>&lt;p&gt;One of the main challenges in every (non-small) place I&amp;rsquo;ve worked is keeping VMware Tools updated, and with Change Management processes this becomes a little bit more complicated. There is a setting on each VM to upgrade Tools when the VM is booted and this is a good way to keep Tools updated on those VMs that aren&amp;rsquo;t mission critical and require manual intervention.&lt;/p&gt;
&lt;p&gt;In this post we&amp;rsquo;ll look at creating an action and a workflow to configure this setting, and pushing it as a context setting in the Flex Web Client.&lt;/p&gt;
&lt;p&gt;This leads to the issue of how this setting is enabled - firstly as part of the initial push (you don&amp;rsquo;t want to enable this manually for 100&amp;rsquo;s (or more) VMs) and with newly created VMs. Although this can be set on a VM template or &amp;ldquo;Gold Build&amp;rdquo; (or equivalent terminology), this can still lead to human error so we&amp;rsquo;ll also look creating a workflow to set this for a cluster and scheduling this using the Flex Web Client.&lt;/p&gt;
&lt;h4 id=&#34;upgrade-tools-action&#34;&gt;Upgrade Tools Action
&lt;/h4&gt;&lt;p&gt;To configure a VM to upgrade Tools we need to create a new configuration specification and set the tools configuration appropriately. Our actionÂ will return the Task for the configuration (note: this can be null) and will take two inputs - the VM to configure and whether we are automatically upgrading Tools. Here is a screenshot of the action configuration:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586577d88fffe.png&#34;
	width=&#34;321&#34;
	height=&#34;122&#34;
	srcset=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586577d88fffe_hu_dfc26034d28fe23a.png 480w, https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586577d88fffe_hu_90c644766cca1ce7.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;vco-automatically-upgrade-tools-action-parameters&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;263&#34;
		data-flex-basis=&#34;631px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The script of the action is as follows:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;task&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;null&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;vm&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;!=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;null&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;k&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;toolsconfig&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;VcToolsConfigInfo&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;k&#34;&gt;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;autoupgrade&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;==&lt;/span&gt; &lt;span class=&#34;bp&#34;&gt;true&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		&lt;span class=&#34;n&#34;&gt;toolsconfig&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;toolsUpgradePolicy&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;upgradeAtPowerCycle&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		&lt;span class=&#34;n&#34;&gt;toolsconfig&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;toolsUpgradePolicy&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;manual&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;k&#34;&gt;var&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;vmconfig&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;new&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;VcVirtualMachineConfigSpec&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;n&#34;&gt;vmconfig&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;tools&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;toolsconfig&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	&lt;span class=&#34;n&#34;&gt;task&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;vm&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reconfigVM_Task&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;vmconfig&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;task&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;In the code snippet above, we ensure that the &amp;ldquo;vm&amp;rdquo; variable contains a valid VM. We create a new ToolsConfigInfo object which will contain the tools settings that we wish to apply and then create a new VirtualMachineConfigSpec object and assign the ToolsConfigInfo object to it. Thus when we call the reconfigVM_Task() function with the configuration object, the VM is only reconfigured with the settings we have provided.&lt;/p&gt;
&lt;p&gt;Now we have an action, we can create a workflow that will invoke it and then wait for the task to complete. This is the schema diagram:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586580bdbfde6.png&#34;
	width=&#34;493&#34;
	height=&#34;223&#34;
	srcset=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586580bdbfde6_hu_34819274c9bea1d3.png 480w, https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586580bdbfde6_hu_3f8de459a17593aa.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;vco-automatically-upgrade-tools-workflow-schema&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;221&#34;
		data-flex-basis=&#34;530px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The workflow (and action) can be downloadedÂ from the file at the end of this post.&lt;/p&gt;
&lt;h4 id=&#34;cluster-workflow&#34;&gt;Cluster Workflow
&lt;/h4&gt;&lt;p&gt;Now we have an action to make the changes, we can put together a workflow that will look at all VMs in the cluster and configure them. The schema is as follows:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586ad1836cd71.png&#34;
	width=&#34;642&#34;
	height=&#34;350&#34;
	srcset=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586ad1836cd71_hu_1701fa6ae8e0cd23.png 480w, https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_586ad1836cd71_hu_6a3526f4e637306f.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;183&#34;
		data-flex-basis=&#34;440px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;The workflow will get all VMs in the cluster and for each one:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Only upgrade Windows VMs (&amp;ldquo;Upgrade VM ?&amp;rdquo; decision)&lt;/li&gt;
&lt;li&gt;Check if the configuration setting currently matches what we want it to. (&amp;ldquo;Decide setting&amp;rdquo; script).&lt;/li&gt;
&lt;li&gt;Change the setting.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The meat of the process is in the &amp;ldquo;Decide setting&amp;rdquo; script item - we will look at what the setting should be, and if the current setting does not match then we will change it. This also means that if we wish the VM to update Tools manually and it is set to automatically update at power on, the setting will be changed to update manually.&lt;/p&gt;
&lt;h4 id=&#34;setting-as-a-context-action&#34;&gt;Setting as a context action
&lt;/h4&gt;&lt;p&gt;To set this as a context action on the cluster within the Flex Web Client, we need to look at the Orchestrator pages in the Web Client. The server page will have a Manage screen and a Context Actions page:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_589a518eb890b.png&#34;
	width=&#34;631&#34;
	height=&#34;211&#34;
	srcset=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_589a518eb890b_hu_cdfc1973f570fcdd.png 480w, https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/img_589a518eb890b_hu_2cdace01328541d1.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;299&#34;
		data-flex-basis=&#34;717px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;Next we need to add a new one - select the workflow to add and the type of object to associate it with - in this case we&amp;rsquo;re adding the workflow to set the upgrade for Tools for a single virtual machine, so we select the Virtual Machine object:&lt;/p&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;http://enlow.co.uk/wp-content/uploads/2017/02/add_context_workflow.png&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;&lt;img src=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/add_context_workflow.png&#34;
	width=&#34;727&#34;
	height=&#34;542&#34;
	srcset=&#34;https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/add_context_workflow_hu_d935da99e830b8f8.png 480w, https://enlow.co.uk/p/using-orchestrator-to-automatically-upgrade-tools/images/add_context_workflow_hu_80947f636d8418b0.png 1024w&#34;
	loading=&#34;lazy&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;134&#34;
		data-flex-basis=&#34;321px&#34;
	
&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Press OK and all is done. You&amp;rsquo;ll need to reload the Flex Web Client in order to see it - it appears at the bottom of the actions menu for the object - under the &amp;ldquo;vRealize Orchestrator context actions&amp;rdquo; title.&lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s it !Â This workflow a prime candidate for being scheduled to ensure all your VMs are kept up to date.&lt;/p&gt;
&lt;p&gt;The workflows (and action) for this are available at my github repo - &lt;a class=&#34;link&#34; href=&#34;https://github.com/nelons/vco-content&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://github.com/nelons/vco-content&lt;/a&gt;.&lt;/p&gt;</description>
        </item>
        <item>
        <title>Automating Brocade FC Configuration (Part 2)</title>
        <link>https://enlow.co.uk/p/automating-brocade-fc-configuration-part-2/</link>
        <pubDate>Fri, 20 Jan 2017 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/automating-brocade-fc-configuration-part-2/</guid>
        <description>&lt;p&gt;From the first article we looked at how to use the SSH Sessions Powershell module to log into a Linux server that will, via a script, log into a Brocade FC switch and get the zoning configuration.&lt;/p&gt;
&lt;p&gt;As per the disclaimer in the first part, these articles have been assembled from my notes and memory and may not be 100% correct. I worked with FOS 6.x and so 7.x/later releases might not need this approach - I no longer have access to any Brocade FC switches to test :)&lt;/p&gt;
&lt;h4 id=&#34;getting-the-switch-config-via-a-function&#34;&gt;Getting the switch config via a function
&lt;/h4&gt;&lt;p&gt;As we&amp;rsquo;re going to need to get the config from two switches, we&amp;rsquo;ll write a powershell function that will get the config from one switch, so we have one call for each. The function is as follows:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;30
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;31
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;32
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;33
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Get-BrocadeSwitchZoneConfig {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[CmdletBinding()]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param (
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $Target,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $Username,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $Password,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[switch] $VersionSix
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Import the SSH-Sessions Module.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		Import-Module $PSScriptRoot\..\modules\SSH-Sessions\SSH-Sessions.psd1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Connect to the target.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		New-SshSession -ComputerName $Target -Username $Username -Password $Password | out-null
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Invoke the command to get the config.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$config = &amp;#34;&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($VersionSix -eq $False) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$config = Invoke-SshCommand -ComputerName $Target -Command &amp;#34;zoneshow&amp;#34; -Quiet
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		} else {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$config = Invoke-SshCommand -ComputerName $Target -Command &amp;#34;bash --login -c &amp;#39;zoneshow&amp;#39;&amp;#34; -Quiet;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Disconnect from the target.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		Remove-SShSession -ComputerName $Target | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# return the config.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		return $config;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;So, let&amp;rsquo;s get the config:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config1 = Get-BrocadeSwitchZoneConfig -Target &amp;#34;switch1.fqdn&amp;#34; -Username &amp;#34;automation&amp;#34; -Password &amp;#34;password&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config2 = Get-BrocadeSwitchZoneConfig -Target &amp;#34;switch2.fqdn&amp;#34; -Username &amp;#34;automation&amp;#34; -Password &amp;#34;password&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h4 id=&#34;sanity-checking-the-zone-configuration&#34;&gt;Sanity Checking the Zone Configuration
&lt;/h4&gt;&lt;p&gt;Before changing the configuration we need to make sure anything we create does not already exist. Namely, we&amp;rsquo;ll be checking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;WWPNs of the server HBAs.&lt;/li&gt;
&lt;li&gt;The name of the server zone.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;30
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Check-FCConfig {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[CmdletBinding()]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param (
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        Parameter(Mandatory=$true)][string] $Config,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $Hostname,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $HBA
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# need to trim the &amp;#34;-&amp;#34; from the hostname as it is an illegal char on the brocades.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$brocade_hostname = $Hostname.Replace(&amp;#34;-&amp;#34;, &amp;#34;&amp;#34;);
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($HBA -ne $Null) {			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Check to see if the hostname is present
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($Config.ToLower().Contains($brocade_hostname.ToLower())) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Write-Host &amp;#34;Hostname exists in the current config.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				return $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Check to see if HBA address is present.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($Config.ToLower().Contains($HBA.ToLower())) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Write-Host &amp;#34;HBA exists in the current config.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				return $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                        return $True;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;                return $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;So, we&amp;rsquo;ll then need to call this for each of the switch configs we got earlier. Our new script looks as follows:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config1_ok = $false;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config2_ok = $false;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config1 = Get-BrocadeSwitchZoneConfig -Target &amp;#34;switch1.fqdn&amp;#34; -Username &amp;#34;automation&amp;#34; -Password &amp;#34;password&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;if ($config1.Length -gt 0) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  $config1_ok = Check-FCConfig -Config $config1 -Hostname &amp;#34;server01&amp;#34; -HBA &amp;#34;20:00:00:25:B5:40:02:0F&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$config2 = Get-BrocadeSwitchZoneConfig -Target &amp;#34;switch2.fqdn&amp;#34; -Username &amp;#34;automation&amp;#34; -Password &amp;#34;password&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;if ($config2.Length -gt 0) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  $config2_ok = Check-FCConfig -Config $config2 -Hostname &amp;#34;server01&amp;#34; -HBA &amp;#34;20:00:00:25:B5:40:02:1F&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;if ($config1_ok -eq $true -And $config2_ok -eq $true) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt; // Here is where we create the config.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Hopefully the above is quite straight forward - we get the config for the both switches and check that it is ok for the servername and for the HBA address. We store the result in a local variable, and when both checks are complete we will only be making changes to the FC switches if both configs reported good.&lt;/p&gt;
&lt;h4 id=&#34;the-final-proxy-script&#34;&gt;The final proxy script
&lt;/h4&gt;&lt;p&gt;Our final Linux proxy script will change the configuration on a singleÂ switches, and we will call it twice, once for each server. This would allow us to provide different variables for each switch, in case they have not been configured identically. The variables that we will pass, and their position for the script are below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Hostname of the filer.&lt;/li&gt;
&lt;li&gt;Username for the filer.&lt;/li&gt;
&lt;li&gt;Password for the filer.&lt;/li&gt;
&lt;li&gt;Server hostname&lt;/li&gt;
&lt;li&gt;WWPN for the HBA&lt;/li&gt;
&lt;li&gt;Name of the active configuration&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Our full script will be:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;cat &amp;laquo; _END_ | sshpass -p ${1} ssh ${3} -tt -o StrictHostKeyChecking=no -l ${2} alicreate ${4}_hba0, ${5} zonecreate ${4}, &amp;ldquo;${4}_hba0;san_hba0;san_hba1&amp;rdquo; cfgadd ${6}, ${4} echo y|cfgenable ${6} exit _END_&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is how we would call it:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$brocade_hostname = $Hostname.Replace(&amp;#34;-&amp;#34;, &amp;#34;&amp;#34;);
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$brocade_config_name = &amp;#34;config&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$fc_switch1 = &amp;#34;switch1.fqdn&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$fc_switch2 = &amp;#34;switch2.fqdn&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Connect to the brocade scripting host.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;New-SshSession -ComputerName $brocade_script_host -Username $brocade_script_host_username -Password $brocade_script_host_password | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Run the Script.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$results = Invoke-SshCommand -ComputerName $brocade_script_host -Command &amp;#34;./create-fc-zone $fc_switch1 $brocade_username $brocade_password $brocade_hostname $HBA0 $brocade_config_name&amp;#34; -Quiet;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Run the Script.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$results = Invoke-SshCommand -ComputerName $brocade_script_host -Command &amp;#34;./create-fc-zone $fc_switch2 $brocade_username $brocade_password $brocade_hostname $HBA1 $brocade_config_name&amp;#34; -Quiet;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Disconnect from the host
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Remove-SshSession -ComputerName $brocade_script_host | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h4 id=&#34;powershell-configuration-script&#34;&gt;Powershell Configuration Script
&lt;/h4&gt;&lt;p&gt;When we put the above together we will aim to have some powershell that will:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Get the config of each FC switch&lt;/li&gt;
&lt;li&gt;Check the config to ensure there will be no clashes or problems.&lt;/li&gt;
&lt;li&gt;Call the proxy script to update the config.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This would look like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;30
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;31
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;32
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;33
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;34
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;35
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;36
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;37
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;38
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;39
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;40
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;41
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;42
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;43
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;44
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;45
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;46
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;47
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;48
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;49
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;50
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;51
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Create-FC-Zone {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	[CmdletBinding()]
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param (
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $Hostname,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $HBA0,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][string] $HBA1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$brocade_hostname = $Hostname.Replace(&amp;#34;-&amp;#34;, &amp;#34;&amp;#34;);
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$brocade_config_name1 = &amp;#34;config&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$brocade_config_name2 = &amp;#34;config&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# FC Switch Details.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$fc_switch1 = &amp;#34;switch1.fqdn&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$fc_switch2 = &amp;#34;switch2.fqdn&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$fc_username = &amp;#34;automation&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$fc_password = &amp;#34;password&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Proxy Details
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$proxy_host = &amp;#34;proxy.fqdn&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$proxy_username = &amp;#34;automation&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$proxy_password = &amp;#34;password&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$config1_ok = $false;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$config2_ok = $false;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$config1 = Get-BrocadeSwitchZoneConfig -Target $fc_switch1 -Username $fc_username -Password $fc_password;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($config1.Length -gt 0) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$config1_ok = Check-FCConfig -Config $brocade_config_name1 -Hostname $brocade_hostname -HBA $HBA0;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$config2 = Get-BrocadeSwitchZoneConfig -Target $fc_switch2 -Username $fc_username -Password $fc_password;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($config2.Length -gt 0) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$config2_ok = Check-FCConfig -Config $brocade_config_name2 -Hostname $brocade_hostname -HBA $HBA1;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($config1_ok -eq $true -And $config2_ok -eq $true) {			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Connect to the brocade scripting host.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			New-SshSession -ComputerName $proxy_host -Username $proxy_username -Password $proxy_password | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Run the Script.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$results = Invoke-SshCommand -ComputerName $proxy_host -Command &amp;#34;./create-fc-zone $fc_switch1 $fc_username $fc_password $brocade_hostname $HBA0 $brocade_config_name&amp;#34; -Quiet;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Run the Script.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$results = Invoke-SshCommand -ComputerName $proxy_host -Command &amp;#34;./create-fc-zone $fc_switch2 $fc_username $fc_password $brocade_hostname $HBA1 $brocade_config_name&amp;#34; -Quiet;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Disconnect from the host
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Remove-SshSession -ComputerName $proxy_host | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    }
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This uses the function &amp;ldquo;Get-BrocadeSwitchZoneConfig&amp;rdquo; at the beginning of this article, and most of the variables are configured in the script. For the sake of security you&amp;rsquo;ll want to remove these from being hardcoded and pass them in as parameters. I&amp;rsquo;ve left them as hardcoded to show what is required and where it is used.&lt;/p&gt;
&lt;p&gt;This is available in a single file on my &lt;a class=&#34;link&#34; href=&#34;https://github.com/nelons/psscripts/blob/master/brocade/brocade.ps1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;psscripts github repo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Please let me know if anything is wrong or if this helped you !&lt;/p&gt;</description>
        </item>
        <item>
        <title>VMware vCheck NTP and Syslog Plugin Amendments</title>
        <link>https://enlow.co.uk/p/vmware-vcheck-ntp-and-syslog-plugin-amendments/</link>
        <pubDate>Tue, 09 Jun 2015 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/vmware-vcheck-ntp-and-syslog-plugin-amendments/</guid>
        <description>&lt;p&gt;I&amp;rsquo;m a big fan of the &lt;a class=&#34;link&#34; href=&#34;http://www.virtu-al.net/vcheck-pluginsheaders/vcheck/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;vCheck script&lt;/a&gt; by the very talented Alan Renouf and community, but a couple of the plugins don&amp;rsquo;t work as well as I&amp;rsquo;d like with our environment, where we have multiple NTP and Syslog servers and these settings can differ depending on the cluster within a single vCenter. So I&amp;rsquo;ve made a few changes to the vCheck NTP and Syslog plugins.&lt;/p&gt;
&lt;h4 id=&#34;ntp-plugin&#34;&gt;NTP Plugin
&lt;/h4&gt;&lt;p&gt;The file is called &amp;ldquo;31 NTP Name and Service.ps1&amp;rdquo; and kept in the &amp;ldquo;30 Host&amp;rdquo; folder.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m going to cut out the bottom part of the plugin script as there would only be cosmetic changes made there.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Start of Settings
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# The NTP server which should be set on your hosts
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ntpserver = &amp;#34;ntp-server1.cluster1 ntp-server2.cluster1&amp;#34;, &amp;#34;ntp-server1.cluster2&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# End of Settings
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$Result = @($VMH | Where {$_.Connectionstate -ne &amp;#34;Disconnected&amp;#34;} | Select Name, @{N=&amp;#34;NTPServer&amp;#34;;E={&amp;#34;$($_ | Get-VMHostNtpServer)&amp;#34;}}, @{N=&amp;#34;ServiceRunning&amp;#34;;E={(Get-VmHostService -VMHost $_ | Where-Object {$_.key -eq &amp;#34;ntpd&amp;#34;}).Running}} | Where {$_.ServiceRunning -eq $false -o $ntpserver -notcontains $_.NTPServer})
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$Result
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;There are two changes here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The line &amp;ldquo;$($_ | Get-VMHostNtpServer)&amp;rdquo; has been enclosed in quotation marks to expand the array into a string.&lt;/li&gt;
&lt;li&gt;The check at the end has been changed so we are now checking if the NTP server values are in the provided array.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I&amp;rsquo;m fairly sure the list of NTP servers are ordered (but have been known to be wrong before), so I&amp;rsquo;m leaving the list of servers in the order that PowerCLI decides to return them. So when specifying a list of NTP servers, do it in the order they should be used/configured.&lt;/p&gt;
&lt;h4 id=&#34;syslog-servers&#34;&gt;Syslog Servers
&lt;/h4&gt;&lt;p&gt;The syslog plugin file is called &amp;ldquo;51 Syslog Name.ps1&amp;rdquo; and it is also in the &amp;ldquo;30 Host&amp;rdquo; folder.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t believe that the syslog hosts are ordered (they certainly shouldn&amp;rsquo;t be), so in the code below we&amp;rsquo;re looking at the list of syslog hosts sorted alphabetically.&lt;/p&gt;
&lt;p&gt;The code is now:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;8
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Start of Settings 
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# The Syslog server which should be set on your hosts
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Multiple syslog entries per host must be space separated and in alphabetical order.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# Multiple possible entries per vCenter should be comma separated so an array is created.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$SyslogServer = &amp;#34;udp://syslog-server1 udp://yet-another-syslog-server&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;# End of Settings
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;@($VMH | Where-Object {$_.ExtensionData.Summary.Config.Product.Name -eq &amp;#39;VMware ESXi&amp;#39;} | Select-Object Name,@{Name=&amp;#39;SyslogServer&amp;#39;;Expression = {&amp;#34;$(($_ | Get-VMHostSysLogServer).Host | sort Host)&amp;#34;}} | Where-Object {$SyslogServer -notcontains $_.SyslogServer})
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;There&amp;rsquo;s a few changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &amp;lsquo;SyslogSettings&amp;rsquo; section, supporting ESXi 4.x has been removed.&lt;/li&gt;
&lt;li&gt;The line &amp;ldquo;$(($_ | Get-VMHostSysLogServer).Host | sort Host)&amp;rdquo; sorts the names and expands the array into a string.&lt;/li&gt;
&lt;li&gt;The comparison check at the end now checks for presence in the array.&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&#34;summary&#34;&gt;Summary
&lt;/h4&gt;&lt;p&gt;This is very much a lazy fix to a problem I had, and there will be a better solution. For instance, it&amp;rsquo;s not going to check that hosts in a certain cluster have particular settings - just that all hosts have a valid setting permissable for the vCenter. But it&amp;rsquo;ll do the job, and for everything else there should be host profiles - and there is vCheck plugin that can be used unaltered to check on those ;)&lt;/p&gt;</description>
        </item>
        <item>
        <title>Creating a Cisco UCS Profile using PowerTool</title>
        <link>https://enlow.co.uk/p/creating-a-cisco-ucs-profile-using-powertool/</link>
        <pubDate>Thu, 26 Mar 2015 00:00:00 +0000</pubDate>
        
        <guid>https://enlow.co.uk/p/creating-a-cisco-ucs-profile-using-powertool/</guid>
        <description>&lt;h2 id=&#34;creating-a-cisco-ucs-profile-using-powertool&#34;&gt;Creating a Cisco UCS Profile using PowerTool
&lt;/h2&gt;&lt;p&gt;This post is going to walk through creating a powershell function to create a Service Profile on a Cisco UCS domain. Later posts in this series will look at how to assign it to a server, configure shared storage on a NetApp filer, and configure the zoning on Fiber Channel switches - essentially all the work we&amp;rsquo;d need to do to automate the creation of a physical server.&lt;/p&gt;
&lt;p&gt;There are a few ways to create Service Profiles on a Cisco UCS domain, but if you&amp;rsquo;re looking for consistency, best practice and the possibility to automate then you&amp;rsquo;ll need to use templates - not just a Service Profile template, but templates within the Service Profile template - for vNICs, vHBAs and for any other policies. I have assumed that templates have been set up and are being used.&lt;/p&gt;
&lt;p&gt;We are going to be using Cisco UCS PowerTool for this, so ensure you&amp;rsquo;ve got this installed on your system. You can get it from , but you&amp;rsquo;ll need a Cisco.com login.&lt;/p&gt;
&lt;h3 id=&#34;the-file&#34;&gt;The File
&lt;/h3&gt;&lt;p&gt;Open up your favourite IDE or text editor (personally I use Notepad++) and create a new file. Save it with a filename and a location of your choice. My file is going to be called &amp;ldquo;automate.ps1&amp;rdquo; and I keep everything in a &amp;ldquo;scripts&amp;rdquo; folder in the root of a hard drive. Powershell has a verb system, so the cmdlets are prepended (for example) with &amp;ldquo;New&amp;rdquo;, &amp;ldquo;Get&amp;rdquo; and &amp;ldquo;Set&amp;rdquo;. I&amp;rsquo;m going to use the verb &amp;ldquo;Automate&amp;rdquo; to make our functions stand out from anything else that might exist on your system, but you might wish to use your company name or something else.&lt;/p&gt;
&lt;p&gt;Below is a sample function definition for &amp;ldquo;Automate-NewUCSProfile&amp;rdquo;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-NewUcsProfile {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param()
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Our code will go here
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The first line declares the function and the curly brackets open its contents. The &amp;ldquo;Param()&amp;rdquo; line will be expanded so we can pass parameters into the function, and the main body of code will reside in the curly brackets are the &amp;ldquo;Process {&amp;rdquo; section. We then close off every open curly bracket &amp;ldquo;{&amp;rdquo; with the opposite curly bracket &amp;ldquo;}&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;d like to learn more about Powershell functions, your search engine of choice will direct you.&lt;/p&gt;
&lt;h3 id=&#34;connections&#34;&gt;Connections
&lt;/h3&gt;&lt;p&gt;When we connect to a UCS domain we can be given a handle to it. PowerTool will support connections to multiple UCS domains, though I believe the default is one and it needs to be reconfigured through the Set-UcsPowerToolConfiguration cmdlet (see it and the Connect-UCS cmdlet help for more information). If we are connecting to one UCS domain then we won&amp;rsquo;t need to use the handle when using other cmdlets, however I believe it is good practice to do so, so I will.&lt;/p&gt;
&lt;p&gt;To connect we use:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Connect-UCS -Name ucspe01 -Credential (Get-Credential)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;When running the above connect cmdlet (and after entering correct credentials for the target UCS domain) we are given something similar to below (which is a platform emulator output running on VMware Workstation 9):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Proxy                       :
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Cookie                      : 1427096220/c399b102-8234-4bad-a94d-4202ed62593a
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Domains                     : org-root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;LastUpdateTime              : 23/03/2015 07:36:59
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name                        : 192.168.117.135
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;NoSsl                       : False
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;NumPendingConfigs           : 0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;NumWatchers                 : 0
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Port                        : 443
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Priv                        : {aaa, admin, ext-lan-config, ext-lan-policy...}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;RefreshPeriod               : 600
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;SessionId                   :
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;TransactionInProgress       : False
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PromptOnCompleteTransaction : False
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Ucs                         : UCSPE-192-168-117-135
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Uri                         : https://192.168.117.135
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;UserName                    : config
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;VirtualIpv4Address          : 192.168.117.135
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Version                     : 2.2(2c)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;WatchThreadStatus           : None
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;So, if we want to connect without this information being printed to the screen then we&amp;rsquo;ll need to accept the handle being returned from the cmdlet, as below:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ucs = Connect-UCS -Name ucspe01 -Credential (Get-Credential)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Credential can be prompted for by using the &amp;ldquo;(Get-Credential)&amp;rdquo; input above, or it can be provided ahead of time, by putting the output of &amp;ldquo;Get-Credential&amp;rdquo; into a variable.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$cred = Get-Credential
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ucs = Connect-Ucs -Name ucspe1 -Credential $cred
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;To disconnect, we use the cmdlet&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Disconnect-UCS -Ucs $ucs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;So building our function it will start to look as below. We are passing in the name of the UCS domain and the credentials to connect to it.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-NewUcsProfile {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $ucs_domain,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][System.Management.Automation.PSCredential] $credential = (Get-Credential)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Our code will go here
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$ucs = Connect-Ucs -Name $ucs_domain -Credential $credential
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($ucs -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Disconnect-Ucs -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;One thing to note here is that if a Credential is not provided, then the person running the script is prompted to provide one.&lt;/p&gt;
&lt;h3 id=&#34;creating-a-service-profile-from-a-template&#34;&gt;Creating a Service Profile from a template
&lt;/h3&gt;&lt;p&gt;One line of code is required to create a Service Profile based upon a template, and it takes the following parameters:&lt;/p&gt;
&lt;p&gt;- ServiceProfile is the name of the template upon which to base the new profile - NewName is the name of the new profile.&lt;/p&gt;
&lt;p&gt;It returns a object to represent the service profiles that it creates. An example:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$service_profile = Add-UcsServiceProfileFromTemplate -ServiceProfile &amp;#34;template-name&amp;#34; -NewName &amp;#34;new-profile&amp;#34; -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Note this this leaves the new profile bound to the template. We can change this later.&lt;/p&gt;
&lt;p&gt;We should do some sanity checking though - I&amp;rsquo;m sure you are aware of the two types of templates - &amp;ldquo;initial&amp;rdquo; and &amp;ldquo;updating&amp;rdquo; (if not, &lt;a class=&#34;link&#34; href=&#34;http://www.cisco.com/c/en/us/products/collateral/servers-unified-computing/ucs-manager/white_paper_c11-590518.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Cisco have a useful page on Service Profiles&lt;/a&gt;). These are represented in PowerShell by being a Service Profile object, but with a type of either &amp;ldquo;initial-template&amp;rdquo; or &amp;ldquo;updating-template&amp;rdquo;. A Service Profile object that is actually a Service Profile has a type of &amp;ldquo;instance&amp;rdquo;. So let&amp;rsquo;s make sure that a profile with this name exists:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$template = Get-UCSServiceProfile -Name &amp;#34;template-name&amp;#34; -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;This code is retrieving all service profiles of the name &amp;ldquo;template-name&amp;rdquo;. It then runs a check on them to see if they have type set to &amp;ldquo;instance&amp;rdquo;, and if so, the object is returned.&lt;/p&gt;
&lt;p&gt;If $template is equal to $null (i.e. $template -eq $null) then no template could be found. Putting our code together, outside of our function, it would look like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ucs = Connect-UCS -Name ucspe01 -Credential (Get-Credential)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;if ($ucs) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	$template = Get-UCSServiceProfile -Name &amp;#34;template-name&amp;#34; -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; };
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	if ($template -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$service_profile = Add-UcsServiceProfileFromTemplate -ServiceProfile $template -NewName &amp;#34;new-profile&amp;#34; -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Disconnect-UCS -UCS $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id=&#34;optional-unbinding-from-the-service-profile-template&#34;&gt;Optional: Unbinding from the Service Profile template
&lt;/h3&gt;&lt;p&gt;If you wish to unbind from the template, the line is simple:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Set-UcsServiceProfile -ServiceProfile $service_profile -SrcTemplName &amp;#39;&amp;#39; -Force | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Though we could pipe the $service_profile variable to it, as per:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$service_profile | Set-UcsServiceProfile -SrcTemplName &amp;#39;&amp;#39; -Force | out-null
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The &amp;ldquo;| out-null&amp;rdquo; just ensures that nothing is printed on the screen as it is being run.&lt;/p&gt;
&lt;h3 id=&#34;assembling-our-function&#34;&gt;Assembling our Function
&lt;/h3&gt;&lt;p&gt;From the above we need to know some things:&lt;/p&gt;
&lt;p&gt;- The name of the UCS domain to connect to. - The credentials to connect with. - The name of the Service Profile we want to create. - The name of the Template we are going to bind to.&lt;/p&gt;
&lt;p&gt;So when we put the code from above into the function, and configure our parameters, this is what it should look like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-NewUCSProfileFromTemplate {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Domain,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][System.Management.Automation.PSCredential] $Credential,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $new_profile_name,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $template_name
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$ucs = Connect-Ucs -Name $Domain -Credential $Credential
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($ucs -ne $null) {			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$template = Get-UCSServiceProfile -Name $template_name -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; };
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($template -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Add-UcsServiceProfileFromTemplate -ServiceProfile $template -NewName $new_profile_name -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		Disconnect-UCS $ucs;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;h3 id=&#34;organisations-and-checkingâprofile-existence&#34;&gt;Organisations and checkingÂ Profile existence
&lt;/h3&gt;&lt;p&gt;We&amp;rsquo;ve got one last check that we should make - that the service profile doesn&amp;rsquo;t already exist. This is slightly more complicated due to Organisations - service profile names are unique within each organisation. This is represented in service profile objects by distinguished names which are formed of two parts, the location and the service profile name. Running the code:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Get-UcsServiceProfile | ft Name, Rn, Dn
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;will show us the format:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PS C:\&amp;gt; get-ucsserviceprofile | ft Name, Rn, Dn
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name                                    Rn                                      Dn
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;---- -- --
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test                                    ls-test                                 org-root/ls-test
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;test                                    ls-test                                 org-root/org-Finance/ls-test
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;As we can see, we have two service profiles with the name &amp;ldquo;test&amp;rdquo;, one in the &amp;ldquo;root&amp;rdquo; organisation, and one in the &amp;ldquo;Finance&amp;rdquo; organisation. Let&amp;rsquo;s get the details about the organisations:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;PS C:\&amp;gt; Get-UcsOrg | ft Name, Dn
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Name                                                        Dn
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;---- --
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;root                                                        org-root
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Acme                                                        org-root/org-Acme
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Finance                                                     org-root/org-Finance
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;So when we create our profile we must make a choice about where we create it - by default it will be in the root organisation. Our code will have to take a string that allows callers to provide an organisation (but have a default of &amp;ldquo;root&amp;rdquo;). We will then search for the service profile within that organisation:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$existing_profile = Get-UcsServiceProfile -Name $sp_name -Org $org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;It looks simple, but there is a catch - it will still match against any service profiles in sub-organisations. We need to add the &amp;ldquo;-LimitScope&amp;rdquo; parameter in order to only match within our desired target organisation. If $existing_profile is equal to $null, then we can continue.&lt;/p&gt;
&lt;p&gt;So our function will now look like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-NewUCSProfileFromTemplate {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Domain,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][System.Management.Automation.PSCredential] $Credential,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $NewName,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[String] $Organisation = &amp;#34;root&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Template
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$ucs = Connect-Ucs -Name $Domain -Credential $Credential
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($ucs -ne $null) {			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$org = Get-UcsOrg $Organisation;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($org) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				# Check to see if profile already exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				$existing_sp = Get-UcsServiceProfile -Name $NewName -Org $org -LimitScope;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				if ($existing_sp -eq $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					# Check to see if template exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					$sp_template = Get-UCSServiceProfile -Name $Template -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; };
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					if ($sp_template -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;						$sp = Add-UcsServiceProfileFromTemplate -ServiceProfile $Template -NewName $NewName -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		Disconnect-UCS $ucs;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Note: Organisation names are not unique throughout the Domain and it is the Dn that will determine uniqueness. This is something that we&amp;rsquo;ll deal with next.&lt;/p&gt;
&lt;h3 id=&#34;one-final-step&#34;&gt;One Final Step
&lt;/h3&gt;&lt;p&gt;To make everything simple, we should do all our checks to see if any stage of this will fail at the start of code. For the sake of separation we&amp;rsquo;ll create a new function for this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;30
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;31
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;32
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;33
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;34
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;35
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;36
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;37
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;38
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;39
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;40
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;41
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-CheckUcsServiceProfileConflict {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][Cisco.Ucs.UcsHandle] $Ucs,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $NewName,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[String] $Organisation = &amp;#34;root&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Template
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$result = $True;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Check the Organisation exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$org = Get-UcsOrg $Organisation;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($org -eq $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;The Organisation does not exist.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		} elseif ($org.Count -gt 1) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# We found more than one Organisation
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;There is more than one Organisation with the name &amp;#39;$Organisation&amp;#39;. Please use the Org Dn to create Service Profiles.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		} else {		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Check that a profile with the existing name doesn&amp;#39;t already exist.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$existing_sp = Get-UcsServiceProfile -Name $NewName -Org $org -LimitScope;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($existing_sp -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Write-Host &amp;#34;A Service Profile with the name &amp;#39;$NewName&amp;#39; already exists in the organisation &amp;#39;$Organisation&amp;#39;.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Check that the template exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$sp_template = Get-UCSServiceProfile -Name $Template -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; };
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($sp_template -eq $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;The template $Template does not exist.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		return $result;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;There are a few differences to our original function - we are passing in the connection handle to the UCS Domain, so we don&amp;rsquo;t have to deal with any Connect-Ucs/Disconnect-Ucs and credentials. We are then going to run some checks and return whether we can go ahead with creating the service profile.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s go through the code:&lt;/p&gt;
&lt;p&gt;- We first get all the Organisations that have the name we supply. - If there are no Organisations then we output this to the user and ensure we will return failure. - We see if there is more than one Organisation with the name. - If there is one Organisation then we check to see if there is a service profile with the same name in it.&lt;/p&gt;
&lt;p&gt;- We check to see if the service profile template exists. - We return the result.&lt;/p&gt;
&lt;p&gt;This is where we are handling that we could have multiple Organisations could have the same name. If more than one is found, then we will fail and tell the person running our function to supply the Dn if they wish to continue.&lt;/p&gt;
&lt;p&gt;When we alter our original function to use this one to do checks, and put everything together, it looks as per the below:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt; 1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 2
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 3
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 4
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 5
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 6
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 7
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 8
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt; 9
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;10
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;11
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;12
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;13
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;14
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;15
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;16
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;17
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;18
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;19
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;20
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;21
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;22
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;23
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;24
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;25
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;26
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;27
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;28
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;29
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;30
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;31
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;32
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;33
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;34
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;35
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;36
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;37
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;38
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;39
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;40
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;41
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;42
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;43
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;44
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;45
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;46
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;47
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;48
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;49
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;50
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;51
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;52
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;53
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;54
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;55
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;56
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;57
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;58
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;59
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;60
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;61
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;62
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;63
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;64
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;65
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;66
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;67
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;68
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;69
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-CheckUcsServiceProfileConflict {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][Cisco.Ucs.UcsHandle] $Ucs,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $NewName,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[String] $Organisation = &amp;#34;root&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Template
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$result = $True;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Check the Organisation exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$org = Get-UcsOrg $Organisation;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($org -eq $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;The Organisation does not exist.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		} elseif ($org.Count -gt 1) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# We found more than one Organisation
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;There is more than one Organisation with the name &amp;#39;$Organisation&amp;#39;. Please use the Org Dn to create Service Profiles.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		} else {		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			# Check that a profile with the existing name doesn&amp;#39;t already exist.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$existing_sp = Get-UcsServiceProfile -Name $NewName -Org $org -LimitScope;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($existing_sp -ne $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				Write-Host &amp;#34;A Service Profile with the name &amp;#39;$NewName&amp;#39; already exists in the organisation &amp;#39;$Organisation&amp;#39;.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		# Check that the template exists.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$sp_template = Get-UCSServiceProfile -Name $Template -Ucs $ucs | ? { $_.type -ne &amp;#34;instance&amp;#34; };
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($sp_template -eq $null) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			Write-Host &amp;#34;The template $Template does not exist.&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$result = $False;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		return $result;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;Function Automate-NewUCSProfileFromTemplate {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Param(
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Domain,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][System.Management.Automation.PSCredential] $Credential = (Get-Credential),
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $NewName,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[String] $Organisation = &amp;#34;root&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		[Parameter(Mandatory=$true)][String] $Template
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	Process {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		$ucs = Connect-Ucs -Name $Domain -Credential $Credential
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		if ($ucs -ne $null) {			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			$checks_passed = Automate-CheckUcsServiceProfileConflict -Ucs $ucs -NewName $NewName -Organisation $Organisation -Template $Template;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			if ($checks_passed -eq $True) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				$sp = Add-UcsServiceProfileFromTemplate -ServiceProfile $Template -NewName $NewName -Ucs $ucs;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				if ($sp) {
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					Write-Host &amp;#34;Service Profile Created&amp;#34;;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					# If you want to unbind from the template then put the code here.
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;					Set-UcsServiceProfile -ServiceProfile $sp -SrcTemplName &amp;#39;&amp;#39; -Force | out-null;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;				}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;			}			
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;		Disconnect-UCS -Ucs $ucs;	
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;	}
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;And that&amp;rsquo;s it :). We now have some code that will create a UCS Service Profile from a template in a given organisation and will pass the obvious sanity checks.&lt;/p&gt;
&lt;p&gt;We can now create (or at least attempt to) a service profile by doing the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-fallback&#34; data-lang=&#34;fallback&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;C:\Scripts\&amp;gt;. .\automate.ps1
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;C:\Scripts\&amp;gt;Automate-NewUCSProfileFromTemplate -Domain ucspe01 -NewName server01 -Template init-windows
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;Next time, we&amp;rsquo;re going to get the HBA WWPNs and associate the service profile with a server.&lt;/p&gt;</description>
        </item>
        
    </channel>
</rss>
