The DBHistory.com PowerShell cmdlets now asks for login credentials with an interactive prompt if credentials are not provided as parameters. Also, the login credentials can be provided as a PSCredential for secure scripting. The cmdlet requires two set of credentials:
- The DBHistory.com credentials required to log in into DBHistory.com.
- Credentials required to log into the SQL Server being added. By default the credentials for logging in into SQL Server are implicit as Windows authentication is used (Integrated Authentication, or SSPI). SQL Server credentials are only needed if SQL Authentication is desired.
Provide explicit DBHistory.com user name and password
If both -DBHistoryUserName and DBHistoryUserPassword are present and no -DBHistoryCredential is provided then the user name and password provided will be used to log in into DBHistory.com.
PS>Install-DBHistory -DBHistoryUserName me@example.com `
-DBHistoryUserPassword BgfS9DQh `
-ServerName ...
This option is recommended only when working in an interactive PowerShell session in a completely secure environment. Note that the passwords you type may be persisted in PowerShell session history. Do not use explicit passwords in scripts.
Prompt for DBHistory.com user name or password
If any of -DBHistoryUserName or -DBHistoryPassword is omitted and no -DBHistoryCredential is provided, then a credential prompt is displayed asking for the user name and password to be used to log in into DBHistory.com.
PS>Install-DBHistory -ServerName ...
This option is perfect for interactive PowerShell session in an insecure environment. The prompt will hide the password you type, and the password will not be persisted anywhere.
Using a PSCredential for DBHistory.com
If a -DBHistoryCredential parameter is provided then this will be used to log in into DBHistory.com. You can create the PSCredential type parameter by using the Get-Credential cmdlet or via New-Object, see PowerShell – How to create a PSCredential object for details.
PS>$credential = Get-Credential
Install-DBHistory -DBHistoryCredential $credential `
-ServerName ...
This option is perfect for using Install-DBHistory cmdlet in automated scripts because the PSCredential object can be passed as an argument to the script.
Provide explicit SQL Authentication user name and password
If you provide both -SQLUserName and -SQLUserPassword then the cmdlet will use them to log in, as SQL Authentication, into the SQL Server instance you are adding.
PS>Install-DBHistory -ServerName ... `
-SQLUserName sa `
-SQLUserPassword Pc8qV3h2
This option is only recommended when working in a completely secure environment, as the password provided may be saved by the PowerShell session in the commands history. Do not use explicit passwords in scripts.
Prompt for SQL Authentication password
If you only provide the -SQLUserName parameter then the cmdlet will use SQL authentication and it will prompt for the password to use.
PS>Install-DBHistory -ServerName ... `
-SQLUserName sa
This option is perfect for interactive PowerShell session in an insecure environment. The prompt will hide the password you type, and the password will not be persisted anywhere.
Use PSCredential for SQL Authentication
You can also provide a PSCredential object for the -SQLUserCredential parameter. In this case the cmdlet will use SQL Authentication, using the user name and password from the provided PSCredential object.
PS>$credential = Get-Credential
PS>Install-DBHistory -ServerName ... `
-SQLUserCredential $credential
This option is recommended when using Install-DBHistory is scripts, as the credential object can be passed as argument to the script.