Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to call a sub script from the main script on a remote server

$
0
0
HI i am having problem in calling a sub script from the main script using powershell on a remote server
I have the main script which is call 1.ps1
the other script is called 2.ps1

Here are the scripts

    1.ps1 contains this code &("C:\Users\test\Desktop\remotely run scripts\2.ps1")
    2.ps1 contains this code new-item -type file c:\itworksagain.txt

The command which i am using is as follows

    invoke-command -computer "remoteServer" -filepath "C:\Users\test\Desktop\remotely run 
    scripts\1.ps1"

I am getting an error

The term 'C:\Users\test\Desktop\remotely run scripts\2.ps1 is not recognized as the name of a cmdlet, function,


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>