Update module version to 1.0.1 and add new functions for exporting and deploying DSC configuration data
This commit is contained in:
29
Private/ConvertTo-ConfigurationDataRelativePath.ps1
Normal file
29
Private/ConvertTo-ConfigurationDataRelativePath.ps1
Normal file
@@ -0,0 +1,29 @@
|
||||
function ConvertTo-ConfigurationDataRelativePath {
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$Path,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]
|
||||
$BasePath
|
||||
)
|
||||
|
||||
$ResolvedPath = Repair-ConfigurationDataPathEncoding -Path $Path
|
||||
$ResolvedBasePath = Repair-ConfigurationDataPathEncoding -Path $BasePath
|
||||
|
||||
try {
|
||||
$PathUri = [System.Uri]::new((Resolve-Path -LiteralPath $ResolvedPath).ProviderPath)
|
||||
$BaseUriPath = [System.IO.Path]::GetFullPath($ResolvedBasePath)
|
||||
if(-not $BaseUriPath.EndsWith([System.IO.Path]::DirectorySeparatorChar)){
|
||||
$BaseUriPath += [System.IO.Path]::DirectorySeparatorChar
|
||||
}
|
||||
|
||||
$BaseUri = [System.Uri]::new($BaseUriPath)
|
||||
return [System.Uri]::UnescapeDataString($BaseUri.MakeRelativeUri($PathUri).ToString()).Replace('/', [System.IO.Path]::DirectorySeparatorChar)
|
||||
}
|
||||
catch {
|
||||
return $ResolvedPath
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user