I need to run a Powershell script which calls a Perl command to execute the file.
This is my Powershell command:
parm($scriptpath,$inputpath,$outputpath)
perl $scriptpath -input $inputpath -output outputpath
When I execute this command from Powershell by passing the necessary arguments, I am getting expected result.
But on executing via web jobs, I am getting errors like
enter image description here
Do I need to modify my Powershell script?
Related
I would like to execute my powershell scripts. To do this I've written a basic jenkinsfile. However, Jenkins constantly complains about either a unexpected '\' character or it simply says that the path I've given is not the OK. Or that the cmdlet is not properly used.
I've tried:
call '& "C:\WSEB\Conversietool\UT\ConversieToolTestcases\CommandLineConversieALLtestcases.ps1"'
powershell '& "C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerToolUitvoerVorigeTestrun.ps1"'
powershell '& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerToolUitvoerVorigeTestrun.ps1
& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\KopieerConfig-test.ps1
& C:\WSEB\Conversietool\UT\ConversieToolTestcases\PSscript\VerwijderResultaten.ps1'
call 'C:\\WSEB\\Conversietool\\UT\\ConversieToolTestcases\\CommandLineConversieDSO.ps1'
powershell 'C:\WSEB\Conversietool\UT\ConversieToolTestcases\CommandLineConversieALLtestcases.ps1'
I'm at a loss here. I would like Jenkins to simply tell me if the tests were OK/NOK (warnings/errors etc). The powershell files are located in C:\WSEB\Conversietool\UT\ConversieToolTestcases
I've got it. You can execute a powershell script file with the following:
powershell returnStatus: true, script: 'C:\\Users\\User\\Desktop\\example.ps1'
Credits to: bic (Run Powershell script from file in Jenkins pipeline)
I need to automate some tasks against a legacy application. It doesn't have an API, but the vendor offers a .exe I can run to perform various tasks against the application.
I can call the .exe from within PowerShell just fine, but after calling it it prompts for the following input:
Do you agree to the license: YES
User name: myuid
Password: SuperSecretPassword`
I can run this interactively from the command prompt just fine and manually enter the requested input as prompted, but I need to automate this in a script. The .exe doesn't accept any command line parameters for this either(it's an old app), the only parameters I can pass are the commands I want to execute against the application. The .exe is only command line based with no GUI, so GUI automation tools aren't an option either.
I could do this easily with expect in a *nix shell, however given that I have a .exe I need to run, that's out of the question. There doesn't appear to be an "expect" equivalent in Windows, so I'm curious if this can be accomplished in PowerShell?
Note: For Windows scripts I prefer PowerShell, but could utilize VBScript if necessary.
If I remember correctly, if it's just one line you can pipe a string to an exe eg. "asdf" | example.exe, but it's multiple lines of input you might need to use SendKeys
Add-Type -AssemblyName 'System.Windows.Forms'
$ID = (Start-Process example.exe -PassThru).id
Sleep 1
Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.Interaction]::AppActivate([Int32]$ID)
[System.Windows.Forms.SendKeys]::SendWait("YES~")
[System.Windows.Forms.SendKeys]::SendWait("myuid~")
[System.Windows.Forms.SendKeys]::SendWait("SuperSecretPassword~")
I have written simple batch script to replace some text in a file, when executed via command line but when those commands are copied to .bat file execution stops after powershell command. Any idea how to execute powershell commands in batch file?
arco444's answer worked for me in comments:
You just call powershell.exe with no parameters so it starts an interactive session. If you were to type exit your batch script would continue. Use the -command switch to execute whatever it is you want to. And please edit your question and include the code there. Also You need to put the powershell command in quotes. i.e. powershell -command "get-content file.cs"
In a powershell script I need to start the process powershell and tell it to run the script foo.ps1 like so:
start-process powershell C:\foodir\foo.ps1
But I ran into problems when I needed the script foo to be run with parameters. I tried some code like this:
start-process powershell (C:\foodir\foo.ps1 -paramforfoo test)
but this simply freezes the script when it gets to this line and throws no errors. I think it is trying to pass the parameter test to the powershell process and not to the script foo. How can I run this script with parameters?
Try using quotes to collect your command. E.g.
Start-Process powershell ".\Untitled3.ps1 -testparam 'hello world'"
Does anyone know how to execute a PowerShell script from SSIS? I have created the script and it works from from the command line. The script takes a couple of command line parameters, which work fine when called from cmd.exe.
I'm using an Execute Process Task in SSIS and cannot get the script file to execute. I'm using expressions to pass in the name of the script and the command line arguments. The task is returning an incomplete string token error.
From VS to launch PSH with an extra script (for a Cmdlet project) I use the following commandline:
powershell -noexit -command ". ./Startup.ps1"
The -noexit will keep the instance around (so you wouldn't want that), putting all the real commands in a script to be dot-sourced avoids a really long command line.
Go to Execute Process Task Editor -> Process tab and set the following options:
Executable - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Arguments - -File ".\PowershellScript/ps1" "arg_1_value" "arg_2_value" ... "arg_n_value"
Refer to the below screenshot: