Forum Discussion
grvranjan
Sep 17, 2021Copper Contributor
PowerShell script with MS Intune
Hi, I have been trying to run a script from MS Intune for decrypting hard drive but the status of the script shows success but decryption never starts. I also checked the registry and there also the...
Are other powershell script working? I tested it multipe times and each time it started decrypting
grvranjan
Sep 20, 2021Copper Contributor
If I am running a one liner in my script, it is working but when I am adding the condition for encryption algorithm, it is not working.
For Example:-
Disable-BitLocker -MountPoint $env:SystemDrive
If I only execute this command, it works without any issues. But as soon as I apply the If block for encryption algorithm, it does not works. Below script is not working for me.
$BitlockerStatus = Get-BitLockerVolume -MountPoint $env:SystemDrive
$status = $BitlockerStatus.VolumeStatus
$algorithm = $BitlockerStatus.EncryptionMethod
if ($status -eq 'FullyEncrypted')
{
#Write-Host $status
if ($algorithm -eq 'XTSAES128')
{
#Write-host "It's encrypted"
}
Else
{
Disable-BitLocker -MountPoint $env:SystemDrive
}
}
For Example:-
Disable-BitLocker -MountPoint $env:SystemDrive
If I only execute this command, it works without any issues. But as soon as I apply the If block for encryption algorithm, it does not works. Below script is not working for me.
$BitlockerStatus = Get-BitLockerVolume -MountPoint $env:SystemDrive
$status = $BitlockerStatus.VolumeStatus
$algorithm = $BitlockerStatus.EncryptionMethod
if ($status -eq 'FullyEncrypted')
{
#Write-Host $status
if ($algorithm -eq 'XTSAES128')
{
#Write-host "It's encrypted"
}
Else
{
Disable-BitLocker -MountPoint $env:SystemDrive
}
}
- Sep 20, 2021What happens when you remove the $env:Systemdrive and just target the c: drive ?
Disable-BitLocker -MountPoint "c:"