mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-28 08:51:31 -06:00
e0889d51db
* move Microwin related stuff to own Folder under "Functions" * update runspace function gathering logic * update Recall logic (from main repo) * change to easier naming scheme - rename files - rename function names * remove unneeded comment (after @CodingWonders's suggestion)
24 lines
1.1 KiB
PowerShell
24 lines
1.1 KiB
PowerShell
function Microwin-CopyToUSB([string]$fileToCopy) {
|
|
foreach ($volume in Get-Volume) {
|
|
if ($volume -and $volume.FileSystemLabel -ieq "ventoy") {
|
|
$destinationPath = "$($volume.DriveLetter):\"
|
|
#Copy-Item -Path $fileToCopy -Destination $destinationPath -Force
|
|
# Get the total size of the file
|
|
$totalSize = (Get-Item "$fileToCopy").length
|
|
|
|
Copy-Item -Path "$fileToCopy" -Destination "$destinationPath" -Verbose -Force -Recurse -Container -PassThru |
|
|
ForEach-Object {
|
|
# Calculate the percentage completed
|
|
$completed = ($_.BytesTransferred / $totalSize) * 100
|
|
|
|
# Display the progress bar
|
|
Write-Progress -Activity "Copying File" -Status "Progress" -PercentComplete $completed -CurrentOperation ("{0:N2} MB / {1:N2} MB" -f ($_.BytesTransferred / 1MB), ($totalSize / 1MB))
|
|
}
|
|
|
|
Write-Host "File copied to Ventoy drive $($volume.DriveLetter)"
|
|
return
|
|
}
|
|
}
|
|
Write-Host "Ventoy USB Key is not inserted"
|
|
}
|