Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Convert URNs to SQL Server Provider Paths

SQL Server 2012

The SQL Server Management Object model (SMO) builds Uniform Resource Names (URN) for its objects. Each URN uniquely identifies a SMO object, and can be converted to a SQL Server PowerShell provider path by using the Convert-UrnToPath cmdlet.

Each URN has the same information as a path to the object, but in a different form. For example, this is the path to a table:

SQLSERVER:\SQL\MyComputer\DEFAULT\Databases\AdventureWorks2012\Tables\Person.Address

And this is the URN to the same object:

Server[@Name='MyComputer']\Database[@Name='AdventureWorks2012']\Table[@Name='Address' and @Schema='Person']

If you have created a SMO object in a PowerShell script, you can reference the Urn property to get the URN for the object, and then use the Convert-UrnToPath cmdlet to convert the SMO URN string to a Windows PowerShell path. You can then use the provider to navigate to different locations on the path.

If node names contain extended characters that are not supported in Windows PowerShell path names, Convert-UrnToPath encodes them in their hexadecimal representation. For example "My:Table" is returned as "My%3ATable".

For examples of using the cmdlet, in Windows PowerShell, run:

Get-Help Convert-UrnToPath -Examples
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.