Created
November 2, 2023 08:37
-
-
Save SpotlightForBugs/d7be2d096bce7aa67b7be9c32e414f9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Get-WmiObject -Query "SELECT * FROM Win32_DiskDrive WHERE MediaType='Removable Media'"|%{Get-WmiObject -Query "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($_.DeviceID)'} WHERE AssocClass=Win32_DiskDriveToDiskPartition"|ForEach-Object{Get-WmiObject -Query "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($_.DeviceID)'} WHERE AssocClass=Win32_LogicalDiskToPartition"|ForEach-Object{$_.DeviceID}}}|Sort-Object{(Get-Item $_).LastWriteTime}-Descending|Select-Object -First 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment