Question

Getting output into the Activity log

  • 4 October 2022
  • 4 replies
  • 118 views

Badge

Hello!

I have a very simple issue.
I want to run this command in a worklet policy…

manage-bde -Status

I then want the output of this to show in the activity log.  As far as I can tell, this isn’t possible, as I’ve tried a whole host of ways to get it working but always end up with a blank log (unless I do something useless like “write-host hello”). I’d be really happy for someone to prove me wrong.

Cheers,
Mark.


4 replies

Hey Mraybone,

 

“manage-bde -Status” doesn’t work in 32-bit Powershell, which is what we use for Worklets. Instead, you can use the code below to pipe the command to 64-bit, which will show up in the Activity Log. This code block will work for anything else you wish to pipe to 64-bit PS as well.

 

$scriptBlock = {
(manage-bde -Status)
}

& "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptBlock

Thank you!

Badge

Thanks, almost there but the powershell.exe line isn’t accepting any of the parameters…

 

 

Hey Mark,

Did you happen to modify the code I sent you? I just tested it again with a Worklet and it was successful.

 

 

You can also try the code below using Powershell instead of piping CMD

$BitlockerVolumers = Get-BitLockerVolume
$BitlockerVolumers |
ForEach-Object {
$MountPoint = $_.MountPoint
$RecoveryKey = [string]($_.KeyProtector).RecoveryPassword
if ($RecoveryKey.Length -gt 5) {
Write-Output ("The drive $MountPoint has a recovery key $RecoveryKey.")
}
}

 

Badge

Ok my bad - looks like something weird happened via the copy and paste - typed it verbatim and it works :) :)

 

Thank you!!  I’d have never figured this out in a million years

Reply