Need help using Createfile to run a powershell script

Hello everyone,

I am using the following createfile that is exiting with code=1

delete __createfile
delete powershell.ps1

createfile until EOF
Get-NetAdapter * | Where-Object {{ $_.TransmitLinkSpeed -EQ “25000000000” }} | Set-NetAdapterAdvancedProperty -DisplayName “Jumbo Packet” -DisplayValue “9014”
EOF

move __createfile powershell.ps1

waithidden powershell.exe -ExecutionPolicy Bypass -File powershell.ps1

This is what is showing on the client log

GatherHashMV command received.
At 15:01:22 -0400 - mailboxsite (http://root.local:52311/cgi-bin/bfgather.exe/mailboxsite1080821027)
Downloaded ‘http://relay.local:52311/mailbox/files/0d/7c/0d7cd895f18a6696972ef01de2feccb9d02997a0’ as ‘Action 193306.fxf’
Gather::SyncSiteByFile adding files - count: 1
At 15:01:22 -0400 -
Successful Synchronization with site ‘mailboxsite’ (version 200) - ‘http://root.local:52311/cgi-bin/bfgather.exe/mailboxsite1080821027
Processing action site.
At 15:01:25 -0400 - mailboxsite (http://root.local:52311/cgi-bin/bfgather.exe/mailboxsite1080821027)
Relevant - Custom Action (fixlet:193306)
At 15:01:25 -0400 -
ActionLogMessage: (action:193306) Action signature verified for Execution
ActionLogMessage: (action:193306) starting action
At 15:01:25 -0400 - actionsite (http://root.local:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded delete No ‘C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\actionsite__createfile’ exists to delete, no failure reported (action:193306)
Command succeeded delete powershell.ps1 (action:193306)
Command succeeded createfile until (action:193306)
Command succeeded move __createfile powershell.ps1 (action:193306)
Command started - waithidden powershell.exe -ExecutionPolicy Bypass -File powershell.ps1 (action:193306)
At 15:01:26 -0400 -
Report posted successfully
At 15:01:27 -0400 - actionsite (http://root.local:52311/cgi-bin/bfgather.exe/actionsite)
Command succeeded (Exit Code=1) waithidden powershell.exe -ExecutionPolicy Bypass -File powershell.ps1 (action:193306)
At 15:01:28 -0400 -
ActionLogMessage: (action:193306) ending action
At 15:01:28 -0400 - mailboxsite (http://root.local:52311/cgi-bin/bfgather.exe/mailboxsite1080821027)
Not Relevant - Custom Action (fixlet:193306)

If I run the PowerShell cmd directly on Windows it does what it needs to do.

What am I doing wrong?

Thanks!

Try saving off the generated Power shell file to test it.

I suspect it’s how you’re trying to escape the curly brackets though.

Your {{ is correct, that escapes the open-curly and translates to a literal { in the PowerShell script instead of beginning a Relevance clause. But I think your }} needs to change - because you’re not inside a relevance substitution, that is passed literally into the PowerShell script as }}

1 Like

Any reason not to do this using BigFix’s native support for powershell?

1 Like

So I had first tried it with the curly bracket on the front, but that didn’t work so I thought that maybe I needed that at the end as well…that didn’t work either. But lo and behold after you mentioned it, I tried it again with the double single curly on the front only and the action completed successfully this time. :face_with_diagonal_mouth:

corrected action script

delete __createfile
delete powershell.ps1

createfile until EOF
Get-NetAdapter * | Where-Object {{ $_.TransmitLinkSpeed -EQ “25000000000” } | Set-NetAdapterAdvancedProperty -DisplayName “Jumbo Packet” -DisplayValue “9014”
EOF

move __createfile powershell.ps1

waithidden powershell.exe -ExecutionPolicy Bypass -File powershell.ps1

2 Likes

At first that is what I was trying to accomplish, nice easy deployment with built-in PowerShell support but the action kept on failing.

At least it’s working now.

Thanks!

1 Like