Getting SQL Server table size with Powershell

<#
----------------------------------------------------------------------------------------------------------------
Author:     ******** Enterprise Architecture
Date:       May 5, 2018
Purpose:    List table sizes
Revisions:  Initial – SDH 2018-05-05
To-do:      -
----------------------------------------------------------------------------------------------------------------
#>

$conn = New-Object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=********\NCRWO;database=NCRWO_TransactionLog;Integrated Security=true;MultipleActiveResultSets=true"
$conn.Open()

$cmd = New-Object System.Data.SqlClient.SqlCommand
$cmdInner = New-Object System.Data.SqlClient.SqlCommand

$cmd.Connection = $conn
$cmdInner.Connection = $conn

$cmd.CommandText = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'"
  
$swReader = $cmd.ExecuteReader()
while ($swReader.Read()) {
  $cmdInner.CommandText = "exec sp_spaceused [" + $swReader['table_name'] + "]"
  $swInnerReader = $cmdInner.ExecuteReader()
  while ($swInnerReader.Read()) {
    $tmp=[int]$swInnerReader['reserved'].replace(" KB","") 
    $swInnerReader["name"] + "," + $swInnerReader['rows'].toString() + "," + $tmp.toString() + "," + $swInnerReader['data'] + "," + $swInnerReader['index_size'] + "," + $swInnerReader['unused']| Out-File 'C:\USERS\ADM-SHOWARD\DOWNLOADS\edrsizelog.csv' -Append
  }
  $swInnerReader.Close()
}
$swReader.Close();