Solved

Powershell script connect-mstsc.ps1 doesnt run

Posted on 2014-09-26
5
434 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 39

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 39

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 39

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

778 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