AutomoxAutomox

Getting output into the Activity log

MRaybone
October 4, 2022 at 3:09 pm UTC

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.

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (4)

KyleG-AutomoxOctober 4, 2022
#1

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.

 

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

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

Thank you!

MRayboneOctober 5, 2022
#2

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

 

 

KyleG-AutomoxOctober 5, 2022
#3

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

powershell9 lines
$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.")
}
}

 

MRayboneOctober 5, 2022
#4

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