• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 136
  • Last Modified:

how to use ScriptBlock parameter in invoke-SSHCommand in powershell

Hi,

I am trying to run linux script from windows server. I am using below command .

Invoke-SSHCommand  -ComputerName $temp -cred $cred -ScriptBlock $ScriptBlock

I am not sure how to pass a linux script in 'ScriptBlock' parameter.


Please help.
0
kannu kc
Asked:
kannu kc
1 Solution
 
Gerwin Jansen, EE MVETopic Advisor Commented:
$ScriptBlock is a variable that you would need to fill before you call the script, like this for example:

$ScriptBlock =   {cd ~; ls;}

If you want to run a script that is already on the remote server then I would just put the script in there, or use -command:

-Command "/path/to/remote/scipt.sh"
0
 
PberSolutions ArchitectCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Gerwin Jansen EE MVE (https:#a42398788)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Pber
Experts-Exchange Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now