<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: Folder by Path	</title>
	<atom:link href="https://www.lucd.info/2012/05/18/folder-by-path/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lucd.info/2012/05/18/folder-by-path/</link>
	<description>My PowerShell ramblings</description>
	<lastBuildDate>Wed, 08 Jan 2025 15:37:24 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
<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>
		By: Importer et exporter les dossiers de machines virtuelles avec PowerShell - Mon Post-It		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-25570</link>

		<dc:creator><![CDATA[Importer et exporter les dossiers de machines virtuelles avec PowerShell - Mon Post-It]]></dc:creator>
		<pubDate>Wed, 08 Jan 2025 15:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-25570</guid>

					<description><![CDATA[[&#8230;] effectuant quelques recherches sur le Net, nous avions lu les&#160; scripts&#160; de LucD (Lien 1&#160;, Lien 2), mais hier je suis tombé par hasard sur un script de LucD modifié par Mathieu du [&#8230;]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] effectuant quelques recherches sur le Net, nous avions lu les&nbsp; scripts&nbsp; de LucD (Lien 1&nbsp;, Lien 2), mais hier je suis tombé par hasard sur un script de LucD modifié par Mathieu du [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Daniel		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5720</link>

		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Mon, 30 Nov 2020 08:20:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5720</guid>

					<description><![CDATA[Replace Split() int line 39 with .Split($Separator, [StringSplitOptions]::RemoveEmptyEntries)]]></description>
			<content:encoded><![CDATA[<p>Replace Split() int line 39 with .Split($Separator, [StringSplitOptions]::RemoveEmptyEntries)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Daniel		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5719</link>

		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Mon, 30 Nov 2020 08:17:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5719</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-5718&quot;&gt;Daniel&lt;/a&gt;.

Uh, I noticed it throws the error when the Path starts with /]]></description>
			<content:encoded><![CDATA[<p>Uh, I noticed it throws the error when the Path starts with /</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Daniel		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5718</link>

		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Mon, 30 Nov 2020 08:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5718</guid>

					<description><![CDATA[It does return the correct folder, but only after throwing an error.

Get-Inventory:
Line &#124;
  36 &#124;                      $root = Get-Inventory -Name $_ -Location $root -N …
     &#124;                                                  ~~
     &#124; Cannot validate argument on parameter &#039;Name&#039;. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.]]></description>
			<content:encoded><![CDATA[<p>It does return the correct folder, but only after throwing an error.</p>
<p>Get-Inventory:<br />
Line |<br />
  36 |                      $root = Get-Inventory -Name $_ -Location $root -N …<br />
     |                                                  ~~<br />
     | Cannot validate argument on parameter &#8216;Name&#8217;. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Angelo		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5222</link>

		<dc:creator><![CDATA[Angelo]]></dc:creator>
		<pubDate>Wed, 21 Oct 2020 11:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5222</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-5218&quot;&gt;LucD&lt;/a&gt;.

i have an error message when i use this code:


Import-Csv Folder.csv -UseCulture &#124; %{

  $vm = Get-VM -Name $_.VmName

  $folder = Get-FolderByPath -Path $_.FolderName

  Move-VM -VM $vm -Destination $folder

}

###############error####################&quot;
PS C:\Dell\Folder&#062; .\folder.ps1
AVERTISSEMENT : Specifying Folder in the Destination parameter is deprecated and the parameter will stop accepting Folder objects at a future release. Please use the InventoryLocation
parameter instead.
Move-VM : 21/10/2020 13:50:13   Move-VM         The operation for the entity &quot;XXXX&quot; failed with the following message: &quot;The request refers to an unexpected or unknown type.&quot;
Au caractère C:\Dell\Folder\folder.ps1:92 : 3
+   Move-VM -VM $vm -Destination $folder
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidType
    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

AVERTISSEMENT : Specifying Folder in the Destination parameter is deprecated and the parameter will stop accepting Folder objects at a future release. Please use the InventoryLocation
parameter instead.
Move-VM : 21/10/2020 13:50:18   Move-VM         The operation for the entity &quot;XXXX&quot; failed with the following message: &quot;The request refers to an unexpected or unknown type.&quot;
Au caractère C:\Dell\Folder\folder.ps1:92 : 3
+   Move-VM -VM $vm -Destination $folder
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidType
    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM]]></description>
			<content:encoded><![CDATA[<p>i have an error message when i use this code:</p>
<p>Import-Csv Folder.csv -UseCulture | %{</p>
<p>  $vm = Get-VM -Name $_.VmName</p>
<p>  $folder = Get-FolderByPath -Path $_.FolderName</p>
<p>  Move-VM -VM $vm -Destination $folder</p>
<p>}</p>
<p>###############error####################&#8221;<br />
PS C:\Dell\Folder&gt; .\folder.ps1<br />
AVERTISSEMENT : Specifying Folder in the Destination parameter is deprecated and the parameter will stop accepting Folder objects at a future release. Please use the InventoryLocation<br />
parameter instead.<br />
Move-VM : 21/10/2020 13:50:13   Move-VM         The operation for the entity &#8220;XXXX&#8221; failed with the following message: &#8220;The request refers to an unexpected or unknown type.&#8221;<br />
Au caractère C:\Dell\Folder\folder.ps1:92 : 3<br />
+   Move-VM -VM $vm -Destination $folder<br />
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidType<br />
    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM</p>
<p>AVERTISSEMENT : Specifying Folder in the Destination parameter is deprecated and the parameter will stop accepting Folder objects at a future release. Please use the InventoryLocation<br />
parameter instead.<br />
Move-VM : 21/10/2020 13:50:18   Move-VM         The operation for the entity &#8220;XXXX&#8221; failed with the following message: &#8220;The request refers to an unexpected or unknown type.&#8221;<br />
Au caractère C:\Dell\Folder\folder.ps1:92 : 3<br />
+   Move-VM -VM $vm -Destination $folder<br />
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
    + CategoryInfo          : NotSpecified: (:) [Move-VM], InvalidType<br />
    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5218</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Wed, 21 Oct 2020 09:24:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5218</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-5211&quot;&gt;Angelo&lt;/a&gt;.

Just copy the complete function to your .ps1 file.
Then, in the same .ps1 file, you can call the function.
&lt;code&gt;
function Get-FolderByPath{
...
}

Get-FolderByPath -Path &quot;DC1/Blue1/Blue12/Blue121/Servers&quot;
&lt;/code&gt;]]></description>
			<content:encoded><![CDATA[<p>Just copy the complete function to your .ps1 file.<br />
Then, in the same .ps1 file, you can call the function.<br />
<code><br />
function Get-FolderByPath{<br />
...<br />
}</p>
<p>Get-FolderByPath -Path "DC1/Blue1/Blue12/Blue121/Servers"<br />
</code></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Angelo		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-5211</link>

		<dc:creator><![CDATA[Angelo]]></dc:creator>
		<pubDate>Tue, 20 Oct 2020 16:54:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-5211</guid>

					<description><![CDATA[hello,
in this link:
https://communities.vmware.com/thread/530723
you said that:
You will have to copy the code for my Get-FolderByPath function to your .ps1 file (at the top).Then you call the function later on in the .ps1 file.

could you give me an example please ? how can i call function in the file?]]></description>
			<content:encoded><![CDATA[<p>hello,<br />
in this link:<br />
<a href="https://communities.vmware.com/thread/530723" rel="nofollow ugc">https://communities.vmware.com/thread/530723</a><br />
you said that:<br />
You will have to copy the code for my Get-FolderByPath function to your .ps1 file (at the top).Then you call the function later on in the .ps1 file.</p>
<p>could you give me an example please ? how can i call function in the file?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-4872</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Mon, 20 Jul 2020 19:28:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-4872</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-4870&quot;&gt;Matt&lt;/a&gt;.

Thanks for sharing that Matt.]]></description>
			<content:encoded><![CDATA[<p>Thanks for sharing that Matt.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Matt		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-4870</link>

		<dc:creator><![CDATA[Matt]]></dc:creator>
		<pubDate>Mon, 20 Jul 2020 19:08:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-4870</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-3015&quot;&gt;Peter&lt;/a&gt;.

To fix the &quot;multiple child issue&quot; I modified my loop from:
foreach($strPath in $Path){
        $root = Get-Folder -Name $rootName -Server $vc -ErrorAction SilentlyContinue
        $strPath.Split($Separator) &#124; %{
          $root = Get-Inventory -Name $_ -Location $root -Server $vc -ErrorAction SilentlyContinue
          if((Get-Inventory -Location $root -NoRecursion &#124; Select -ExpandProperty Name) -contains &quot;vm&quot;){
            $root = Get-Inventory -Name &quot;vm&quot; -Location $root -Server $vc -NoRecursion
          }
        }

to:
for ($i = 0; $i -lt $strPath.Split($Separator).count; $i++) {
            $FOLDER = $strPath.Split($Separator)[$i]
            if ($i -eq 0 ) {
                # FIRST FOLDER
                $root = Get-Inventory -Name $FOLDER -Location $root -Server $vc -ErrorAction SilentlyContinue
            } else {
                # SUBSEQUENT FOLDERS
                $root = Get-Inventory -Name $FOLDER -Location $root -Server $vc -ErrorAction SilentlyContinue &#124; ? {$_.Parent.Name -eq $root}
            }
            if((Get-Inventory -Location $root -NoRecursion &#124; Select -ExpandProperty Name) -contains &quot;vm&quot;){
                $root = Get-Inventory -Name &quot;vm&quot; -Location $root -Server $vc -NoRecursion
            }
        }]]></description>
			<content:encoded><![CDATA[<p>To fix the &#8220;multiple child issue&#8221; I modified my loop from:<br />
foreach($strPath in $Path){<br />
        $root = Get-Folder -Name $rootName -Server $vc -ErrorAction SilentlyContinue<br />
        $strPath.Split($Separator) | %{<br />
          $root = Get-Inventory -Name $_ -Location $root -Server $vc -ErrorAction SilentlyContinue<br />
          if((Get-Inventory -Location $root -NoRecursion | Select -ExpandProperty Name) -contains &#8220;vm&#8221;){<br />
            $root = Get-Inventory -Name &#8220;vm&#8221; -Location $root -Server $vc -NoRecursion<br />
          }<br />
        }</p>
<p>to:<br />
for ($i = 0; $i -lt $strPath.Split($Separator).count; $i++) {<br />
            $FOLDER = $strPath.Split($Separator)[$i]<br />
            if ($i -eq 0 ) {<br />
                # FIRST FOLDER<br />
                $root = Get-Inventory -Name $FOLDER -Location $root -Server $vc -ErrorAction SilentlyContinue<br />
            } else {<br />
                # SUBSEQUENT FOLDERS<br />
                $root = Get-Inventory -Name $FOLDER -Location $root -Server $vc -ErrorAction SilentlyContinue | ? {$_.Parent.Name -eq $root}<br />
            }<br />
            if((Get-Inventory -Location $root -NoRecursion | Select -ExpandProperty Name) -contains &#8220;vm&#8221;){<br />
                $root = Get-Inventory -Name &#8220;vm&#8221; -Location $root -Server $vc -NoRecursion<br />
            }<br />
        }</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: LucD		</title>
		<link>https://www.lucd.info/2012/05/18/folder-by-path/#comment-4666</link>

		<dc:creator><![CDATA[LucD]]></dc:creator>
		<pubDate>Wed, 03 Jul 2019 13:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.lucd.info/?p=4027#comment-4666</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.lucd.info/2012/05/18/folder-by-path/#comment-4665&quot;&gt;Amine&lt;/a&gt;.

Sorry to hear that.
A screenshot of the tree structure of the VM folder could help me trying to analyse further.]]></description>
			<content:encoded><![CDATA[<p>Sorry to hear that.<br />
A screenshot of the tree structure of the VM folder could help me trying to analyse further.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
