Pau Lo
asked on
powershell execution
How to you run a powershell script?
Downloaded the tool:
%SystemRoot%\system32\Wind owsPowerSh ell\v1.0\p owershell. 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>myscri pt.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?
Downloaded the tool:
%SystemRoot%\system32\Wind
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>myscri
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?
ASKER
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\myscri pt.ps1'
Regards
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\myscri
Regards
Set-executionpolicy is a separate expression.
ASKER
Cheers
ASKER
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 <<<<
PS C:\documents and settings\me\desktop> .\ms.ps1
that reads:
File C:\documents and settings\me\Desktop\ms.ps1
At line:1 char:12
+ .\ms.ps1 <<<<
ASKER
I am running it under basic domain user priveleges not domain admin but I do have local admin account for this machine if required
Have you run:
set-executionpolicy remotesigned
set-executionpolicy remotesigned
ASKER
Yeah
Strange, it should run it.
Try the following:
set-executionpolicy bypass
And try to run the script again.
Try the following:
set-executionpolicy bypass
And try to run the script again.
ASKER
Will do gimme two mins
ASKER
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
Set-ExecutionPolicy : A parameter cannot be found that matches parameter name 'bypass'. At line:1 char:20 +set executionpolicy <<<< bypass
So you have PowerShell 1.0?
ASKER
Hi soostibi - yeah thats right, why do you ask?
Just wondering how to resolve this issue. For v1.0 you may use:
set-executionpolicy unrestricted
set-executionpolicy unrestricted
ASKER
will give it a go when back in the office, cheers
ASKER
maybe i should download the latest version of pweshell, would that be v2?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cool, it works.
.\mycsript.ps1
or
& 'C:\documents and settings\me\desktop\myscri
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