powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Convert-UrnToPath



NAME
Convert-UrnToPath

SYNOPSIS
Converts a SQL Server Management Object URN to a SQL Server PowerShell provider path.

SYNTAX
Convert-UrnToPath [-Urn] []


DESCRIPTION
Converts a SQL Server Management Object Uniform Resource Name (URN) to a SQL Server provider path. SQL Server Manag
ement Objects have a Urn property that returns a string indicating their location in the SQL Server object hierarch
y.
If nodes in the Urn are SQL Server delimited identifiers that have extended characters not supported in PowerShell
path nodes, the extended characters are encoded with their hexadecimal representation. For example, a table name "M
y:Table" is encoded as "My%3ATable".


PARAMETERS
-Urn
A character string containing a SQL Server Unique Resource Name (URN). A SQL Server URN is a string that identi
fies the location of an object in the SQL Server hierarchy. URNs have the same information as a SQL Server Powe
rShell path, only in a different format. SQL Server Management Objects have a Urn property.

Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS
String


OUTPUTS
String


NOTES




-------------- Example 1 --------------

C:\PS>Set-Location SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks
Convert-UrnToPath -Urn (Get-Item .).Urn.ToString()


Returns a character string containing the current path. The example uses the ToString() function of the SMO Urn pro
perty to return the Urn as a character string.


SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks


-------------- Example 2 --------------

C:\PS>Set-Location ( Convert-UrnToPath -Urn "Server[@Name='MyComputer']/Database[@Name='AdventureWorks']/Table[@Nam
e='Address' and @Schema = 'Person']" )


Sets the path to the location specified in a SQL Server Management Object URN.





-------------- Example 3 --------------

C:\PS>Set-Location SQLSERVER:\SQL\MyComputer\DEFAULT\Databases
foreach ($Item in Get-ChildItem) { $Item.Urn.ToString() | Convert-UrnToPath }


Returns a set of character strings, each containing the path to a database in the default instance. Uses a pipeline
to pass the current node URN to Convert-UrnToPath


SQLSERVER:\SQL\MyComputer\DEFAULT\Databases\AdventureWorks



RELATED LINKS
Decode-SqlName
Encode-SqlName