Forum Discussion
Call Powershell Script from Unix Shell Script
Hi All,
Trust you're all having a great day.
I have a powershell script on my Windows server which does some active directory operations. I wish to call that script from another Linux machine using a shell script. I have installed powershell server on my Windows server and can communicate with my linux machine using key based ssh authentication. The issue is that my script just stops once the command for ssh to Windows server is executed.
My shell script below:
!/bin/bash
echo "script run" GROUP=$1 ACCOUNT=$2 ssh Administrator@ sleep 10 echo "\scriptname.ps1 -group $GROUP -account $ACCOUNT" sleep 5 echo "exit" exit
I have tried without the echo command as well and it still hangs. Any idea what I must be doing wrong here? How can I make it work please?
Regards, Gaurav
Tried the operation using an "expect" script and it all works well now.
- Gaurav_Kabra_25Nimbostratus
Tried the operation using an "expect" script and it all works well now.
- Chris_GrantEmployeeExpect is an awesome tool. Would you be willing to share the code you used so the community can benefit?
- Chris_GrantEmployee
I am assuming you actually have a server after the @. I suspect what's happening is that you are running sleep on the windows server, rather than the \scriptname.ps1 file. Try something like this:
GROUP=$1 ACCOUNT=$2 ssh Administrator@ "\scriptname.ps1 -group $Group -account $ACCOUNT"
SSH should take care of the delay while logging in and the exit on completion of the command natively.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com