Tags: databases powershell smo
This is a quick example on getting a attribute from a database in a given Databases collection.[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')function Get-Database_Owner {param( [string]$SsdbName= $(throw'SQL Server database instance name is missing as a parameter.'), [string]$DatabaseName= $(throw'Database name is missing as a parameter.') ) $Ssdb=New-Object'Microsoft.SqlServer.Management.Smo.Server'$SsdbName $Ssdb.Databases["$DatabaseName"].Owner }A ex
This is a quick example on getting a attribute from a database in a given Databases collection.[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')function Get-Database_Owner {param( [string]$SsdbName= $(throw'SQL Server database instance name is missing as a parameter.'), [string]$DatabaseName= $(throw'Database name is missing as a parameter.') ) $Ssdb=New-Object'Microsoft.SqlServer.Management.Smo.Server'$SsdbName $Ssdb.Databases["$DatabaseName"].Owner }A ex