<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DRS Archives - LucD notes</title>
	<atom:link href="https://www.lucd.info/category/vsphere/drs/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/category/vsphere/drs/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Wed, 08 Apr 2020 10:59:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.lucd.info/wp-content/uploads/2018/12/cropped-120px-Tibetan_Dharmacakra-32x32.png</url>
	<title>DRS Archives - LucD notes</title>
	<link>https://www.lucd.info/category/vsphere/drs/</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/>	<item>
		<title>Optimize-VMwarePKS</title>
		<link>https://www.lucd.info/2019/04/03/optimize-vmwarepks/</link>
					<comments>https://www.lucd.info/2019/04/03/optimize-vmwarepks/#comments</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Wed, 03 Apr 2019 19:29:51 +0000</pubDate>
				<category><![CDATA[DRS]]></category>
		<category><![CDATA[Folder]]></category>
		<category><![CDATA[PKS]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Optimise]]></category>
		<guid isPermaLink="false">http://www.lucd.info/?p=6336</guid>

					<description><![CDATA[A guest post Over the last couple of weeks, it has been my [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">A guest post</h3>



<p>Over the last couple of weeks, it has been my great pleasure to assist  <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://twitter.com/chipzoller" target="_blank">Chip Zoller</a> in writing a <a rel="noreferrer noopener" aria-label="VMware PowerCLI (opens in a new tab)" href="https://communities.vmware.com/community/vmtn/automationtools/powercli" target="_blank">VMware PowerCLI</a> script, named <a rel="noreferrer noopener" aria-label="Optimize-VMwarePKS (opens in a new tab)" href="https://github.com/chipzoller/Optimize-VMwarePKS" target="_blank">Optimize-VMwarePKS</a>. This script helps organise your PKS deployment at three levels: folders, tags and DRS rules, including functionality to run a clean up.</p>



<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="858" height="546" src="https://www.lucd.info/wp-content/uploads/2019/03/pks-pcli.png" alt="" class="wp-image-6337" srcset="https://www.lucd.info/wp-content/uploads/2019/03/pks-pcli.png 858w, https://www.lucd.info/wp-content/uploads/2019/03/pks-pcli-300x191.png 300w, https://www.lucd.info/wp-content/uploads/2019/03/pks-pcli-768x489.png 768w, https://www.lucd.info/wp-content/uploads/2019/03/pks-pcli-720x458.png 720w" sizes="(max-width: 858px) 100vw, 858px" /><figcaption>VMware PKS</figcaption></figure>



<p>The following post by Chip describes the function in greater detail, and shows how you can use it. </p>



<p>This post also appears on the <strong>Sovereign Systems</strong> website as <a rel="noreferrer noopener" aria-label="Optimize-VMwarePKS: A PowerShell Script for All Your VMware PKS Deployment Needs (opens in a new tab)" href="https://www.sovsystems.com/optimize-vmwarepks-a-powershell-script-for-all-your-vmware-pks-deployment-needs/" target="_blank">Optimize-VMwarePKS: A PowerShell Script for All Your VMware PKS Deployment Needs</a>.</p>



<p>Take it away Chip.</p>



<span id="more-6336"></span>



<h2 class="wp-block-heading">Optimize-VMwarePKS: A
PowerShell script for all your VMware PKS deployment needs</h2>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ever since
VMware PKS (now called Enterprise PKS) came onto the market over a year ago,
it’s been a big hit. With it, you get upstream Kubernetes, NSX-T, an enterprise-class
container registry, automation of the entire K8s cluster creation process, and
lots more all on top of the de facto private cloud platform of vSphere. It’s
truly becoming the way organizations are standardizing on K8s cluster
instantiation, upgrade, and management on-premises. The deployment nodes
themselves are regular virtual machines. And, like all virtual machines, you
and your company probably have an established way of organizing those VMs.
While Enterprise PKS takes care of a lot of tasks automatically, one thing that
we still need to consider is how those VMs get organized. So, as a joint effort
between myself and <a href="https://twitter.com/LucD22">Luc Dekens</a>, we’re
glad to announce today a new script called <strong>Optimize-VMwarePKS</strong>
which is designed to bring that level of optimization to your vSphere and PKS
clusters. Specifically, this script is designed to optimize your PKS
deployments in three ways: vSphere folders, vSphere tags, and DRS rules–with
clean-up for three of these. Read on to see this in action and learn how you
can greatly simplify deployment of PKS clusters in your own environment.</p>



<h3 class="wp-block-heading"><strong>FOLDERS</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </h3>



<p>As mentioned, PKS deploys K8s nodes
as simple VMs into your vSphere environment. After a single deployment, you may
see something like this in your vSphere Client.</p>



<figure class="wp-block-image"><img decoding="async" width="317" height="165" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-35-40.png" alt="" class="wp-image-6338" srcset="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-35-40.png 317w, https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-35-40-300x156.png 300w" sizes="(max-width: 317px) 100vw, 317px" /></figure>



<p>All VMs are, as you can see, named with IDs that are doled
out by PKS and BOSH, and tracked internally. They probably look very different
from the internal naming standard you’ve developed, right? Although we shouldn’t
change the names of the VMs, we can do other things. The first feature of <strong>Optimize-VMwarePKS</strong> is the ability to place
all VMs from a given deployment automatically into a folder based on that name.
In so doing, the above screenshot now looks like this after optimization:</p>



<figure class="wp-block-image"><img decoding="async" width="367" height="311" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-59-11.png" alt="" class="wp-image-6339" srcset="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-59-11.png 367w, https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_16-59-11-300x254.png 300w" sizes="(max-width: 367px) 100vw, 367px" /></figure>



<p>As you can see, these folder names align with the PKS
cluster names perfectly if we examine them with a pks clusters
command. In fact, <strong>Optimize-VMwarePKS</strong>
is designed to take this information directly from the PKS CLI tool, which is a
requirement for the script (see later).</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="658" height="86" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-00-30.png" alt="" class="wp-image-6340" srcset="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-00-30.png 658w, https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-00-30-300x39.png 300w" sizes="auto, (max-width: 658px) 100vw, 658px" /></figure>



<p>The nice thing about this script is </p>



<ol class="wp-block-list"><li>it’s very easy to operate (simply add the –ProcessFolders switch)</li><li>it’s idempotent so will keep this organization
no matter how many times you run it.</li></ol>



<h3 class="wp-block-heading"><strong>TAGS</strong></h3>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The second
feature of <strong>Optimize-VMwarePKS</strong> to highlight
is the ability to assign vSphere Tags to all of the VMs that form a given PKS
deployment. Tags are often used to provide a form of organization that may
exist alongside or independent of vSphere folders. These tags are, again by
default, created based on the name of the PKS cluster and automatically created
and assigned to all VMs part of a cluster. With a tag category of your choice
(or by accepting the default category of ‘PKS’), the script will detect your
clusters, create a new appropriate tag in the tag category, and assign that tag
to all VMs.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="187" height="232" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-11-01.png" alt="" class="wp-image-6341"/></figure>



<p>As you can see here, the script has created two tags for us
that match the names of our clusters. If we inspect the VMs within those
clusters, we can see it’s been correctly assigned as well.</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="689" height="278" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-12-03.png" alt="" class="wp-image-6342" srcset="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-12-03.png 689w, https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-12-03-300x121.png 300w" sizes="auto, (max-width: 689px) 100vw, 689px" /></figure>



<p>This optimization is easily enabled with the -ProcessTags switch.</p>



<h3 class="wp-block-heading"><strong>DRS RULES</strong></h3>



<p>            Since PKS has the ability to deploy HA K8s clusters–which is a tremendous strength and huge time saver–it automatically provisions multiple masters and places them behind an NSX-T load balancer. These masters then serve as the API entry point for all K8s-related commands. Masters can be spread out across multiple Availability Zones (AZ). Where AZs map directly onto distinct vSphere clusters, this provides a sufficient level of fault isolation. But in the case where either multiple Azs aren’t in use or they do not align to separate compute clusters, Enterprise PKS will place all masters on the same cluster. Optimize-VMwarePKS can therefore be used to build DRS anti-affinity rules to provide such separation.</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; In my
previous screenshots, you’ve noticed I have a single small cluster (1 master; 3
workers) and a large cluster (3 masters; 3 workers). If we run the script with
the -ProcessDRSRules switch, it will
automatically find those masters and create a DRS anti-affinity rule for us.
And not to worry, it’ll only create the rule with the masters of each cluster,
so multiple HA clusters get individual DRS rules created. See below. Even
better, the script is written in a future-proof way in that when VMware/Pivotal
support larger multi-master clusters in the future, if you scaled out masters
the script will detect the increase and update the rule for you!</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="527" height="592" src="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-19-04.png" alt="" class="wp-image-6343" srcset="https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-19-04.png 527w, https://www.lucd.info/wp-content/uploads/2019/03/2019-03-24_17-19-04-267x300.png 267w" sizes="auto, (max-width: 527px) 100vw, 527px" /></figure>



<p>These abilities are, as I hope you’ll agree, extremely
useful in order to not only fill some gaps but bring VMware PKS deployments
into alignment with your vSphere policies today. But there’s one thing missing
that we haven’t covered yet. Kubernetes clusters may come and go (another big
win for Enterprise PKS is the automatic roll-back of NSX-T objects!), and when
they do we want to ensure we aren’t leaving behind elements that are no longer
relevant. So the last portion of <strong>Optimize-VMwarePKS</strong>
is its ability to automatically maintain a tidy house.</p>



<h3 class="wp-block-heading"><strong>TIDYING UP</strong></h3>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Each of the
three optimizations shown previously (folders, tags, and DRS rules) can be
switched on independently. And with each one, except DRS rules, if a cluster
gets deleted we’d have some clean-up work to do. So the script has also been
written with switches that you can (optionally, of course) automate the
clean-up of these objects. We’re talking here about tidying up of vSphere
folders and vSphere tags. By adding the -TidyFolders
and/or -TidyTags switches, <strong>Optimize-VMwarePKS</strong> will search for these empty folders and tags and
remove them for you. But, not to fear, it will *only* do this if you’ve
provided these switches and also only consider the parent vSphere folder or tag
category for clean-up. That means it won’t scour your entire estate and remove
anything else.</p>



<h3 class="wp-block-heading"><strong>IDEMPOTENCE</strong></h3>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lastly, and
before we look at some running examples, is to point out the idempotent nature
of this script. Because you may have many groups of people bring up and down
PKS deployments, you need something that can maintain a ready state of what you
define, similar to tools like Ansible, Puppet, and Chef. Being able to schedule
this script is one of the main reasons it was written, and in so doing it must
be made idempotent. No matter how many times you run the script, it always
checks if things exist before making a change. You can be confident that when
you ask it to run with whatever parameters that it’ll maintain that state
exactly. So no fear if someone drops a tag or moves a VM out of a folder. Next
time it runs it’ll put it right back where it was.</p>



<h3 class="wp-block-heading"><strong>RUNNING
OPTIMIZE-VMWAREPKS</strong></h3>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Now you’re
aware of all its capabilities, let’s quickly look at what’s needed to run it
and then an example on how to run it.</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The script
needs PowerShell, <a href="https://www.powershellgallery.com/packages/VMware.PowerCLI/">VMware PowerCLI</a>,
and the <a href="https://network.pivotal.io/products/pivotal-container-service">PKS
CLI binary tool</a>, all of which are cross-platform at this point. In fact, it
has been tested running directly from the Pivotal Operations Manager appliance
running Ubuntu with <a href="https://github.com/PowerShell/PowerShell">PowerShell
Core</a> but runs perfectly fine from a Windows control machine as well. The
PKS CLI tool needs to be added to your PATH. You also must ensure you have
credentials and network connectivity to access both vCenter Server and PKS.</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Now you
have the prereqs, time to actually run this script. Grab it from the <a href="https://github.com/chipzoller/Optimize-VMwarePKS">GitHub repo here</a>. For
your convenience (and so you don’t have to either read a blog or inspect the
code), extensive help has been provided on how to operate the script, its
parameters, but some examples.</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; All the
switches can be run independently, so you can mix and match whatever
functionality you like and only it will run. If we want to let it process
folders, tags, and DRS rules for us, we could call it like so:</p>



<pre class="wp-block-code"><code>$secvCPass = ConvertTo-SecureString -String 'VMware1!' -asPlainText -Force
$credvC = New-Object System.Management.Automation.PSCredential('administrator@vsphere.local',$secvCPass)
$secPKSPass = ConvertTo-SecureString -String 'VMware1!' -asPlainText -Force
$credPKS = New-Object System.Management.Automation.PSCredential('myuser',$secPKSPass)

./Optimize-VMwarePKS.ps1 -ProcessFolders -ProcessTags -ProcessDRSRules -vCenter $vc -vCenterCredential $credvC -PKSSever $pks -PKSCredential $credPKS -Verbose</code></pre>



<p>We have to pass a PSCredential object to the script, and so
the lines before actually running it do that for us.</p>



<p>If all you wanted was to clean-up (tidy) those objects, run
it with only those flags set:</p>



<pre class="wp-block-code"><code>./Optimize-VMwarePKS.ps1 -TidyFolders -TidyTags -vCenter $vc -vCenterCredential $credvC -PKSSever $pks -PKSCredential $credPKS</code></pre>



<p>Or, combine all flags into a single command:</p>



<pre class="wp-block-code"><code>./Optimize-VMwarePKS.ps1 -ProcessFolders -ProcessTags -ProcessDRSRules -TidyFolders -TidyTags -vCenter $vc -vCenterCredential $credvC -PKSSever $pks -PKSCredential $credPKS</code></pre>



<p>As far as managing the parameters needed, one of the most
convenient ways is with <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-6">splatting</a>
in PowerShell. We can write a script, call it “wrapper.ps1” and put all
parameters inside of it as shown below. Note that with splatting, we must set
the values to “true” unlike when passing the switches to the script directly. The
final line simply calls <strong>Optimize-VMwarePKS</strong>
for us passing the entire splat as an argument.</p>



<pre class="wp-block-code"><code>$vCUser = 'myuser@mydomain.com'
$vCPass = 'VMware1!' | ConvertTo-SecureString -asPlainText -Force
$PKSUser = 'myuser'
$PKSPass = 'VMware1!' | ConvertTo-SecureString -asPlainText -Force

$params = @{
ProcessFolders = $true
ProcessTags = $true
ProcessDRSRules = $true
TidyFolders = $true
TidyTags = $true
vCenter = 'myvcenter.mydomain.com'
PKSServer = 'mypks.mydomain.com'
vCenterCredential = New-Object System.Management.Automation.PSCredential($vCUser,$vCPass)
PKSCredential = New-Object System.Management.Automation.PSCredential($PKSUser,$PKSPass)
}

/home/ubuntu/Optimize-VMwarePKS.ps1 @params</code></pre>



<p>And, as mentioned earlier, because this script is entirely
idempotent, it can easily be scheduled with either cron, Windows task
scheduler, or any other mechanism you want. This will ensure your environment
is kept optimized based on your rules and patterns with no manual clean-up
required.</p>



<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I hope you find this script to be valuable in your environments. If so, we’d love to hear about it and you can drop either Luc or Chip a line on Twitter at <a href="https://twitter.com/LucD22" target="_blank" rel="noreferrer noopener" aria-label="@LucD22 (opens in a new tab)">@LucD22</a> or <a rel="noreferrer noopener" aria-label="@chipzoller (opens in a new tab)" href="https://twitter.com/chipzoller" target="_blank">@chipzoller</a> respectively.</p>



<hr class="wp-block-separator"/>



<p>Thanks Chip.<br></p>



<p>Enjoy!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/2019/04/03/optimize-vmwarepks/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>DRSRule &#8211; a DRS rules and groups module</title>
		<link>https://www.lucd.info/2015/01/22/drsrule-drs-rules-and-groups-module/</link>
					<comments>https://www.lucd.info/2015/01/22/drsrule-drs-rules-and-groups-module/#comments</comments>
		
		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Thu, 22 Jan 2015 15:00:14 +0000</pubDate>
				<category><![CDATA[Affinity]]></category>
		<category><![CDATA[Anti-affinity]]></category>
		<category><![CDATA[DRS]]></category>
		<category><![CDATA[Group]]></category>
		<category><![CDATA[Host]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Rule]]></category>
		<category><![CDATA[VM]]></category>
		<category><![CDATA[vSphere]]></category>
		<category><![CDATA[anti-affinity]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[Module]]></category>
		<category><![CDATA[PowerCLI]]></category>
		<category><![CDATA[rule]]></category>
		<guid isPermaLink="false">http://www.lucd.info/?p=4852</guid>

					<description><![CDATA[One of the nice vSphere features is the ability to define DRS rules. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One of the nice vSphere features is the ability to define <a href="http://pubs.vmware.com/vsphere-55/topic/com.vmware.vsphere.resmgmt.doc/GUID-FF28F29C-8B67-4EFF-A2EF-63B3537E6934.html" target="_blank" rel="noopener noreferrer">DRS rules</a>.</p>
<p><a href="https://www.lucd.info/2015/01/22/drsrule-drs-rules-and-groups-module/drsrule-intro/" rel="attachment wp-att-4854"><img loading="lazy" decoding="async" class="aligncenter wp-image-4854" src="https://lucd.info/wp-content/uploads/2015/01/DRSRule-intro.png" alt="DRSRule-intro" width="490" height="315" srcset="https://www.lucd.info/wp-content/uploads/2015/01/DRSRule-intro.png 659w, https://www.lucd.info/wp-content/uploads/2015/01/DRSRule-intro-300x193.png 300w" sizes="auto, (max-width: 490px) 100vw, 490px" /></a>The feature allows a vSphere administrator to control the placement of virtual machines in a vSphere cluster. There are the <strong>VM to VM</strong> <strong>affinity</strong> and <strong>anti-affinity</strong> rules, and the newer <strong>VM to VMHost</strong> rules. With the VM to VMHost rules, vSphere introduced the concept of <strong>VM</strong> and <strong>VMHost groups</strong>, and the ability to have rules that are a <strong>requirement</strong> (&#8216;shall&#8217;) or a <strong>preference</strong> (&#8216;should&#8217;).</p>
<p>In a recent <a href="https://communities.vmware.com/community/vmtn/automationtools/powercli" target="_blank" rel="noopener noreferrer">VMTN PowerCLI community</a> thread a <a href="https://communities.vmware.com/people/EdZ314" target="_blank" rel="noopener noreferrer">PowerCLI user</a> had a query about <a href="https://communities.vmware.com/message/2271796#2271796" target="_blank" rel="noopener noreferrer">exporting and importing DRS rules and groups</a>. At that point <a href="https://twitter.com/mtboren" target="_blank" rel="noopener noreferrer">Matt Boren</a> and myself developed the idea to provide a PowerShell module. The PowerShell module, which we named <a href="https://github.com/PowerCLIGoodies/DRSRule">DRSRule</a>, provides all the functions we deemed useful for working with DRS rules and groups. And yes, the module includes an <strong>export</strong> and an <strong>import</strong> cmdlet !</p>
<p><span id="more-4852"></span></p>
<p><a href="https://twitter.com/mtboren" target="_blank" rel="noopener noreferrer">Matt Boren</a>, famous for the high quality posts on his <a href="https://www.vnugglets.com/" target="_blank" rel="noopener noreferrer">vNugglets blog</a>, and myself, started working on the module, and after some late evenings and long weekends, we now have a first version we want to make public.</p>
<p>There are already many blogposts on the subject of DRS rules and groups. Including some excellent PowerCLI posts. The first one that springs to mind is <a href="https://twitter.com/avlieshout">Arnim</a>&#8216;s excellent <a href="https://www.van-lieshout.com/2011/06/drs-rules/" target="_blank" rel="noopener noreferrer">Managing VMware DRS rules using PowerCLI</a>.</p>
<p>And don&#8217;t forget to read <a href="https://www.vnugglets.com/2015/01/drsrule-new-powershell-module-for-drs.html">Matt&#8217;s post</a> on the DRSRule module as well.</p>
<p>To get you on your way with the DRSRule module, Matt and myself compiled the following introductory text.</p>
<h2>Why the DRSRule module?</h2>
<p>The core <strong>PowerCLI </strong>from VMware allows for many of the DRS rule operations that one might want to perform.  There have been questions over the years in the <a href="https://communities.vmware.com/community/vmtn/automationtools/powercli" target="_blank" rel="noopener noreferrer">VMware Communities PowerCLI</a> forum about how to export DRS rules and groups, and, on how to then import such items.</p>
<p>While there are several posts on the web about how to get/export such things, importing/recreating DRS rules/groups from such exported data has not received much focus.  This was the spark for this DRSRule module:  to allow for easy export/import of such rules/groups.  As part of making a module to handle these actions, other cmdlets were born, like the <strong>Get-/New-/Remove-/Set-*</strong> cmdlet sets for DRS <strong>VM groups</strong> and <strong>VMHost groups</strong>, along with sets for DRS VM to VM rules and VM to VMHost rules.</p>
<h2>How to use the DRSRule module?</h2>
<p>The DRSRule module comes with an <a href="http://raw.githubusercontent.com/PowerCLIGoodies/DRSRule/master/About_DRSRule.help.txt">about_DRSRule</a>.<br />
Once the module is installed, use that help topic to get a general introduction to the use of the DRSRule module:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Get-Help about_DRSRule</pre><p></p>
<h2>How to get the DRSRule module ?</h2>
<p>The source for this PowerShell module is hosted on <a href="https://github.com/">GitHub.com</a>.<br />
The repository is managed by the GitHub organization <a href="https://github.com/PowerCLIGoodies" target="_blank" rel="noopener noreferrer">PowerCLIGoodies</a>, and in there is the <a href="https://github.com/PowerCLIGoodies/DRSRule">DRSRule repository</a> itself.</p>
<p>There are a couple of ways to get the module, and use it in your PowerShell session:</p>
<h3>Automated</h3>
<h4>Via a script</h4>
<p>Use a PowerShell script to perform the download and the extract.<br />
The script is included in the repository as file <a href="https://raw.githubusercontent.com/PowerCLIGoodies/DRSRule/master/DownloadLatest.ps1" target="_blank" rel="noopener noreferrer">DownloadLatest.ps1</a>.</p>
<h4>Via PsGet</h4>
<p>If you have the <a href="https://psget.net/" target="_blank" rel="noopener noreferrer">PsGet</a> module loaded in your PowerShell session, then installing this DRSRule module is as simple as updating PsGet and then installing DRSRule:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Update-Module -Verbose -Module PsGet
Install-Module DRSRule</pre><p></p>
<h3>Manual</h3>
<p>Grab the <a href="https://github.com/PowerCLIGoodies/DRSRule/archive/Latest.zip" target="_blank" rel="noopener noreferrer">latest version</a> from the GitHub repository.<br />
Extract the content to a suitable folder.</p>
<p>You can go for the Modules folder linked to the Windows account you are using. To find this path, run:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Join-Path ${env:\userprofile} &quot;Documents\WindowsPowerShell\Modules&quot;)</pre><p></p>
<p>Or you can select any other folder.</p>
<p>Either way you will end up with a folder named <strong>[pathToModule]\DRSRule</strong>, in which the PowerShell files for the <strong>DRSRule module</strong> reside.</p>
<p>Then, load the DRSRule module into your session.</p>
<p>If you selected one of the folders in $env:PSModulePath (your PSModule path), you can do this with</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Import-Module DRSRule</pre><p></p>
<p>If you picked another folder, you should use the full path to the folder that contains the module&#8217;s files, like:</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Import-Module [PathToModule]\DRSRule</pre><p></p>
<p>Please also read the note below about using <strong>Unblock-File</strong>, since this module is not Authenticode signed.</p>
<h2>Note on Unblock-File</h2>
<p>Since there is no <strong>Authenticode</strong> certificate supplied for this module, and, assuming that one&#8217;s PowerShell ExecutionPolicy is at least <strong>RemoteSigned</strong>, below is a quick/easy way to unblock files.  But, this should only be done when you trust the code in the files that you are unblocking &#8212; inspecting the files is for your own good.</p>
<p></p><pre class="urvanov-syntax-highlighter-plain-tag">Get-ChildItem [pathToModules]\DRSRule | Unblock-File</pre><p></p>
<p>The DRSRule module was set up as community resource, so we are hoping to see your comments, suggestions and code.</p>
<p>Enjoy !</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lucd.info/2015/01/22/drsrule-drs-rules-and-groups-module/feed/</wfw:commentRss>
			<slash:comments>56</slash:comments>
		
		
			</item>
	</channel>
</rss>
