Below is my command to perform one activity. It accepts few arguments which is fine and no issues there. But when we run that command in cmd, it asks for password and confirm password.
I want to automate that passowrd and confirm password part. How can I do that?
Example:
When we run below command in cmd -
c:\Test\myscript.exe --arg1 --arg2 --config “c:\Temp\config.cfg” --confirm
It shows below in same command prompt-
Performing the script execution for ABCD.
Enter password:
Type again to confirm:
What I need is, How can I automate this enetering of password and confirm password, considering I have the password.
Please help here.
When you post code, error messages, sample data or console output format it as code, please.
Here you can read how that works:
You can go back and edit your existing post. You don’t have to create a new one.
Thanks in advance.
Now to your actual question:
If it’s about automating a task I’d recommend to use a scheduled task and set it up to run the task using the needed credentials to accomplish the tasks. You could even allow other users with less privileges to run this task.
The ability to automate the password entry is going to depend on myscrpt.exe and it’s capabilities. Without knowing what myscript.exe is, we’d just be making guesses.
Thanks for you reply. Consider Myscript.exe as any third party software and we cannot alter or modify it. below powershell link has similar solution but I am not able to make it. Could you please help me here.
Just check the last script of below link. Something similar I needed.
Thanks for you reply. Consider Myscript.exe as any third party software and we cannot alter or modify it. below powershell link has similar solution but I am not able to make it. Could you please help me here.
Just check the last script of below link. Something similar I needed.
Well any third party software will have its own parameters and options. It’s not up to powershell or cmd or any shell if that tool can have password input automated. It’s strictly up to that tool and its characteristics.
It does have parameters but not for password. Using Docker we can automate this but it requires additional software to be installed. I guess using New-Object System.Diagnostics.Process this can be automated. I need to do more research.
Again - if you set it up as a scheduled task with the according account including its password you can run ANY internal or external program with it. And it does not have to run on a schedule. You can set it up to run on demand … even by less privileged users.
That is not the feasible solution in my case because Password may change and need to pass as a parameter. so whatever latest password is there it will pass it to the script.
So you need to query the account and password each time you run it, create a credential object in PowerShell with this information and pass it to your third party tool. For example with Invoke-Command.
There is no built in cmdlet or function to securely manage stored credentials.
When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.
Let me count the ways that a PowerShell script can obtain credentials on demand.
SecretManagement (as Olaf posted)
default store is local only.
There is a Credential Module for interfacing into Credential Manager.
Again this solution local only.
HashiCorp Vault.
Manage your own HashiCorp Vault instance (open source and Enterprise grade)
Keybase Vault. PSKeyBase module
My preference isn’t to not use SecretManagement abstraction to interface with non-MS vaults.
Requires Keybase client to be installed and running.