I have a simple (test) Powershell script, it creates an empty file. The script runs fine executed manually in Powershell. However it does nothing when executed in SSIS.
I've tried executing it in an Execute Process task and also in a VB.Net Script task.
Both times Poweshell seems to open (I see the screen come up and close quickly), however the file that the script tries to create doesn't get created.
Any ideas how to troubleshoot this would be appreciated!
Thank you!
Adding -ExecutionPolicy ByPass is what made it work. So now what I am passing is:
-ExecutionPolicy ByPass -file "\\SERVER\Share\Script.ps1"
This is where I got this tip - http://www.sqlservercentral.com/Forums/Topic1714552-147-1.aspx
After I added this, Read-Host started working also and paused the execution of the script.
Related
I've written a Powershell script to automate a Web UI test using IE. The script runs fine when I execute it from PowerShell. However, I have run into an obscure problem and that is when I run my Web UI test script from another powershell script, it fails. I tried to debug it and found that it fails on the following line.
$button = $ie.Document.getElementsByTagName("button")
$button.Item().Click() # $button.Item() evaluates to null when the script is executed from another script.
Can anyone help me figure this out? It appears that when I run the script, the script has no issues locating the element, but when it is run from another script the element I am looking for cannot be located.
EDIT
I get the same error when I run the PS script through Task Scheduler. The script only works when I invoke it directly. If I invoke via another script/program, it doesn't work.
Can anyone help me with run command to open PowerShell as different user?
Currently I am trying to run below command
Runas /noprofile /user:domain\username powershell
It works but I have to provide password once powershell window opens, is there any way where I can directly put password in run command?
Or even if I get to know how can I run any commands from PowerShell using different user without opening new ps window. e.g need to run below command using different user.
Restart-Server -Name testservice
You could try schtasks.exe. You can get the help using schtasks.exe /?
If you are getting any errors after using this command referring the examples, update the post with the error, we are here to help you.
Update:
There is an in-built cmdlet available in PowerShell Register-ScheduledTask, but its depended on OS and is available only from Windows Server 2012 onwards.
I would like to make a batch file that can write sql request into an .exe that is running as a cmd prompt window.
My idea was to put my sql script into an .txt file that the batch request and insert into my second prompt window.
I've found something about:
Type 'mytext.txt' | myexe.exe
But its not working.
What I want to do is a Batch that send my sql request into that .exe run as a cmd prompt, so I can automate that process.
Any idea?
Thanks
Depends heavily on the capabilities of that exe-file.
What does it poll for ? Is it written to handle pipes ?
https://technet.microsoft.com/en-us/library/bb490982.aspx gives you an overview of the command redirection operators.
Not knowing what the exe is capable of makes this question really hard to answer.
Please someone help me!
Cannot run Multiple shell command in vb.net
when run the shell command in projects , the projects is hangs until command is finish.
And how to run without hangs in projects.
Thanks...
Sorry for Spelling.
Try using Process.Start() instead. It is only slightly different but is more powerful. By default it will not wait. But you can wait by getting the process it creates and then waiting on it to exit.
I have built out a simple FTP job in Pentaho that places a file in a local directory. I need to be able to call this job in a SQL server agent job which I can then schedule and use, but when I set the agent job up it runs through the steps successfully but does not produce anything to show that it was in fact successful.
I am pretty confident the Pentaho job itself is fine because it can be run through the UI, command line, and .bat file. Everything works as expected except when I try to make this SQL Server Agent job and I have no idea why!
Here is the only step in the job When I use this i'm prompted with no errors but nothing actually happens. If I try to enclose it in quotes I get an error.
Any help would be appreciated
Figured it out!
Apparently, only the first line of the command was executing. So it was navigating to a different directory but not executing any commands. I remedied this by putting everything on one line and adding a && to it.
Command line used: cd c:\pentaho\data-integration && kitchen.bat /file:C:\pentaho\Jobs\BW\FTP_BW_TRN.kjb /level:Basic