Me gustaría convertir una ruta a una ruta relativa en un script de PowerShell. ¿Cómo hago esto usando PowerShell?¿Cómo convertir la ruta absoluta a la ruta relativa en PowerShell?
Por ejemplo:
Path to convert: c:\documents\mynicefiles\afile.txt
Reference path: c:\documents
Result: mynicefiles\afile.txt
Y
Path to convert: c:\documents\myproject1\afile.txt
Reference path: c:\documents\myproject2
Result: ..\myproject1\afile.txt
En lugar de usar una variable temporal, también puede usar Push-Location y Pop-Location para establecer la ubicación y luego volver a su valor original. La misma solución básica pero sin la variable temporal. –