PowerShell to get database schemas I am able to connect to a remote SQL Server with the instance name using PowerShell. I am using an XML file (something like a configuration file) which includes all my database details. PowerShell uses this for connection establishment. 

Now I want to get all "schemas" associated with a particular database that is already defined in that XML file. How can I achieve that using Powershell scripting?

Any help would be really appreciated.
Assuming you have a valid instance of the SMO Server object defined as $ServerObject. The following code will allow you pull the names of all schemas in the database UserDatabase01:

$Database = $ServerObject.Databases | ? { $_.Name -eq "UserDatabase01" }
$Database.Schemas | Select Name


For more information on schema properties available through SMO, see the documentation for the Schema class. Unfortunately, the version of SMO for SQL 2005 is missing a lot of properties for this class. Newer versions are backwards compatible, you may want to look into installing a newer version:  


SQL 2012 Feature Pack
SQL 2014 Feature Pack