Jump to content
View in the app

A better way to browse. Learn more.

Pulseway

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PowerShell Script to Eject USB Storage Devices via Pulseway Automation

Featured Replies

Posted

Hi everyone,

I wanted to share a simple PowerShell script that you can use within Pulseway Automation to remotely eject any USB storage devices connected to a system. This can be helpful for security-conscious environments or in scenarios where USB usage needs to be tightly controlled.

Works well in combination with the Disable USB Storage Access script in the built in category.

 

The script uses Shell.Application to trigger the native "Eject" action for removable drives (DriveType = 2). Here's the version that loops through all mounted USB volumes:

 Works great in Pulseway automation tasks
💡 You can modify it to eject a specific drive letter if needed
powershell
# Eject all USB volumes using Shell.Application COM object
$Eject = New-Object -ComObject Shell.Application

# Get all removable (DriveType = 2) volumes with drive letters
$volumes = Get-WmiObject -Class Win32_Volume | Where-Object { $_.DriveType -eq 2 -and $_.DriveLetter }

foreach ($vol in $volumes) {
    Write-Host "Ejecting drive $($vol.DriveLetter)..."
    $Eject.NameSpace(17).ParseName($vol.DriveLetter).InvokeVerb("Eject")
}

 

Notes:

During my testing, I've seen that USB devices will not be removed if a process is running from the disks in question.
In other words, if there is a write/read process running, the disk is not ejected.

 

Let me know if you have questions or enhancements!

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.