dynamic menu

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by  Steven 2 weeks, 6 days ago.

  • Author
    Posts
  • #78733

    Steven
    Participant

    $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:\ ?

  • #78736

    Max Kozlov
    Participant
    -foreach { $selection[$_.IDX] 
    -echo $selection[$_.IDX] 
    -$dest = $selection[$_.IDX]
    -robocopy $dest d:\
    -}
    +foreach-object {
    +$_.Name
    +robocopy $_.Name d:\
    +}
    
  • #78739

    Olaf Soyk
    Participant

    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:\
                    }
  • #78788

    Steven
    Participant

    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?

You must be logged in to reply to this topic.