I have a powershell wrapper that downloads the script to the client and them moves it to the c:\temp folder on the machine. It then uses the following command line in the wrapper to launch the script:
This works for other scripts that I am running, such as copying files from network share to the local box, but this script only starts the Start-Transcript -Path c:\temp\output.txt -Append which is the first line of the script and never executes the rest. Is there something I should be doing different within the wrapper to launch and run a script that will run local without any issues. It is a script to fail over a SQL cluster.
I am using powershell 4.0 and even with out transcript powershell completes successfully but script never runs. I placed the transcript there to make sure powershell.exe was launch the script.
We have the execution policy set to bypass and is running on 2012R2 OS. As for the script I really can not post it but it basically has some functions and main code that fail over s SQL cluster.
//============================================================================
//PowerShell Script…
//
//THIS TASK WILL DOWNLOAD AND EXECUTE A POWERSHELL SCRIPT
//============================================================================
//1. Save old ExecutionPolicy value
//parameter “PolicyExisted”="{exists value “ExecutionPolicy” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of registry}"
//parameter “oldExecutionPolicy”="{if (parameter “PolicyExisted” as boolean) then (value “ExecutionPolicy” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell” of registry as string) else “”}"
//============================================================================
//2. set to ExecutionPolicy=Unrestricted and set the powershell executable location
//we need to determine what the current execution policy is so we can put it back when we’re done.
//regset “[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]” “ExecutionPolicy”=“Unrestricted”
//parameter “PowerShellexe” = “C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe”
//============================================================================
//3. If C:\temp doesn’t exist, create it
//
if {not exists folder “c:\temp”}
waithidden cmd.exe /C mkdir c:\temp
else
endif
//============================================================================
//4.
download as vacate_server_bigfix_testing.ps1 http://bigfixserver:52311/Uploads/vacate_server_bigfix_testing.ps1
continue if {(sha1 of it = “d3b0af46b4c33dd4584e53a1293aba4d59bded16”) of file “vacate_server_bigfix_testing.ps1” of folder “C:\Program Files (x86)\BigFix Enterprise\BES Client__BESData\actionsite__Download”}
dos copy /Y __Download\vacate_server_bigfix_testing.ps1 c:\temp\vacate_server_bigfix_testing.ps1
//============================================================================
//5. Execute PowerShell with ps1 script file
waithidden “{parameter “PowerShellexe”}” -file “c:\temp\vacate_server_bigfix_testing.ps1”
Powershell seems to default to x86 Powershell.exe. Some scripts are picky and need to be run from the x64 Powershell.exe. This specific path should force it to use the x64 version.