Skip to content

Instantly share code, notes, and snippets.

@alevyinroc
Last active May 18, 2018 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alevyinroc/9dc3f8474341f83510f991250589c20f to your computer and use it in GitHub Desktop.
Save alevyinroc/9dc3f8474341f83510f991250589c20f to your computer and use it in GitHub Desktop.
import-module dbatools,importexcel;
$DBServer = 'MYSERVER';
$TableList = Get-Content TableList.txt;
$Tables = Get-DbaTable -ServerInstance $DBServer -Database Satellites -Table $TableList;
foreach ($Table in $Tables) {
$Columns = $Table.columns | Select-Object Name,DataType,Nullable,@{name='Length';expression={$_.Properties["Length"].Value}};
$Columns | Export-Excel -Path C:\Users\andy\Documents\TableInfo.xlsx -WorkSheetname $Table.Name -FreezeTopRow -BoldTopRow;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment