Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How do I control the user context in my powershell

Closed Thread
 
Thread Tools Display Modes
Old 12-29-2006   #1 (permalink)
paulmcd
Guest


 

How do I control the user context in my powershell

I know powershell is for admins...

but how do I control the user context used by my cmdlets.

let's say for example, i am logged in as paulmcd .

i am NOT a domain admin or an exchange admin.

however, i want to perform domain admin actions in my powershell, like
adding a new user, or mailbox, or other admin stuff.

how do i specify which credentials a cmdlet should use when doing it's
thing.

for example, in exchange, i am trying to do a "new-accepteddomain"
cmdlet.

this requires me to be an exchange admin.

but i don't want to login as an exchange admin.

i have noticed that "SOME" cmdlets take the -credentials paramete,
which is a PSCredentials object.

but it appears that NOT all of them take it.

or do they?

here is my question:

is there some global , fool proof way, that I can provide crednetials
that I want a cmdlet to run as ?

this is very similar to the runas command in win32.

how do i do that with powershell .

note: ideally, this is generic, and in a way I can also control it
programmatically, as I am also calling cmdlets from c# .net code.

this is where it really kicks in, as if you want to call a cmdlet from
asp.net, you can be pretty sure your asp.net is NOT running as a domain
admin. but i want to be able to still use powershell, so need to pass
in credentials somehow. i am using RunspaceInvoke from asp.net.

thanks!!!
-paulmcd

Old 12-29-2006   #2 (permalink)
paulmcd
Guest


 

Re: How do I control the user context in my powershell

I should add as a note... the real thing I am trying to do here is use
powershell from asp.net

my scenario is i have users, that are NOT domain admins.

they log into my asp.net site.

i control what they can and can't do.

some of the actions, require me making changes in exchange server or
ad.

specifically like calling new-accepteddomains (exchange 12) .

i do NOT want the asp.net user to have these rights.

so i want to call the powershell cmdlet, using my exchange admin creds.

hope this clears up what my scenario is.

i'm using asp.net and RunspaceInvoker.

thanks!!
-paul

Old 01-05-2007   #3 (permalink)
Jonathan Kalmes
Guest


 

Re: How do I control the user context in my powershell

paulmcd wrote:
<snip>
> is there some global , fool proof way, that I can provide crednetials
> that I want a cmdlet to run as ?


I have the same issue, but that's mostly just because I don't want to
load and unload my "super" account profile every time I want to run a
quick script to check on our Exchange queues.

I see two sides to this question (both of which I could use answers for)...

-Does anyone have a way to run an individual cmdlet in a particular
security context?
-Is there a way to switch the security context of a Powershell script or
session without reloading PS using a RUNAS or Explorer's "Alternate
Credentials" option?

--Jonathan "smthng" Kalmes
http://smthng.info
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control the Maximum allowed User Sessions in Fast User Switching lmlm Vista General 1 03-19-2008 08:19 AM
Per-user shell context menu extensions? Keith MacDonald Vista security 6 01-17-2007 07:52 AM
finding the logged on user (user name) with powershell using WMI? klumsy@xtra.co.nz PowerShell 3 09-25-2006 12:21 PM
job control in PowerShell Adam Milazzo [MSFT] PowerShell 6 09-01-2006 03:42 PM
Finding out what control the context menu call belongs to? Mario Goebbels [489782] Avalon 0 03-24-2006 10:45 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50