<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Add multiple disks on different datastores in vSphere Update Manager PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690303#M674</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are the master LucD!! Thanks a lot mate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 May 2014 10:18:21 GMT</pubDate>
    <dc:creator>online11</dc:creator>
    <dc:date>2014-05-13T10:18:21Z</dc:date>
    <item>
      <title>Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690297#M668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone, I am new to scripting. I am trying to script adding disks to different datastores on different hosts (not clustered). Lets say I have VMs called VM1 and VM2 I get this info from adddisk.txt file. I want to add disks to those VMs but I don't know the datastore name under specific host. If VM1 is under Host1, then datastore name is : Datastore1 IF VM2 is under Host2, then datastore name is : Datastore2 So how can I add disks to multiple VMs without knowing the datastore name? $servers = Get-Content "C:\Scripts\AddDisk\adddisk.txt" New-HardDisk -VM&amp;nbsp; $servers -CapacityGB&amp;nbsp; 30 -DiskType Flat -Datastore "DatasoreName" -StorageFormat Thin Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 12:01:12 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690297#M668</guid>
      <dc:creator>online11</dc:creator>
      <dc:date>2014-05-12T12:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690298#M669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can find the host a VM is on like this&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;$hostname = Get-VM -Name $vmName | Get-VMHost | Select -ExpandProperty Name&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;You can now test on te hostname&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;if($hostname -like "*1$"){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; $dsname = "datastore1"&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;elseif($hostname -like "*2$"){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; $dsname = "datastore2"&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;There are of course many other ways to accomplish the same, but this is in my opinion one of the most simple ones.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 16:20:04 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690298#M669</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-05-12T16:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690299#M670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi LucD, thanks for your reply. according to your reply I have updated the script. Now looks like this. Please see attached jpeg. &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="script.JPG"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/51973iA53C9B6C12261399/image-size/large?v=v2&amp;amp;px=999" role="button" title="script.JPG" alt="script.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Sorry to ask here cause I am really new to scripting.&lt;/P&gt;&lt;P&gt;If I have 4 VMs here.&lt;/P&gt;&lt;P&gt;VM1 and VM2 on ESX3&lt;/P&gt;&lt;P&gt;VM3 and VM4 on ESX4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This script adds new disk to VM1 and VM2 but not adding on VM3 and VM4. Error message says Invalid configuration&amp;nbsp; for device "0"&lt;/P&gt;&lt;P&gt;Can you spot why?&lt;/P&gt;&lt;P&gt;Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 08:09:03 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690299#M670</guid>
      <dc:creator>online11</dc:creator>
      <dc:date>2014-05-13T08:09:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690300#M671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What exactly do you have in the adddisk.txt file ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 08:12:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690300#M671</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-05-13T08:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690301#M672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="add.JPG"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/51974iE1EC92779F27BADB/image-size/large?v=v2&amp;amp;px=999" role="button" title="add.JPG" alt="add.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;addisk.txt&amp;nbsp; contains VM1 VM2 VM3 VM4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 08:42:22 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690301#M672</guid>
      <dc:creator>online11</dc:creator>
      <dc:date>2014-05-13T08:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690302#M673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #5f9ea0;"&gt;Get-Contentt&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; text-decoration: underline;"&gt;c:\Script\adddisk.txt&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;|&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;%&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;{&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$hostname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;Get-VM&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-Name&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;$_&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;|&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;Get-VMHost&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;|&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;Select&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-ExpandProperty&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;Name&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$hostname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;-eq&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000;"&gt;"esx3"&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$dsname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000;"&gt;"Datastore3"&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;elseif&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$hostname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;-eq&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000;"&gt;"esx4"&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;){&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$dsname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000;"&gt;"Datastore4"&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;New-HardDisk&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-VM&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;$_&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-CapacityGB&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;5&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-DiskType&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;Flat&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-Datastore&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;$dsname&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #5f9ea0;"&gt;-StorageFormat&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;Thin&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Get-Content will read the file line by line.&lt;/P&gt;&lt;P&gt;We execute the codeblock for each line (the ForEach construct - the alias is %)&lt;/P&gt;&lt;P&gt;Testing on equality of strings is done with the -eq operator, the = operator is only used for assignments.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 08:54:41 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690302#M673</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2014-05-13T08:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add multiple disks on different datastores</title>
      <link>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690303#M674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are the master LucD!! Thanks a lot mate.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 10:18:21 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/vSphere-Update-Manager-PowerCLI/Add-multiple-disks-on-different-datastores/m-p/2690303#M674</guid>
      <dc:creator>online11</dc:creator>
      <dc:date>2014-05-13T10:18:21Z</dc:date>
    </item>
  </channel>
</rss>

