Thanks in advance for any assistance.
I’m trying to refactor my code using the dsc_resource. I’m using the File resource in this instance. Having a few issues which hopefully someone can point me in the right direction.
I’m creating a folder as below, this works fine.
dsc_resource ‘Exchange2016Folder’ do
resource :File
property :Type, 'Directory’
property :DestinationPath, 'c:/Exchange2016’
property :Ensure, 'Present’
end
The issue I’m having is if I run the below without the credential line, I receive the error:
Chef::Exceptions::PowershellCmdletException: Powershell Cmdlet failed: Invoke-DscResource : Relative path is not supported. The related file/directory is: https://download.microsoft.com/download/3/9/B/39B8DDA8-509C-4B9E-BCE9-4CD8CDC9A7DA/Exchange2016-x64.exe.
I found a similar error here: http://serverfault.com/questions/568833/powershell-dsc-copy-from-network-share which indicates that the command might be run as a SYSTEM account.
dsc_resource ‘Exchange2016File’ do
resource :file
property :Credential, 'Chef::Util::Powershell:PSCredential(“vagrant”, “vagrant”)'
property :DestinationPath, 'c:/Exchange2016/Exchange2016-x64.exe’
property :SourcePath, 'https://download.microsoft.com/download/3/9/B/39B8DDA8-509C-4B9E-BCE9-4CD8CDC9A7DA/Exchange2016-x64.exe’
COMMENTED OUT property :Checksum, '131520f0f703956643a1887b384f54d4d765beb882f201c2905a5c7e20410db5’
property :Checksum, "SHA-256"
property :Ensure, 'Present’
property :Type, 'File’
COMMENTED OUT property :MatchSource, $true
end
I’m trying to work out if I can download the file using a URI using the File DSC Resource and also how to us the Credential property correctly.
My alternative is to use the below dsc_resource Script resource to download the file.
dsc_resource ‘downloadExchange2016-x64fromMS’ do
resource :Script
property :GetScript, '{@{Result = (get-content c:/Exchange2016/Exchange2016-x64.exe).Name}}'
property :SetScript, 'invoke-webrequest -uri “https://download.microsoft.com/download/3/9/B/39B8DDA8-509C-4B9E-BCE9-4CD8CDC9A7DA/Exchange2016-x64.exe” -outfile “c:/Exchange2016/Exchange2016-x64.exe”'
property :TestScript,'test-path “c:/Exchange2016/Exchange2016-x64.exe”'
COMMENTED OUT property :Credential, 'Chef::Util::Powershell:PSCredential(“vagrant”, “vagrant”)'
COMMENTED OUT property :DependsOn, [File]Exchange2016Folder
end
Thank you.
Regards, Tim.