Convert-UrnToPath
Converts a SQL Server Management Object URN to a Windows PowerShell provider path.
语法
Default (默认值)
Convert-UrnToPath
-Urn <String>
[<CommonParameters>]
说明
The Convert-UrnToPath cmdlet converts a SQL Server Management Object Uniform Resource Name (URN) to a SQL Server provider path. SQL Server Management Objects have a Urn property that returns a string indicating their ___location in the SQL Server object hierarchy. If nodes in the Urn are SQL Server delimited identifiers with extended characters that are not supported in Windows PowerShell path nodes, the extended characters are encoded with their hexadecimal representation. For example, a table name "Main:Table" is encoded as "Main%3ATable".
示例
Example 1: Get a string containing the current path
PS C:\> Set-Location "SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks2014"
PS SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks2014> Convert-UrnToPath -Urn (Get-Item .).Urn.ToString()
SQLSERVER:\SQL\MyComputer\MyInstance\Databases\AdventureWorks2014
This command returns a string that contains the current path. The example uses the ToString() function of the Urn property to return the Urn as a string.
Example 2: Set the path ___location based on a URN
PS C:\> Set-Location (Convert-UrnToPath -Urn "Server[@Name='MyComputer']/Database[@Name='AdventureWorks']/Table[@Name='Address' and @Schema = 'Person']")
This command sets the path to the ___location specified in a SQL Server Management Object URN.
Example 3: Get database paths
PS C:\> Set-Location "SQLSERVER:\SQL\MyComputer\DEFAULT\Databases"
PS SQLSERVER:\SQL\MyComputer\DEFAULT\Databases> ForEach ($Item in Get-ChildItem) { $Item.Urn.ToString() | Convert-UrnToPath }
SQLSERVER:\SQL\MyComputer\DEFAULT\Databases\AdventureWorks2014
This command returns an array of strings that contain the path to a database in the default instance. The pipeline operator is used to pass the current node URN to Convert-UrnToPath.
参数
-Urn
Specifies a SQL Server URN that identifies the ___location of an object in the SQL Server hierarchy.
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
(All)
Position: | Named |
必需: | True |
来自管道的值: | True |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
输入
String
Specifies a string that represents a SQL Server Management Object URN.
输出
String
Specifies a string that represents a SQL Server PowerShell provider path.