dynamic menu

$selection = Get-ChildItem C:\temp -Directory | Select Name | Sort Name

If($selection.Count -gt 1){
$IDX = 0
$(foreach ($item in $selection){
$item | select @{l=‘IDX’;e={$IDX}},Name
$IDX++}) |
Out-GridView -Title ‘Select one or more folders to use’ -OutputMode Multiple |
foreach { $selection[$_.IDX]

echo $selection[$_.IDX]

$dest = $selection[$_.IDX]

robocopy $dest d:\

}
}


robocopy $dest d:\ , this command show robocopy @{Name=Folder1} d:\

possible to show robocopy Folder1 d:\ ?

-foreach { $selection[$_.IDX] 
-echo $selection[$_.IDX] 
-$dest = $selection[$_.IDX]
-robocopy $dest d:\
-}
+foreach-object {
+$_.Name
+robocopy $_.Name d:\
+}

Actually you don’t need an index …

Get-ChildItem -Path C:\temp -Directory |
Sort-Object -Property Name |
Select-Object -Property Name,FullName |
Out-GridView -Title ‘Select one or more folders to use’ -OutputMode Multiple |
ForEach-Object{
robocopy $_.FullName d:
}

Thank for the help it working using the list selection method.

i just wonder if this selection list method if convert to multi checkbox is it difficult?