Exeuting power shell script via BigFix action has an issue

Hi All,

I am trying to execute an Power shell which will stop the BES Client service, delete the BES Data and start the BES client service via BIgFix action script. The script that I am suing is as follows:-

# STOP BES client service
Stop-Service -Name BESClient -Force
# Delete the __BESData folder
Remove-Item -Path "C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData" -Recurse -Force
# Start the besclient.service
Start-Service -Name "BESClient"

BigFix Action script that I am using is as follows:-

prefetch EUC_Fix.ps1 sha1:e7fe5ff1fdc7c7d805e00dae5a05dda27ff21602 size:256 http://localhost:52311/Uploads/EUC_Fix.ps1 sha256:878d4a45a2ec531332c4819dd4974a9540a770d9b577652dd361513374123f7d


// Check if the folder exists

if {exists folder "c:\temp"}

    // Delete the folder if it exists

    folder delete "c:\temp"

endif


// Create the folder

folder create "c:\temp"


// Move ps1 file to c:/temp

move "__Download\EUC_Fix.ps1" "c:\temp\EUC_Fix.ps1"


action uses wow64 redirection false


waithidden {{ pathname of file ((it as string) of value "c:\temp\EUC_Fix.ps1" of key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry) } -File "c:\temp\EUC_Fix.ps1"


action uses wow64 redirection {x64 of operating system}

Execution error is shows as follows:-
Command failed (Thread execution failed (2)) waithidden { pathname of file ((it as string) of value “c:\temp\EUC_Fix.ps1” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of native registry) } -File “c:\temp\EUC_Fix.ps1” (action:3117852)

Can you please suggest if the execution of the PS script could be an issue.

Regards,
VT

Why are you trying to evaluate the pathname of the script file you just copied? that shouldn’t be in the relevance substitution at all

so it should be

waithidden {{ "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" of native registry) } -File "c:\temp\EUC_Fix.ps1"

Correct?

Regards,
VT

No I don’t think that relevance to find PowerShell.exe is correct, and shouldn’t be escaped (use one { instead of two {{ )

I’m typing from phone now but you should be able to find lots of PowerShell examples here int he forum

1 Like