Solved

Powershell script connect-mstsc.ps1 doesnt run

Posted on 2014-09-26
5
436 Views
Last Modified: 2014-09-26
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
Comment
Question by:WBC2013
  • 3
  • 2
5 Comments
 
LVL 40

Expert Comment

by:footech
ID: 40345669
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
 

Author Comment

by:WBC2013
ID: 40345678
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
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 40345735
You need to dot source it, otherwise it will only be available in the script scope.
. .\connect-mstsc.ps1

Open in new window

0
 

Author Closing Comment

by:WBC2013
ID: 40345748
much appreciated!
0
 
LVL 40

Expert Comment

by:footech
ID: 40346325
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question