param(
	[string]$hostName,
	[string]$database,
	[string]$login,
	[string]$pwd
)

$connection = New-Object -TypeName System.Data.SqlClient.SqlConnection
$connection.ConnectionString = "Server=" + $hostName + ";Database=" + $database + ";UID=" + $login + ";PWD=" + $pwd + ";Connection Timeout=30";
$command = $connection.CreateCommand()
$command.CommandText = "EXEC sp_spaceused" 
$adapter = New-Object -TypeName System.Data.SqlClient.SqlDataAdapter $command
$dataset = New-Object -TypeName System.Data.DataSet
$adapter.Fill($dataset) > null

foreach ($table in $dataset.Tables) {
	foreach ($row in $table.Rows) {
		foreach ($col in $table.Columns) {
			Write-Host $col.ColumnName $row[$col]
		}
	}
}

$command = $connection.CreateCommand()
$command.CommandText = "SELECT name, physical_name FROM sys.master_files"
$adapter = New-Object -TypeName System.Data.SqlClient.SqlDataAdapter $command
$dataset = New-Object -TypeName System.Data.DataSet
$adapter.Fill($dataset) > null
foreach ($table in $dataset.Tables) {
	foreach ($row in $table.Rows) {
		if ($row["name"] -eq $database) {
			Write-Host "db_file_location" $row["physical_name"]
		}
	}
}

