mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Add datatype to param()
This commit is contained in:
@ -12,14 +12,15 @@
|
||||
#>
|
||||
|
||||
|
||||
param($server = "", $database = "", $username = "", $password = "", $query = "")
|
||||
if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the MySQL server" }
|
||||
if ($database -eq "") { $database = read-host "Enter the database name" }
|
||||
if ($username -eq "") { $username = read-host "Enter the database username" }
|
||||
if ($password -eq "") { $password = read-host "Enter the database user password" }
|
||||
if ($query -eq "") { $query = read-host "Enter the database query" }
|
||||
param([string]$server = "", [string]$database = "", [string]$username = "", [string]$password = "", [string]$query = "")
|
||||
|
||||
try {
|
||||
if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the MySQL server" }
|
||||
if ($database -eq "") { $database = read-host "Enter the database name" }
|
||||
if ($username -eq "") { $username = read-host "Enter the database username" }
|
||||
if ($password -eq "") { $password = read-host "Enter the database user password" }
|
||||
if ($query -eq "") { $query = read-host "Enter the database query" }
|
||||
|
||||
$csvfilepath = "$PSScriptRoot\mysql_table.csv"
|
||||
$result = Invoke-MySqlQuery -ConnectionString "server=$server; database=$database; user=$username; password=$password; pooling = false; convert zero datetime=True" -Sql $query -CommandTimeout 10000
|
||||
$result | Export-Csv $csvfilepath -NoTypeInformation
|
||||
|
Reference in New Issue
Block a user