• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 482
  • Last Modified:

Powershell script connect-mstsc.ps1 doesnt run

Hi

I am trying to use this ps1 script written by Jaap Brasser.  But it doesnt do anything when I run it and I'm pretty sure I'm missing something very elementary!  

The script is:
http://gallery.technet.microsoft.com/scriptcenter/Connect-Mstsc-Open-RDP-2064b10b

I have tried using "set-executionpolicy Unrestricted"

I get no error message, just a new line in the console as if it worked correctly.  Mstsc.exe doesn't appear.

Can someone point out the obvious for me?

Thanks
0
WBC2013
Asked:
WBC2013
  • 3
  • 2
1 Solution
 
footechCommented:
Did you read the included help in the script?  Just running the .PS1 file (dot source it to make it available in the global scope) creates the function.  Then you have to run the function, submitting the needed parameters.
0
 
WBC2013Author Commented:
Ah this is the elementary mistake yes.

So I run .\connect-mstsc.ps1

But I get an error when trying to use the connect-mstsc function (as per the help notes).  It says the cmdlet, function or script file is not recognised.

e.g \> connect-mstsc -computerName testPC -user TestUser -password TestPassword
0
 
footechCommented:
You need to dot source it, otherwise it will only be available in the script scope.
. .\connect-mstsc.ps1

Open in new window

0
 
WBC2013Author Commented:
much appreciated!
0
 
footechCommented:
No problem.  A couple help topics that I think would be helpful and you may want to read are:
about_scope
about_operators
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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