Solved

Powershell script connect-mstsc.ps1 doesnt run

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now