dynamic menu

Welcome Forums General PowerShell Q&A dynamic menu

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
1 year, 1 month ago.

  • Author
    Posts
  • #78733

    Participant
    Points: 0
    Rank: Member

    $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

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

    Participant
    Points: 9
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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?

The topic ‘dynamic menu’ is closed to new replies.