Reputation: 360
I am trying to accomplish the following:
What I need to know, is there a way for powershell to detect the files I have selected in the File Explorer? I have tried to locate resources online to give me some insight, but no luck, either it isn't possible or I am searching the wrong terminology.
Upvotes: 1
Views: 2424
Reputation: 17472
Or without explorer (then you can navigate, but if you know your directory its an other method) :
Get-ChildItem "c:\temp" -file |
Out-GridView -Title "Select your files" -OutputMode Multiple |
Copy-Item -Destination "C:\tempdest"
Upvotes: 1
Reputation: 17472
Something like this (keep CTRL key pressed and select your files)
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = "c:\temp"
$OpenFileDialog.filter = "All files (*.*)| *.*"
$OpenFileDialog.Multiselect=$true
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.FileNames | Copy-Item -Destination "C:\tempdest"
$OpenFileDialog.Dispose()
Upvotes: 1