/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" 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 "," Get Current dir in MSH consoleTtitle "," ")

Monday, October 31, 2005

 


do the MSH - CMD- MSH loop. & RunAs in MSH



while I was looping at the get-process on remote machine, I saw this nice overload of the Start function :

Public Shared Function Start(ByVal fileName As String, ByVal arguments As String, ByVal userName As String, ByVal password As SecureString, ByVal domain As String) As Process

While I was testing with this I entered the folowing line :

[System.Diagnostics.Process]::start("cmd.exe",$null,$cred.UserName,$cred.password,$null)

I was thinking about making a Run-as function but did not fill the credential object yet.

the result was a loop between MSH and CMD if the Prompt indicates your in HMS you are in CMD and if the prompt says CMD your are in MSH ;-)

you should try this !, and play with it a bit, realy funny (see example after signature )
you also loose history I think.

If you fill the Credetials it works as expected, and you have (the base of) a secure run-as function.

MSH C:\Documents and Settings\mow> $cred = get-credential ; [System.Diagnostics.Process]::start("cmd.exe",$null,$cred.UserName,$cred.passwor
d,$null)

Cmdlet get-credential at command pipeline position 1
Supply values for the following parameters:
Credential
User: mow
Password for user mow: *********


Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
0 0 1196 84 2 0,03 740 cmd
you can also use MSH for this so you can do a runas on the commandline.

gr /\/\o\/\/


Sample of the loop between MSH and the CMD

(while you at it try this with MSH and do this :)
MSH c:\>cd windows
MSH c:\windows\>LS
MSH c:\>LS
MSH G:\Monad> [System.Diagnostics.Process]::start("cmd.exe",$null,$cred.name,$cred.password,$null)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\mow>
Handles NPM(K) PM(K) WS(K) VS(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
29 2 1944 2384 29 0,03 3944 cmd


MSH G:\Monad> ver

Microsoft Windows XP [Version 5.1.2600]

C:\Documents and Settings\mow>ver
'ver' is not recognized as a Cmdlet, function, operable program, or script file.
At line:1 char:3
+ ver <<<<
MSH G:\Monad>



Comments:
Blogger /\/\o\/\/
There is a bug Filed on it as answer on my post in the NG.

gr /\/\o\/\/

It appears there is some contention between the processes for the console.
I will file a bug.

-- Jeff Jones [MSFT] Microsoft Command Shell Development Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights.
 
Post a Comment

Links to this post:

Create a Link



<< Home

Archives

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.
Google
 
Web mow001.blogspot.com

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