#/////////////// FINDING USB DRIVES /////////////
Function USBDrive
{
$GPD = Get-PhysicalDisk
foreach($disk in $GPD)
{
if( $disk.BusType -eq "USB")
{
#$disk.DeviceId
$colDisks = Get-WmiObject -Class Win32_LogicalDiskToPartition -ComputerName "."
foreach ($objDisk in $colDisks)
{
if($objDisk.Antecedent.contains("Disk #" + $disk.DeviceId) )
{
$USBDrive= $objDisk.Dependent.Split("""")[1]
$USB = $disk.FriendlyName + " , " + $USBDrive
$global:myArray += $USBDrive
}
}
}
}
}
USBDrive
$global:myArray