2

I would like to invoke Clearprojexp.exe as runas different user.

I was trying to use as follows in my powershell prompt

runas /noprofile /user:Domain\UserName Clearprojexp -credential (Powershellfile.ps1 -get "E:\EncryptedPwd.txt")

But it asks to enter password manually. As powershell has provision to store Password as encrypted string in file, is there any way i can pass the encrypted password from the file?

My intention is to just run a script to open Clearcase project explorer as runas different user.

There is a /Savecred option but i am not sure whether it would store the password in secure form.

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230
  • Why not using the native PowerShell command [`Invoke-Command -Credential $Credential`](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/invoke-command)? For saving your credential in a file, see: [save PSCredential in the file](https://stackoverflow.com/a/40029496/1701026). – iRon Sep 15 '22 at 09:39

2 Answers2

0

You could try a powershell script equivalent of runas, like this one

like using runas.exe to elevate a process (like su in unix/linux) but runas /savecred and saving credentials can be “disabled” by policy. That’s why i use su.ps1 through su.bat instead of runas.exe. Several idea has been implemented from other posts. Thank you for their/your help:

$ScriptFilenam [-UserName:]UserName [[-FilePath:]program [arg1] ['arg 2'] [arg...]]
               [-SaveCredential] [-RdpSaveCredential] [-DeleteCredential] [-Help]
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Other powershell idea: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/132e170f-e3e8-4178-9454-e37bfccd39ea/, http://gallery.technet.microsoft.com/scriptcenter/PowerShell-function-to-3e9766e3 (which is a shorter version of the script mentioned above), http://blogs.msdn.com/b/alanpa/archive/2006/08/16/703031.aspx – VonC Mar 30 '12 at 10:36
0

Runas does not take a credential in the fashion you're attempting to pass it as. -credential is a powershell switch, it will not work with Runas. If you type Runas /? at the cmdline you will see down at the bottom that the first NOTE: says "Enter User's passsword only when prompted. This utility will prompt you to enter the password of the user.

Christopher Douglas
  • 1,519
  • 2
  • 9
  • 16