Eject usb drive but not all of them
Using the windows 10 icon, "eject the media", is slow because windows start all my sleeping usb drives before i can click "eject safely"
I wanted to eject some drive without waiting for the windows to open
I did not want to eject my sleeping usb drives that i use for storage
So, I designed this little powershell script to do so
##### powershell script #####
### requirements
# because this script is not signed
# (this will allow unsigned local powershell scripts to run)
# windows 7
# Set-ExecutionPolicy RemoteSigned #################################
# windows 10
# Set-ExecutionPolicy -scope CurrentUser RemoteSigned ##############
# run it in powershell ISE interface runned as admin
$donotejectserials = @(`
"FAFFFFF0FDF2F7F1BFC15635",`
"2GEWLRPL",`
"14510E6CDA88")
# get serial i do not want to eject - list all usb drives
#get-Disk | Where {($_.BusType -eq "USB")}
$allusbdisk = get-Disk | Where {($_.BusType -eq "USB")}
foreach ($usbdisk in $allusbdisk)
{
$founddonoteject = 0
foreach ($donotejectserial in $donotejectserials)
{
if ($usbdisk.serialnumber -like "*$donotejectserial*")
{
$founddonoteject = 1
}
#write-host "Serials: " $usbdisk.serialnumber " ----- " $donotejectserial " ----- " $founddonoteject
}
if ($founddonoteject -eq 0)
{
$letter = ($usbdisk | Get-Partition ).DriveLetter
write-host "Ejecting: " $letter " ----- " $usbdisk.friendlyname " ----- " $usbdisk.serialnumber
(New-Object -comObject Shell.Application).NameSpace(17).ParseName("$($letter):").InvokeVerb('Eject')
}
else
{
#write-host "NOT Ejecting: " $usbdisk.friendlyname
}
}
First
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this.
ReplyDeleteData Science training in rajaji nagar | Data Science with Python training in chenni
Data Science training in electronic city | Data Science training in USA
Data science training in pune | Data science training in kalyan nagar
I appreciate that you produced this wonderful article to help us get more knowledge about this topic. I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!
ReplyDeletejava training in chennai | java training in bangalore
java training in tambaram | java training in velachery
Really you have done great job,There are may person searching about that now they will find enough resources by your post
ReplyDeletepython training in pune | python training institute in chennai | python training in Bangalore
Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
ReplyDeleteBest Devops Training in pune
Devops interview questions and answers
Your website is very cool and it is a wonderful inspiring article. thank you so much.
ReplyDeleteBest selenium training in chennai
Best Selenium Training Institute in Chennai
Big Data Training in Chennai
iOS Training in Chennai
French Classes in Chennai
french language course in chennai
french course in chennai
Your article gives lots of information to me. I really appreciate your efforts admin, continue sharing more like this.
ReplyDeleteRPA Training in Chennai
RPA course in Chennai
Blue Prism Training in Chennai
Blue Prism Training
UiPath Training in Chennai
Data Science Course in Chennai
Data Science Training in Chennai
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing cursos de ti online
ReplyDeleteI think other website proprietors should take this internet site as an example , very clean and fantastic user genial style . Read More Here
ReplyDeleteNice article I was really impressed by seeing this blog, it was very interesting and it is very useful for me.
ReplyDeleteBig Data Hadoop Training In Chennai | Big Data Hadoop Training In anna nagar | Big Data Hadoop Training In omr | Big Data Hadoop Training In porur | Big Data Hadoop Training In tambaram | Big Data Hadoop Training In velachery
The article is really nice. every concept of this article is explained very neatly in the manner.
ReplyDeleteData Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery
Bet on Blackjack, with the best rules and rules - WGRi
ReplyDeleteIn Blackjack, there are four ways to play, but the dealer who is the highest-charted Blackjack player is the best. 바카라 He is kadangpintar the best player in the game. If the 1xbet dealer who