<?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: Remove a datastore that is in use in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941030#M28420</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;invoke-command won't work here, would it?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or are there any cmdlets you know of to delete / format the partition, similar to what partedutil is doing? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hate the human error aspect having to do this at the canonical name level via SSH...&amp;nbsp; If I can automate it, that'd be much better! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Jul 2017 18:35:10 GMT</pubDate>
    <dc:creator>BenLiebowitz</dc:creator>
    <dc:date>2017-07-13T18:35:10Z</dc:date>
    <item>
      <title>Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941023#M28413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;So, we have some datastores we're looking to retire, however removing them from the web client gives us a "datastore is in use" error.&amp;nbsp; We worked with VMware support, and they gave us a bunch of partedutil commands, but I'd like to try and automate this to reduce the human error factor.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The commands to run are: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;partedUtil getptbl /vmfs/devices/disks/naa.1234567890&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;partedUtil delete /vmfs/devices/disks/naa.1234567890&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;Everything else I can do with get-scsilun&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;This is what I have so far... &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;1. connect to vcenter&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;2. list the clusters&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;3. list the hosts in the selected cluster&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;4. list the datastores/luns on the host&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;5. browse the foor of the datastore selected (to verify nothing is on it and it's the one to be removed)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;6. This would be where the partedutil commands go.&amp;nbsp; &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.vmware.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;----------------------&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# Define the LunDatastoreName function&lt;/P&gt;&lt;P&gt;New-VIProperty -Name lunDatastoreName -ObjectType ScsiLun -Value {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; param($lun)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $ds = $lun.VMHost.ExtensionData.Datastore | %{Get-View $_} | `&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where {$_.Summary.Type -eq "VMFS" -and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ($_.Info.Vmfs.Extent | where {$_.DiskName -eq $lun.CanonicalName})}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($ds){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $ds.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;} -Force | Out-Null&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="DE" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;SPAN lang="EN" style="font-family: Arial, sans-serif; color: #333333;"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# connect to selected vCenter&lt;/P&gt;&lt;P&gt;connect-viserver $vcenter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List Clusters&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which Cluster where the LUN you want to remove presented:"&lt;/P&gt;&lt;P&gt;write-host "(it may take a few seconds to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$ICLUSTER = get-cluster | Select Name | Sort-object Name&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$ICLUSTER | %{Write-Host $i":" $_.Name; $i++}&lt;/P&gt;&lt;P&gt;$HCLUSTER = Read-host "Enter the number for the host to Patch."&lt;/P&gt;&lt;P&gt;$SCLUSTER = $ICLUSTER[$HCLUSTER -1].Name&lt;/P&gt;&lt;P&gt;write-host "You have selected $($SCLUSTER)."&lt;/P&gt;&lt;P&gt;start-sleep -s 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List hosts to select&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which vSphere host that has the LUN presented."&lt;/P&gt;&lt;P&gt;write-host "(it may take a few seconds to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$IHOST = get-cluster $SCLUSTER | Get-VMhost | Select Name | Sort-object Name&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$IHOST | %{Write-Host $i":" $_.Name; $i++}&lt;/P&gt;&lt;P&gt;$DSHost = Read-host "Enter the number for the host to Patch."&lt;/P&gt;&lt;P&gt;$SHOST = $IHOST[$DSHost -1].Name&lt;/P&gt;&lt;P&gt;write-host "you have selected" $SHOST"."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List all scsi devices&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which LUN to remove.&amp;nbsp; *** VERIFY VIA THE vSPHERE CLIENT ***"&lt;/P&gt;&lt;P&gt;write-host "(it may take a minute to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$ILUN = get-scsilun -vmhost $SHOST | Select LunDatastoreName, CanonicalName, RuntimeName, CapacityGB | Sort lundatastorename&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$ILUN | %{Write-Host $i":" $_.lunDatastoreName, $_.RuntimeName, $_.CapacityGB; $i++}&lt;/P&gt;&lt;P&gt;$DSLUN = Read-host "Enter the number for the LUN to remove."&lt;/P&gt;&lt;P&gt;$SLUN = $ILUN[$DSLUN -1].LunDatastoreName&lt;/P&gt;&lt;P&gt;write-host "you have selected" $SLUN"."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List the files on the LUN you selected&lt;/P&gt;&lt;P&gt;get-childitem (get-datastore $SLUN).datastorebrowserpath&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 17:54:32 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941023#M28413</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-12T17:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941024#M28414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just wondering, can't you do the delete partition with the &lt;A href="https://vdc-repo.vmware.com/vmwb-repository/dcr-public/6b586ed2-655c-49d9-9029-bc416323cb22/fa0b429a-a695-4c11-b7d2-2cbc284049dc/doc/vim.host.StorageSystem.html#updateDiskPartitions"&gt;UpdateDiskPartitions&lt;/A&gt; method.&lt;/P&gt;&lt;P&gt;When you pass an empty Spec it erases all partitions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps worth asking Support if that achieves the same thing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 18:23:27 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941024#M28414</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-12T18:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941025#M28415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know it is silly to ask, but is the datastore used for heartbeating or do you have storage I/O control enabled? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 22:57:02 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941025#M28415</guid>
      <dc:creator>ITaaP</dc:creator>
      <dc:date>2017-07-12T22:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941026#M28416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That can easily be checked with my function from &lt;A href="http://www.lucd.info/2012/04/15/test-if-the-datastore-can-be-unmounted/"&gt;Test if the datastore can be unmounted&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 04:28:22 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941026#M28416</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-13T04:28:22Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941027#M28417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Luc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, this function is very helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It turns out, these datastores were configured to store local syslog data instead of using the scratch partition.&amp;nbsp; Once I changed them to scratch, I was able to delete the datastores. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.vmware.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 17:24:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941027#M28417</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-13T17:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941028#M28418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to run the partedutil commands via PowerCLI though?&amp;nbsp; I'm still getting "resource is in use" errors on two datastores.&amp;nbsp; I can browse and find nothing on them...&amp;nbsp; I may need to forcibly remove them. &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.vmware.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:19:51 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941028#M28418</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-13T18:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941029#M28419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Short of SSH-ing into the ESXi node, I'm afraid not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:33:07 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941029#M28419</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-13T18:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941030#M28420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;invoke-command won't work here, would it?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or are there any cmdlets you know of to delete / format the partition, similar to what partedutil is doing? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hate the human error aspect having to do this at the canonical name level via SSH...&amp;nbsp; If I can automate it, that'd be much better! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:35:10 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941030#M28420</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-13T18:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941031#M28421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I guess you mean Invoke-VMScript, but that only works against VMs, not ESXi nodes.&lt;/P&gt;&lt;P&gt;I don't know of any cmdlet that would have the same functionality as the partedutil.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The closest that is available to perform specific functions inside an ESXi node is through the Get-EsxCli cmdlet.&lt;/P&gt;&lt;P&gt;But for commands that are not available in esxcli (or Get-EsxCli for PowerCLI), most of the time one would have to revert to an SSH session.&lt;/P&gt;&lt;P&gt;And execute console commands through something like plink.exe (from the PuTTY Suite).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I don't remember seeing any API that offer this partedutil functionality.&lt;/P&gt;&lt;P&gt;I was hoping that the UpdateDiskPartitions method might do the trick, but obviously it doesn't.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:42:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941031#M28421</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-13T18:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941032#M28422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;in vSphere 6, they introduced an "erase partition" in the web client.&amp;nbsp; In the Hosts and Clusters view, go to a host, then Manage -&amp;gt; Storage - Storage Devices.&amp;nbsp; Find the LUN you want to erase and there's a button.&amp;nbsp; However, I'm getting the same in use error.&amp;nbsp; Oh well. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="erase_partition.PNG"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/73927i612080EABFB74099/image-size/large?v=v2&amp;amp;px=999" role="button" title="erase_partition.PNG" alt="erase_partition.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 18:58:08 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941032#M28422</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-13T18:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941033#M28423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps you have to be at a specific VMFS version for this to work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 19:11:44 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941033#M28423</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-13T19:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941034#M28424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Luc,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I decided to find another way to run the partedUtil command...&amp;nbsp; I'm not getting the same results as I do if I run it via SSH though.&amp;nbsp; Is there a better way to get the Canonical Name of a LUN? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# connect to selected vCenter&lt;/P&gt;&lt;P&gt;connect-viserver $vcenter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List Clusters&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which Cluster where the LUN you want to remove presented:"&lt;/P&gt;&lt;P&gt;write-host "(it may take a few seconds to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$ICLUSTER = get-cluster | Select Name | Sort-object Name&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$ICLUSTER | %{Write-Host $i":" $_.Name; $i++}&lt;/P&gt;&lt;P&gt;$HCLUSTER = Read-host "Enter the number for the host to Patch."&lt;/P&gt;&lt;P&gt;$SCLUSTER = $ICLUSTER[$HCLUSTER -1].Name&lt;/P&gt;&lt;P&gt;write-host "You have selected $($SCLUSTER)."&lt;/P&gt;&lt;P&gt;start-sleep -s 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List hosts to select&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which vSphere host that has the LUN presented."&lt;/P&gt;&lt;P&gt;write-host "(it may take a few seconds to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$IHOST = get-cluster $SCLUSTER | Get-VMhost | Select Name | Sort-object Name&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$IHOST | %{Write-Host $i":" $_.Name; $i++}&lt;/P&gt;&lt;P&gt;$DSHost = Read-host "Enter the number for the host to Patch."&lt;/P&gt;&lt;P&gt;$SHOST = $IHOST[$DSHost -1].Name&lt;/P&gt;&lt;P&gt;write-host "you have selected" $SHOST"."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List all scsi devices&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;Write-host "Choose which LUN to remove.&amp;nbsp; *** VERIFY VIA THE vSPHERE CLIENT ***"&lt;/P&gt;&lt;P&gt;write-host "(it may take a minute to build the list)"&lt;/P&gt;&lt;P&gt;write-host ""&lt;/P&gt;&lt;P&gt;$ILUN = get-scsilun -vmhost $SHOST | Select LunDatastoreName, CanonicalName, RuntimeName, CapacityGB | Sort lundatastorename&lt;/P&gt;&lt;P&gt;$i = 1&lt;/P&gt;&lt;P&gt;$ILUN | %{Write-Host $i":" $_.lunDatastoreName, $_.RuntimeName, $_.CapacityGB; $i++}&lt;/P&gt;&lt;P&gt;$DSLUN = Read-host "Enter the number for the LUN to remove."&lt;/P&gt;&lt;P&gt;$SLUN = $ILUN[$DSLUN -1].LunDatastoreName&lt;/P&gt;&lt;P&gt;write-host "you have selected" $SLUN"."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# List the files on the LUN you selected&lt;/P&gt;&lt;P&gt;get-childitem (get-datastore $SLUN).datastorebrowserpath&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Check to see if the datastore is in use&lt;/P&gt;&lt;P&gt;Get-DatastoreUnmountStatus -datastore $SLUN&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Pipe datastore to get-scsilun to get canonicalname&lt;/P&gt;&lt;P&gt;$LUN = Get-Datastore $SLUN | get-scsilun | Select CanonicalName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Start SSH&lt;/P&gt;&lt;P&gt;$ssh = Get-VMHostService -vmhost $SHOST | Where {$_.Key -eq "TSM-SSH"}&lt;/P&gt;&lt;P&gt;Start-VMHostService -HostService ($ssh) -Confirm:$false &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Remove the 99bnx2fc.sh file.&lt;/P&gt;&lt;P&gt;$User = "root"&lt;/P&gt;&lt;P&gt;$Pswd = "Password1!"&lt;/P&gt;&lt;P&gt;$plink = "c:\plink.exe"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$plinkoptions = " -v -batch -pw $Pswd"&lt;/P&gt;&lt;P&gt;$cmd1 = 'partedUtil getptbl /vmfs/devices/disks/$LUN'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$remoteCommand = '"' + $cmd1 + '"'&lt;/P&gt;&lt;P&gt;$command = $plink + " " + $plinkoptions + " " + $User + "@" + $SHOST + " " + $remoteCommand&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$msg = Invoke-Expression -command $command&lt;/P&gt;&lt;P&gt;$msg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Stop SSH&lt;/P&gt;&lt;P&gt;Stop-VMHostService -HostService ($ssh) -Confirm:$false&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:25:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941034#M28424</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-17T12:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941035#M28425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You mean not using the Get-ScsiLun cmdlet?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:39:34 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941035#M28425</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-17T12:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941036#M28426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes.&amp;nbsp; When I run the command in the script above, it lists the canonical name mulitple times, so when I pipe it into a variable, I'm not sure it's being read properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$LUN = Get-Datastore Datastore1 | get-scsilun | Select CanonicalName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I do $LUN alone, I get this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="2017-07-17 08_49_55-Administrator_ PowerShell NYVMXVCPRD05.png"&gt;&lt;img src="https://communities.vmware.com/t5/image/serverpage/image-id/74000i29D690AEC9950252/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-07-17 08_49_55-Administrator_ PowerShell NYVMXVCPRD05.png" alt="2017-07-17 08_49_55-Administrator_ PowerShell NYVMXVCPRD05.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are multiple hosts attached, as you can see. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I need it to be just 1 line... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 12:53:35 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941036#M28426</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-17T12:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941037#M28427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got it, try like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="text-align: Left; font-family: Segoe UI; font-style: normal; font-weight: normal; font-size: 12; color: #000000;"&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 16;"&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #ff4500;"&gt;&lt;SPAN&gt;$LUN&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #a9a9a9;"&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;Get-Datastore&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8a2be2;"&gt;&lt;SPAN&gt;Datastore1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #a9a9a9;"&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;get-scsilun&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #a9a9a9;"&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;SPAN&gt;Select&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;SPAN&gt;-First&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;&lt;SPAN&gt;-ExpandProperty&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #8a2be2;"&gt;&lt;SPAN&gt;CanonicalName&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: Lucida Console; margin: 0 0 0 0; background-color: #ffffff;"&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:12:27 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941037#M28427</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2017-07-17T13:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a datastore that is in use</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941038#M28428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That got me a single line, thanks!&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jul 2017 13:16:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Remove-a-datastore-that-is-in-use/m-p/941038#M28428</guid>
      <dc:creator>BenLiebowitz</dc:creator>
      <dc:date>2017-07-17T13:16:46Z</dc:date>
    </item>
  </channel>
</rss>

