Skip to Main Content
Status Under review
Product Area OSD Community Tools
Categories OSDCloud
Created by Patrick Davis
Created on May 14, 2026

Have OSDCloud eject the USB automatically if Cached data is not required

We have achieved this using a script that ejects the USB media if it has less than 14gb in size and the device is not a current gen model - This prevents our desktop techs having to clean up USB media periodically due to a large, supported model list. Our logic is that we want the newest model's driver data cached only for quick deployment and none of the older models driver data cached.


        # If device is a current gen, we want to cache the install stuff/load from the cached install stuff

# If usb drive is not NTFS or the drive size is less than 14gb, this is not supported
$USBDrive = Get-USBDrive
if ($null -ne $USBDrive) {
if ($USBDrive.FileSystem -eq 'NTFS' -and $USBDrive.Size -ge 14gb) {
if ($CurrentModels -ccontains $Machine) {
#cache
} else {
Close-USBDrive -DriveLetter $USBDrive.DeviceID
}
} else {
Clear-CachedFiles -DriveLetter $USBDrive.DeviceID
Close-USBDrive -DriveLetter $USBDrive.DeviceID
}
}
  • Attach files