mx1m3
Members
-
Joined
-
Last visited
Reputation Activity
-
mx1m3 got a reaction from Mariale_Pulseway in Send a notification when...I don't know why I didn't see those settings as I scouted all the pages several times.
Hope this will help others too.
Thank you Mariale! 😘
-
mx1m3 got a reaction from Paul in PowerShell Script to Eject USB Storage Devices via Pulseway AutomationHi 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!