/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" do the MSH - CMD- MSH loop. & RunAs in MSH "," list processes of remote computer from MSH "," MSH Error message line number and Trap. "," Strange behavour of get-member on DataTables "," CodeSigning in Monad" Shell Beta 2 (for .NET Frame... "," WMI viewer script for MSH (GUI) "," Monad Release for Whidbey RTM "," Thow Dices in MSH "," when to change your clock ? ask Monad !! "," AD Infastructure exploring with MSH "," ")

Monday, October 31, 2005


Runas with loading Profile script in MSH

In the Last post do the MSH - CMD- MSH loop. & RunAs in MSH ,

I descibed a way to do a Runas in MSH, but your profile does not get loaded.

to do this You need anOther Object a System.Diagnostics.ProcessStartInfo Object
You can fill the properties and then do a : [System.Diagnostics.Process]::start on the Object.

as you can see in the properties list I posted Below Also You have Compleet Control of the Process.

Before I did not see the use of the Get-Credential CMD-let (as for WMI) but here it is KEWL !!!

gr /\/\o\/\/

MSH> $PSI = new-object System.Diagnostics.ProcessStartInfo

MSH> $psi.LoadUserProfile = $true

MSH> $psi.filename = "MSH.exe"

MSH> $psi.UseShellExecute = $false

MSH> $cred = get-credential

Cmdlet get-credential at command pipeline position 1

Supply values for the following parameters:


User: Test

Password for user Test: *******

MSH> $psi.Username = $cred.userName

MSH> $psi.Password = $cred.Password

MSH> [System.Diagnostics.Process]::start($PSI)

Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName

------- ------ ----- ----- ----- ------ -- -----------

0 0 60 76 2 0,02 2220 msh


Other Properties you can Set are :

MSH C:\Documents and Settings\mow> $psi

Verb :
Arguments :
CreateNoWindow : False
EnvironmentVariables : {pathext, homepath, sdktoolpath, lapi, clientname, systemroot, comspec, appdata, allusersprofile, processor_archi
tecture, commonprogramfiles, lib, number_of_processors, homedrive, username, temp, processor_identifier, processo
r_revision, sessionname, path, processor_level, include, computername, winfxsdk, os, systemdrive, vs71comntools,
logonserver, userprofile, wcp, programfiles, userdomain, tmp, fp_no_host_check, windir}
RedirectStandardInput : False
RedirectStandardOutput : False
RedirectStandardError : False
StandardErrorEncoding :
StandardOutputEncoding :
UseShellExecute : False
Verbs : {open, runas}
UserName : Test
Password : System.Security.SecureString
Domain :
LoadUserProfile : True
FileName : MSH.exe
WorkingDirectory :
ErrorDialog : False
ErrorDialogParentHandle : 0
WindowStyle : Normal

Comments: Post a Comment

<< Home


October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?