Powershell Parameters

Specifying correct type for password should be enough, try: Param ( [Parameter(Mandatory=$True)] [string]$FileLocation, [Parameter(Mandatory=$True)] [Security.SecureString]$password ) PowerShell will “mask” password (same as for read-host -asSecureString) and result type will be the one that other cmdlets may require. EDIT: After recent comments: solution, that gives both option to provide plain text password, or force user to … Read more

Connect to MySQL through command line without using root password?

Both for MySQL and PostgreSQL you can specify your user and password in local config file. .my.cnf for MySQL and .pgpass for PostgreSQL. These files should be in your home directory (i.e. ~/.my.cnf). .my.cnf: [mysql] user=user password=password .pgpass: host:port:database:user:password You can have a wildcard entry here, substituting any field for *******. PS: DO NOT EVER … Read more

How to pass command output as several arguments to another command

You can use xargs, with the -t flag xargs will be verbose and prints the commands it executes: ./command1 | xargs -t -n1 command2 -n1 defines the maximum arguments passed to every call of command2. This will execute: command2 word1 command2 word2 command2 word3 If you want all as argument of one call of command2 … Read more

Does mysqldump return a status?

mysqldump returns 0 for Success 1 for Warning 2 for Not Found It also prints an extended error message to stderr e.g. mysqldump: Got error: 1049: Unknown database ‘dbname’ when selecting the database You can inspect the returned value like so mysqldump -u DBuser -pDBpassword database >database.sql 2>database.err if [ “$?” -eq 0 ] then … Read more