PowerShell Question - Noob

I’ve looked at almost all of the PowerShell posts before posting this one. I just want to create a simple fixlet that copies a PowerShell script to Server and execute it. This is what I have:

//download PowerShell script from IEM Relay

download now http://IEMServer:52311/Uploads/IIS7_8_Fullhc_TCS.ps1

//Move PowerShell script to C:\middleware
move __Download\IIS7_8_Fullhc_TCS.ps1 c:\middleware_IIS7_8_Fullhc_TCS.ps1

//Execute PowerShell with Full HealthCheck IIS Script
waithidden powershell.exe -ExecutionPolicy Bypass -Command “c:\middleware\IIS7_8_Fullhc_TCS.ps1.ps1”

Do I need anything else??

Thanks

that should be, but you don’t have to move it out of the download folder to run it. You can use a relevance inspector to get the full path instead.

download now http://IEMServer:52311/Uploads/IIS7_8_Fullhc_TCS.ps1

waithidden powershell.exe -ExecutionPolicy Bypass -Command "{ pathname of download file "IIS7_8_Fullhc_TCS.ps1" }"

Ok, Yeah the IIS folks copy it there so that’s what I moved it to C:\middleware.

Thank you jgstew

Is there an error when this when “c:\middleware\IIS7_8_Fullhc_TCS.ps1” is Red in the Action Script?

Sorry first BF Action Script…

waithidden powershell.exe -ExecutionPolicy Bypass -Command “c:\middleware\IIS7_8_Fullhc_TCS.ps1”

Sorry, I think that is how it is supposed to look, correct?

Why the use of download now ?

This jumps out of all the relay logic and has the client perform the download instead of the BigFix infrastructure

As @AlanM points out, you shouldn’t use download now and should instead use a prefetch in almost all cases.

Also, I just realized that part of your issue is the use of -Command in the command line. That is for one off commands, not for running PowerShell scripts.

Generally you should get the process to work on the command line first, then use that to figure out the actionscript.

Is there a way to take the results of my script and upload them to another relay?

You could have an “archive” command upload results to the core server. You would just need to be able to access it.

http://support.bigfix.com/product/documents/Upload_Archive_Manager_80_101211.pdf

1 Like