• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

run powershell always as admin ?

R

Robert Ludig

#1
A lot of powershell related tasks and commands require elevated right.
How can I either

a) run the powershell always as administrator
or
b) temporarily elevate the rights
?

I suppose a) is a nono ? :)
 

My Computer

R

RichS

#2
If you are talking about running on Vista you can right click icon & run as
administrator
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Robert Ludig" wrote:

> A lot of powershell related tasks and commands require elevated right.
> How can I either
>
> a) run the powershell always as administrator
> or
> b) temporarily elevate the rights
> ?
>
> I suppose a) is a nono ? :)
>
>
 

My Computer

R

Robert Ludig

#3
On 25 Feb., 16:32, RichS <R...@discussions.microsoft.com> wrote:
> If you are talking about running on Vista you can right click icon & run as
> administrator


Is there a way to create a shortcut or link that has "run as
administrator" applied automatically? So that I do not have to bother
to rightclick and can use keyboardhortucts to run the powershell?

Also, is it safe to always runt the whole shell elevated?

Is there a way to temporarily elevate the rights for specific tasks/
commands? It seems I don't get the UAC promt when trying to execute
commads that need elevated rights and the shell is not run as
administrator. Instead I just get a permission error.
 

My Computer

D

Daymon

#4
In XP (or Vista), just create a standard shortcut to the powershell exe.

Then in the properties of the shortcut, click the advanced button and check
the run with different credentials.

Now when you dbl-clk the shortcut, windows brings up the run-as dialog for
you.

"Robert Ludig" wrote:

> On 25 Feb., 16:32, RichS <R...@discussions.microsoft.com> wrote:
> > If you are talking about running on Vista you can right click icon & run as
> > administrator

>
> Is there a way to create a shortcut or link that has "run as
> administrator" applied automatically? So that I do not have to bother
> to rightclick and can use keyboardhortucts to run the powershell?
>
> Also, is it safe to always runt the whole shell elevated?
>
> Is there a way to temporarily elevate the rights for specific tasks/
> commands? It seems I don't get the UAC promt when trying to execute
> commads that need elevated rights and the shell is not run as
> administrator. Instead I just get a permission error.
>
>
 

My Computer

R

Robert Ludig

#5
On 26 Feb., 20:10, Daymon <Day...@discussions.microsoft.com> wrote:
> In XP (or Vista), just create a standard shortcut to the powershell exe.
>
> Then in the properties of the shortcut, click the advanced button and check
> the run with different credentials.
>
> Now when you dbl-clk the shortcut, windows brings up the run-as dialog for
> you.
>
>
>
> "Robert Ludig" wrote:
> > On 25 Feb., 16:32, RichS <R...@discussions.microsoft.com> wrote:
> > > If you are talking about running on Vista you can right click icon & run as
> > > administrator

>
> > Is there a way to create a shortcut or link that has "run as
> > administrator" applied automatically? So that I do not have to bother
> > to rightclick and can use keyboardhortucts to run the powershell?

>
> > Also, is it safe to always runt the whole shell elevated?

>
> > Is there a way to temporarily elevate the rights for specific tasks/
> > commands? It seems I don't get the UAC promt when trying to execute
> > commads that need elevated rights and the shell is not run as
> > administrator. Instead I just get a permission error.- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -


This approach would still require me to enter the password for the
admin account each time I run the shell. Wich is a bit annoying when
using the shell frequently. Also what happens when I doubleclick .ps1
files (wich starts the powershell), the executing script does not have
elevated rights ...
 

My Computer

J

Joris van Lier

#6
Robert Ludig wrote:
> On 26 Feb., 20:10, Daymon <Day...@discussions.microsoft.com> wrote:
>> In XP (or Vista), just create a standard shortcut to the powershell
>> exe.
>>
>> Then in the properties of the shortcut, click the advanced button
>> and check the run with different credentials.
>>
>> Now when you dbl-clk the shortcut, windows brings up the run-as
>> dialog for you.
>>
>>
>>
>> "Robert Ludig" wrote:
>>> On 25 Feb., 16:32, RichS <R...@discussions.microsoft.com> wrote:
>>>> If you are talking about running on Vista you can right click icon
>>>> & run as administrator

