Last active
November 20, 2019 18:44
-
-
Save martin-guth/85c66e3d0b82522aa73e5f1d5bbd6550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module dbatools; | |
Import-Module ExcelPSLib; | |
$credential = Get-Credential; | |
# get results from table | |
$result= Invoke-DbaQuery -SQLInstance localhost -Database master -Query "SELECT * FROM sys.tables" -SqlCredential $credential ; | |
# debug the output | |
$result | Out-GridView; | |
$begin = Get-Date; | |
# export to excel | |
$result | Export-OOXML -FileFullPath test.xlsx -WorksheetName test -AutoFit -HeaderStyle WhiteSmoke; | |
$end = Get-Date; | |
echo "duration $($end-$begin)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment