forked from jrussellfreelance/powershell-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist-tables-mysql.ps1
More file actions
22 lines (22 loc) · 857 Bytes
/
Copy pathlist-tables-mysql.ps1
File metadata and controls
22 lines (22 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# This script lists all of the tables in a MySQL database and exports the list as a CSV
# Install-Module InvokeQuery
# Run the above command if you do not have this module
$csvfilepath = "$PSScriptRoot\mysql_tables.csv"
Do {
$server = Read-Host "Please enter the server host name or IP of the database"
}
While ($server -eq "")
Do {
$database = Read-Host "Please enter the database name"
}
While ($database -eq "")
Do {
$dbuser = Read-Host "Please enter the database user"
}
While ($dbuser -eq "")
Do {
$dbpass = Read-Host "Please enter the database user's password"
}
While ($dbpass -eq "")
$result = Invoke-MySqlQuery -ConnectionString "server=$server; database=$database; user=$dbuser; password=$dbpass; pooling = false; convert zero datetime=True" -Sql "SHOW TABLES" -CommandTimeout 10000
$result | Export-Csv $csvfilepath -NoTypeInformation