I am using the following script to pass SQL credentials at the command line , but I need user to enter the password for the SQL user not the Windows Credentials in it and to make sure that the password is not revealed in clear text when inserted in the prompt. Here is my script:
Param(
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string]$dbusername="",
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string]$password="",
[Parameter(Mandatory=$True)]
[ValidateNotNullOrEmpty()]
[string]$Machine=""
)
This works fine, but I would like to make sure that the password is hidden when user is inserting it in the prompt.
I have used this line to do it
Read-Host -Prompt "Enter your password" -AsSecureString
But this cannot be inserted in the Param block, and I I insert it afterwards it has no effect.
How can I mask the password when is inserted by the user at the prompt?
For PS V3,casting to securestring ie: [securestring]$password="" should be sufficient.
You will certainly have to convert back this securestring to plain text before using it with your app. This can be done with:
$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($password)
$clearpassword = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr)
Related
when I try to run the command create role new_user with passowed 'passowrd' login; it just gives me postgres'> on a new line. I am logged in as a superuser in aws postgres rds. what does this mean and how do I fix this?
That means that your typing on the command line is as sloppy as your typing in Stackoverflow, and you didn't close the single quotes properly. Now psql is waiting for you to continue the string input.
Reset the query buffer by hitting Ctrl+C and start again, taking care that you balance the quotes.
Perhaps the password contains a single quote, which you would have to escape by doubling it.
Let me remark that setting a password like this is unsafe: the password is visible on your screen, will end up in your history file, is sent over the line in clear text and may end up in the PostgreSQL log. Use \password to set the password, then you also don't have to worry about escaping single quotes.
I am modyfying a SQLplus script that creates a user, connects to the user and creates tables and puts values in those tables. This script had a set username and password for user like the below
CONNECT store/store_password#test
However I want to replace store_password with a variable v_store_password which I have put at the start:
ACCEPT v_store_password CHAR PROMPT 'Please type in store password: ' HIDE
Basically what I tried was this:
CONNECT store/&v_store_password || #test;
The above unfortunately does not work. I read some where that a "." can be used but it doesn't work.
How to concatenate or add to Substition variables?
Also how to add numbers to these variables?
/*make a file called file.connection.txt and enter username#password#tnsname#*//* write below code into batch file*/CLSECHO TITLE Database test script (ORACLE)#echo offclsfor /f "tokens=1-5 delims=#" %%a in (file_connection.txt) do (sqlplus -l "%%a/%%b#%%c " #test.sql)
exit
I actually dicovered that I have not included the & in front of variable like below
CREATE USER store IDENTIFIED BY v_store_password;
and the "." is varables concatenation character which ends them so the solution is:
CONNECT store/&v_store_password.#test;
I have a powershell script that would like user to enter password. It calls a function to get a pop up box for the user input. Now it is in plaintext. I'd like it to be hidden/masked
This is the function created :---
function Read-InputBoxDialog([string]$Message, [string]$WindowTitle, [string]$DefaultText)
{
Add-Type -AssemblyName Microsoft.VisualBasic
return [Microsoft.VisualBasic.Interaction]::InputBox($Message, $WindowTitle, $DefaultText)
}
This is the way i called the function from powershell : ---
$SQLPassword = Read-InputBoxDialog -Message "Please enter SQL password used to connect to Database Server" -WindowTitle "Sql Server Authentication" -DefaultText ""
How do I ask mask the password as **** ?
Instead of an input box, Powershell has got its own implementation Get-Credential. It stores credentials as secure strings, so getting a plaintext password requires some tweaking. Like so,
$cred = Get-Credential -Message "Enter Sql password"
$cred.GetNetworkCredential().username # Show the username
$cred.GetNetworkCredential().password # Show the password
I want to stop my HSQL DB from command line using command
java -jar hsqldb/lib/sqltool.jar --rcfile=sqltool.rc --sql "shutdown;" localhost-sa-myPassword
This command expects sqlTool.rc file which contains DB related information like user id and password. This RC file contains password in plain text.
Is there any way to hide that password in RC file?
Or is there any way to encrypt this RC file and use it?
Or is it possible to forcibly stop the server without giving id/pwd?
Any other approach is also welcome as long as password is not visible in plain text
Thanks in advance
I got alternative approach for this.
Connection c = DriverManager.getConnection(
"jdbc:hsqldb:file:/opt/db/testdb;shutdown=true", "SA", "");
create the connection as mentioned above.
Then execute sql query as given below
stmt.execute("shutdown");
This will shutdown the HSQL DB
I found the syntax to change a user password through command prompt. I am using:
net user username password
I have sucessfully changed the password to a regular password. I can not figure out how to change it to a pass-sentence. How would I write the syntax for a password with spaces in it?
For instance, please explain how I would write "My new password." in cmd...because this doesnt work:
net user testuser2 My new password.
I am sure that it is case sensative, no? If its case sensative for the password, why wont it recognise the sapces as part of the password?
Thank you for your time.
Try surrounding the password with quotation marks, such as:
net user username "My new password"
Typically you can put the phrase in double quotes ex "My new password" is you have spaces in you command line.