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
Related
Actually I'm working in Hana DB and Suse Enterprise Server, my objective is use the Scripting and Cronjob to automatize some tasks.
Using hdbuserstore located in /usr/sap/hdbclient I've created and profile for create a HANA command line secure connection, check this link.
My profile works perfect, I did:
Create a user backup into HanaDB, using
*create user backup password Aa12345678*
Then, I've added BACKUPS PRIVILEGES to it:
*grant BACKUP ADMIN to backup*
Later, I've used ./hdbuserstore to create a profile to use via command line:
./hdbuserstore SET back5prf localhost:30015 backup Aa12345678
Then list the profile: ./hdbuserstore LIST
DATA FILE : /root/.hdb/hanab1/SSFS_HDB.DAT
KEY BACK2PRF
ENV : NDB#hanab1:30015
USER: backups
KEY BACK3PRF
ENV : hanab1:30015
USER: backups
KEY BACK5PRF
ENV : localhost:30015
USER: backup
KEY BACKUPSTORE
ENV : localhost:30015
USER: backups
How you guys can see, the profile is ready. Finally when I tried to use the following command:
./hdbsql -U BACK5PRF "SELECT * FROM SCHEMAS"
The system returns the following message:
* 10: invalid username or password SQLSTATE: 28000
Why I'm getting this error event the user and password are ok?
There is other way to execute HANA SQL query without enter into the hdbsql console to automate via Scripting?
This error message can have several causes:
actual wrong user name/password
user account is locked (you need to unlock it in the user management)
user account is a restricted user and not allowed to connect via ODBC/JDBC or from anywhere "outside" SAP HANA
I suggest you make sure that the user works in SAP HANA studio and then setup the cron job.
I had the same issue, the cause was that I used a $ in my password which gets treated as special character in linux (and there more special characters).
So in this case one solution is not to use any character that a treated as special characters or to escape them which in my case resulted the following command for hdbuserstore:
hdbuserstore SET BKADMIN 1xx.x.x.xx:30015 ADMIN_BACKUP password\$12
Check the thread on answer.sap.com.
This might seem like an easy question but I had to ask. I have a powershell script that calls another script and it patches a SQL database. Normally you can just patch all databases at once, but sometimes that halts and you have to cancel it and do single datasbases instead. Here is the script I made to do this sqlps is already run prior to this code segment:
do {
$dabname = Read-Host "Enter the database name or (stop) to end"
if($dabname -ne "stop") {
$sclient = Read-Host "Enter Client name"
$date = Get-Date -Format "yymmdd"
$sqlsrvname = Read-Host "Please enter the sql server name"
SQL-remote -DBServer $sqlsrvname -DBNameList $dabname –client $sclient –mainline HTFS –datefolder $date –targetenv $sqlsrvname}
}until($dabname -eq "stop")
but it keeps telling me the server doesnt exist, I cant figure out what I did wrong can someone please tell me whats missing? This script its suppose to; once working; keep asking if you want to patch more databases after patching them until you say "stop." The sql-remote is a function in which the sql patch script is stored.
I am creating a "change password" form where the user is required to enter the previous password first, then a new password (twice).
I should compare the entered "previous password" to the one already stored.
My web application uses an LDAP server to store user credentials. Password is apparently stored using SHA.
So what I do is get the previous password entered by the user, digest it using SHA1, then compare it.
String oldPass = request.getParameter("oldpass");
String enteredOldPass= App.getInstance().getCipher().cipher(oldPass);
String ldapPassword= ctx.get("userpassword");
But this isn't working, because the passwords are different. When I store "test" in the LDAP I obtain {sha}qUqP5cyxm6YcTAhz05Hph5gvu9M= when calling .get("userPassword"), whilst I get a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 when hashing "test" by myself.
What am I doing wrong here? It seems that a step is missing since my result is purely hex, while the one I get from the LDAP is ASCII. But I tried converting the string to hex (using string to hex online converters) but the result is still differnet.
You don't do any of this.
You attempt to rebind as the user with that password. It either succeeds or fails. That tells you whether it was right or wrong. The API and protocol and server will take care of any hashing required.
Or, if you're using an LDAP server that supports the extended change-password operation, you provide the old and new passwords in the extended operation.
you must convert to binary, then convert to base64. Try this:
echo -n "test" | sha1sum | awk '{print $1}' <br>
The result will be a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
echo -n "test" | sha1sum | awk '{print $1}' | xxd -r -p | base64
The result will be qUqP5cyxm6YcTAhz05Hph5gvu9M=
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)
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.