

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to resolve - Relative path is not supported in PowerShell DSC?
“Relative path is not supported” error generally occurs with the PowerShell DSC when we download a file from online or Website and we use “File” DscResource for that.
In the below example, we are downloading the PowerShell 7.1.4 version from GitHub using DSC to the local computer and we get the error below.
Example
Configuration FileCopy{ Node LocalHost{ File CopyFromBlob{ SourcePath = "https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.msi" DestinationPath = "C:\Temp\" Ensure = 'Present' } } } FileCopy -OutputPath C:\Temp\dsc\FileCopy Start-DscConfiguration -Path C:\Temp\dsc\FileCopy -Wait -Force
Output
Relative path is not supported. The related file/directory is: https://github.com/PowerShell/PowerShell/releases/download/v7.1. 4/PowerShell-7.1.4-win-x86.msi. + CategoryInfo : InvalidArgument: (:) [], CimException + FullyQualifiedErrorId : MI RESULT 4 + PSComputerName : LocalHost
To resolve this error, we can either use the “Script“ DSC resource or we need to download and Install the additional DSC resource “xRemoteFile” to download the file online.
To install the “xRemoteFile” resource use the below command.
Find-DscResource xRemoteFile | Install-Module -Force -Verbose
Once the command is installed, we can use the below configuration.
Configuration FileCopy{ Import-DscResource -ModuleName xPSDesiredStateConfiguration Node LocalHost{ xRemoteFile FileDownload{ URI = "https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.msi" DestinationPath = "C:\Temp\PowerShell-7.1.4-win-x86.msi" } } } FileCopy -OutputPath C:\Temp\dsc\FileCopy Start-DscConfiguration -Path C:\Temp\dsc\FileCopy -Wait -Force
You can also use the inbuilt Script DSC resource as shown below.
Configuration FileCopy{ Node LocalHost{ Script DownloadFile{ GetScript = {""} SetScript = { Invoke-WebRequest - Uri "https://github.com/PowerShell/PowerShell/releases/download/v7.1.4/PowerShell-7.1.4-win-x86.msi" -OutFile C:\Temp\PowerShell-7.1.4-win-x86.msi } TestScript = { If(!(Test-Path C:\Temp\PowerShell-7.1.4-win-x86.msi)){return $false} else{return $true} } } } }
- Related Questions & Answers
- Difference between Test-Path and Resolve-Path in PowerShell?
- How to install DSC resources using PowerShell?
- How to install the MSI package using PowerShell DSC?
- Azure DSC node configuration using PowerShell
- How to Resolve DNS address using PowerShell?
- Why multiple inheritance is not supported in Java
- How to get supported parameters of the cmdlet in PowerShell?
- Why multiple inheritance is not supported by Java?
- Why is operator overloading not supported by java?
- How to use Split-Path command in PowerShell?
- How to get/resolve the command from the alias in PowerShell?
- How to resolve exception Element Not Interactable Exception in Selenium?
- Get an Absolute Filename Path from a Relative Filename Path in Java
- Get an Absolute Filename Path from a Relative Filename with Path in Java
- How to resolve javac is not recognized as an internal or external command in java?
Advertisements