-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florent Guelfucci
committed
May 11, 2017
1 parent
55d031f
commit f68b716
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Check if a give drive is locked or not. | ||
function IsLocked( $drive ) | ||
{ | ||
return (manage-bde -status $drive| Select-String -Pattern 'Lock Status').ToString().Split(":")[1].trim().ToLower() -eq "locked" | ||
} | ||
|
||
# keep track of what we locked | ||
# so we can give a summary at the end. | ||
$found = 0; | ||
|
||
# Look for all the unlocked drives. | ||
$drives = Get-WmiObject Win32_Volume -Filter ("DriveType={0}" -f [int][System.io.Drivetype]::removable) | ||
|
||
# for each and every drives we found. | ||
foreach( $drive in $drives ) | ||
{ | ||
# is it locked? | ||
if( (IsLocked( $drive.DriveLetter )) -eq $false) | ||
{ | ||
# add a message to say that we are locking this drive. | ||
[void]($am.Say( "Drive : "+$drive.DriveLetter +" is unlocked", 400, 10 )) | ||
|
||
# lock it | ||
manage-bde -lock $drive.DriveLetter | ||
|
||
# track that we found an unlocked drive | ||
$found++; | ||
} | ||
|
||
# Move on to the next drive | ||
} | ||
|
||
# Give some sort of sumarry of what was done. | ||
if( $found -eq 0 ) | ||
{ | ||
# If we locked nothing just tell the user. | ||
[void]($am.Say( "Could not find any drives to lock", 400, 10 )) | ||
} | ||
else | ||
{ | ||
# Otherwise just tell them how many we locked. | ||
[void]($am.Say( "Found : "+$found +" drive(s) to lock", 400, 10 )) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Check if a give drive is locked or not. | ||
function IsLocked( $drive ) | ||
{ | ||
return (manage-bde -status $drive| Select-String -Pattern 'Lock Status').ToString().Split(":")[1].trim().ToLower() -eq "locked" | ||
} | ||
|
||
# keep track of what we unlocked | ||
# so we can give a summary at the end. | ||
$found = 0; | ||
|
||
# Look for all the locked drives. | ||
$drives = Get-WmiObject Win32_Volume -Filter ("DriveType={0}" -f [int][System.io.Drivetype]::removable) | ||
|
||
# for each and every drives we found. | ||
foreach( $drive in $drives ) | ||
{ | ||
# is it locked? | ||
if( (IsLocked( $drive.DriveLetter )) -eq $true) | ||
{ | ||
# add a message to say that we are unlocking this drive. | ||
[void]($am.Say( "Drive : "+$drive.DriveLetter +" is locked", 400, 10 )) | ||
|
||
# unlock it, (and ask for password) | ||
manage-bde -unlock $drive.DriveLetter -Password | ||
|
||
# track that we found a locked drive | ||
$found++; | ||
} | ||
|
||
# Move on to the next drive | ||
} | ||
|
||
# Give some sort of sumarry of what was done. | ||
if( $found -eq 0 ) | ||
{ | ||
# If we unlocked nothing just tell the user. | ||
[void]($am.Say( "Could not find any drives to unlock", 400, 10 )) | ||
} | ||
else | ||
{ | ||
# Otherwise just tell them how many we unlocked. | ||
[void]($am.Say( "Found : "+$found +" drive(s) locked", 400, 10 )) | ||
} |