>>
>>> Is there a way to create a shortcut or link that has "run as
>>> administrator" applied automatically? So that I do not have to
>>> bother
>>> to rightclick and can use keyboardhortucts to run the powershell?

>>
>>> Also, is it safe to always runt the whole shell elevated?

>>
>>> Is there a way to temporarily elevate the rights for specific tasks/
>>> commands? It seems I don't get the UAC promt when trying to execute
>>> commads that need elevated rights and the shell is not run as
>>> administrator. Instead I just get a permission error.- Zitierten
>>> Text ausblenden -

>>
>> - Zitierten Text anzeigen -

>
> This approach would still require me to enter the password for the
> admin account each time I run the shell. Wich is a bit annoying when
> using the shell frequently. Also what happens when I doubleclick .ps1
> files (wich starts the powershell), the executing script does not have
> elevated rights ...


Maybe you can use http://sudowin.sourceforge.net/

regards
Joris
 

My Computer

L

Lee Holmes [MSFT]

#7
In Vista's UAC model, you don't enable your Administrator rights for an
application until you've gone through an elevation prompt. So yes, this
means that you will be required to type in your credentials (or click "OK")
whenever you want to load an elevated program (powershell included.) If
there are aspects of this that frustrate you, then the best bet is to
provide your feedback to the Vista UAC team --
http://blogs.msdn.com/windowsvistasecurity/ may be a good starting point.

As for your second point, double-clicking a script doesn't start PowerShell
unless you've specifically modified your system to enable that. In that
case, you may want to create a right-click menu option to execute the script
using the Elevated PowerShell link that Daymon spoke about.

That said, Michael Murgolo (who wrote "PowerShell Here"
http://www.leeholmes.com/blog/PowerShellPromptHerePowerToy.aspx) will soon
be releasing a little utility pack to make some of these scenarios easier.

In terms of the safety of running PowerShell as administrator -- it's
definitely a best practice to run without Administrator rights whenever
possible. If you're just navigating the filesystem, changing files, running
utility scripts, etc -- then I would advise running those in a regular
PowerShell window. If you need to modify administrative data on the
computer, then by all means perform that action in an elevated window.

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


UAC is a core feature of Vista, so
"Robert Ludig" <schwertfischtrombose@gmx.de> wrote in message
news:1172561524.261387.249790@v33g2000cwv.googlegroups.com...
> On 26 Feb., 20:10, Daymon <Day...@discussions.microsoft.com> wrote:
>> In XP (or Vista), just create a standard shortcut to the powershell exe.
>>
>> Then in the properties of the shortcut, click the advanced button and
>> check
>> the run with different credentials.
>>
>> Now when you dbl-clk the shortcut, windows brings up the run-as dialog
>> for
>> you.
>>
>>
>>
>> "Robert Ludig" wrote:
>> > On 25 Feb., 16:32, RichS <R...@discussions.microsoft.com> wrote:
>> > > If you are talking about running on Vista you can right click icon &
>> > > run as
>> > > administrator

>>
>> > Is there a way to create a shortcut or link that has "run as
>> > administrator" applied automatically? So that I do not have to bother
>> > to rightclick and can use keyboardhortucts to run the powershell?

>>
>> > Also, is it safe to always runt the whole shell elevated?

>>
>> > Is there a way to temporarily elevate the rights for specific tasks/
>> > commands? It seems I don't get the UAC promt when trying to execute
>> > commads that need elevated rights and the shell is not run as
>> > administrator. Instead I just get a permission error.- Zitierten Text
>> > ausblenden -

>>
>> - Zitierten Text anzeigen -

>
> This approach would still require me to enter the password for the
> admin account each time I run the shell. Wich is a bit annoying when
> using the shell frequently. Also what happens when I doubleclick .ps1
> files (wich starts the powershell), the executing script does not have
> elevated rights ...
>
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)