BigFix Action Failing With PowerShell Script

I’ve created multiple BigFix actions that create a temporary PowerShell script and execute flawlessly.

However, I have one that is failing before it even finishes writing the script. There seems to be something that is making BF exit abruptly and support has been unable to help me identify the issue.

I have narrowed it down to a single line that is causing the failure, it’s after the pipe. Parenthesis or not, this fails.
Failed Get-LocalUser | Where {($_.name -eq ‘OneAdmin’)}

As part of troubleshooting with HCL support I removed everything after the pipe and replaced it with write-host. This proves the pipe is not the issue.

Completed // Disable wow64 redirection on x64 OSes
Completed action uses wow64 redirection {not x64 of operating system}
Completed delete __createfile
Completed // CREATEFILE
Completed createfile until END_OF_FILE
Completed
Completed Start-Transcript C:\temp\joesbftest.txt -Verbose
Completed
Completed #If default Administrator already exist as OneAdmin then change to Administrator_Disabled
Completed Get-LocalUser | write-host
Completed
Completed
Completed Stop-Transcript
Completed
Completed END_OF_FILE
Completed delete powershell.ps1
Completed move __createfile powershell.ps1
Completed waithidden { pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy Bypass -File powershell.ps1

So why is this failing? It’s not a PowerShell issue. It runs without issue in PowerShell. Support asked me to run PowerShell as System, I did, it worked. It’s not even executing PowerShell at this point, it’s still writing to the file. It shouldn’t matter what I put in this file at this point, it’s just writing to a file. I’ve proven it doesn’t execute as it writes to file because on the successful run above it created a transcript. On this failed run there is no transcript.

I have tried the new BigFix PowerShell action option and it fails at the same place. I have also tried to put this script into a .ps1 file and just download and execute it locally from the client but it fails to download. There is something about that line that BigFix really doesn’t like.

Completed // Disable wow64 redirection on x64 OSes
Completed action uses wow64 redirection {not x64 of operating system}
Completed delete __createfile
Completed // CREATEFILE
Completed createfile until END_OF_FILE
Completed
Completed Start-Transcript C:\temp\joesbftest.txt -Verbose
Completed
Completed #If default Administrator already exist as OneAdmin then change to Administrator_Disabled
Failed Get-LocalUser | Where {($_.name -eq ‘OneAdmin’)}

Stop-Transcript

END_OF_FILE
delete powershell.ps1
move __createfile powershell.ps1
waithidden { pathname of file ((it as string) of value “Path” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -ExecutionPolicy Bypass -File powershell.ps1
strong text

In Action script, Relevance clauses are surrounded by { } tags. Your open-curly-bracket is evaluating as the start of Relevance. Use two open-curly-brackets to escape it, as

Get-LocalUser | Where {{($_.name -eq ‘OneAdmin’)}
1 Like

Nailed it. Thank you so much sir, a lifesaver. Delayed three weeks over that one.

As a note, one of the features we introduced with BigFix 10.0.4 is native Powershell support to help simplify its use and avoid these types of challenges.

Here’s also a brief video if interested in a demo: https://www.youtube.com/watch?v=UT1hls4QWKQ

And additional reference: https://help.hcltechsw.com/bigfix/10.0/platform/Platform/Console/Dialogs/action_script_tab.html

2 Likes

That was the first thing I tried. The PowerShell option was failing on the same line.

Native powershell support, nice, that’ll help a lot!

how do we do the “prefetch” command or any equivalent in PowerShell when using the native Powershell action script?

As far as I know…you don’t.
If you need to mix Actions riot with PowerShell, you’d need to stick to the older methods of using Actionscript with ‘createfile’ or ‘appendfile’ commands to create a PowerShell script and execute it.

The Script Builder Dashboard described at New BigFix Labs Dashboards may be helpful - after using the Dashboard to build a task, you can edit the task to add download commands or pre/post PowerShell commands.