?
Solved

powershell  execution

Posted on 2011-05-11
18
Medium Priority
?
1,862 Views
Last Modified: 2012-05-11
How to you run a powershell script?

Downloaded the tool:

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

I open the powershell gui (powershell .exe)

Change the directory to where my ps1 file is so now at my powershell command prompt I have:

PS C:\documents and settings\me\desktop>

and I enter the name of the script i.e. myscript.ps1

so I have executed

PS C:\documents and settings\me\desktop>myscript.ps1

I get an error:

The term 'myscript.ps1' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and tr
y again.
At line:1 char:10
+ revgui.ps1 <<<<

Where am I going wrong?
0
Comment
Question by:pma111
  • 11
  • 7
18 Comments
 
LVL 13

Expert Comment

by:soostibi
ID: 35736309
You have to use relative or absolute path:

.\mycsript.ps1

or

& 'C:\documents and settings\me\desktop\myscript.ps1'

Second time as the path include space you have to put it into quotation marks and use the invoke operator (&).

You also have to enable script execution before:

set-executionpolicy remotesigned
0
 
LVL 3

Author Comment

by:pma111
ID: 35736605
Thanks

Do you first execute set-executionpolicy remotesigned (and hit return)

or is it one continual string i.e.

PS C:\documents and settings\me\desktop> set-executionpolicy remotesigned & & 'C:\documents and settings\me\desktop\myscript.ps1'

Regards
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35736622
Set-executionpolicy is a separate expression.
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 3

Author Comment

by:pma111
ID: 35736629
Cheers
0
 
LVL 3

Author Comment

by:pma111
ID: 35736764
I now get an error whilst execting:

PS C:\documents and settings\me\desktop> .\ms.ps1

that reads:

File C:\documents and settings\me\Desktop\ms.ps1 cannot be loaded. The file C:\documents and settings\me\Desktop\ms.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signng" for more details..
At line:1 char:12
+ .\ms.ps1 <<<<
0
 
LVL 3

Author Comment

by:pma111
ID: 35736771
I am running it under basic domain user priveleges not domain admin but I do have local admin account for this machine if required
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35737044
Have you run:

set-executionpolicy remotesigned

0
 
LVL 3

Author Comment

by:pma111
ID: 35737098
Yeah
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35737130
Strange, it should run it.
Try the following:

set-executionpolicy bypass

And try to run the script again.
0
 
LVL 3

Author Comment

by:pma111
ID: 35737153
Will do gimme two mins
0
 
LVL 3

Author Comment

by:pma111
ID: 35737185
When I issue that (Set-executionpolicy bypass) command I get:

Set-ExecutionPolicy : A parameter cannot be found that matches parameter name 'bypass'. At line:1 char:20 +set executionpolicy <<<< bypass
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35737485
So you have PowerShell 1.0?
0
 
LVL 3

Author Comment

by:pma111
ID: 35737524
Hi soostibi - yeah thats right, why do you ask?
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35738160
Just wondering how to resolve this issue. For v1.0 you may use:

set-executionpolicy unrestricted
0
 
LVL 3

Author Comment

by:pma111
ID: 35746412
will give it a go when back in the office, cheers
0
 
LVL 3

Author Comment

by:pma111
ID: 35746417
maybe i should download the latest version of pweshell, would that be v2?
0
 
LVL 13

Accepted Solution

by:
soostibi earned 1400 total points
ID: 35748514
Have you tried the "unrestricted" option?
V2 is the latest version.
0
 
LVL 3

Author Comment

by:pma111
ID: 35814900
Cool, it works.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month15 days, 23 hours left to enroll

850 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