I’m trying to write up a small DSC PoC (vs Ansible), and as part of that, I want to show that DSC can create files on a share.
I can happily create files locally, but not remotely. (This question follows on from a previous question about copying from a UNC path)
This is my code Configuration Data:
$ConfigurationData = @{ AllNodes = @( @{ NodeName="Server03" PSDscAllowPlainTextPassword=$True PSDscAllowDomainUser=$True } ) }
The Configuration:
Configuration DSCPOCCreateUNCFile { param ( [Parameter()] [PSCredential]$Credential ) Import-DscResource -ModuleName PsDesiredStateConfiguration Node 'Server03' { File HelloWorldUNC { DestinationPath = "\\Share\Common\DevOps\PowerShell.DSC.Resources\HelloWorld.txt" Ensure = "Present" Type = "File" Credential = $Credential PSDSCRunAsCredential = $Credential } } }
Then I run:
$Cred = (Get-Credential) DSCPOCCopyDSCResources -OutputPath C:\Temp\ -ConfigurationData $ConfigurationData -Credential $Cred
Which outputs my MOF.
I then get this When running the DSC Configuration:
Start-DscConfiguration -Path C:\Temp -Verbose -Wait -Force VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'. VERBOSE: An LCM method call arrived from computer Server03 with user sid S-1-5-21-39487305749-1710526943-1674199894-74534. VERBOSE: [Server03]: LCM: [ Start Set ] VERBOSE: [Server03]: LCM: [ Start Resource ] [[File]HelloWorldUNC] VERBOSE: [Server03]: LCM: [ Start Test ] [[File]HelloWorldUNC] VERBOSE: [Server03]: [[File]HelloWorldUNC] Access is denied. VERBOSE: [Server03]: [[File]HelloWorldUNC] The related file/directory is: \\Share\Common\DevOps\PowerShell.DSC.Resources\HelloWorld.txt. Access is denied. The related file/directory is: \\Share\Common\DevOps\PowerShell.DSC.Resources\HelloWorld.txt. + CategoryInfo : PermissionDenied: (:) [], CimException + FullyQualifiedErrorId : Windows System Error 5 + PSComputerName : Server03 VERBOSE: [Server03]: LCM: [ End Set ] The SendConfigurationApply function did not succeed. + CategoryInfo : PermissionDenied: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : MI RESULT 2 + PSComputerName : Server03 VERBOSE: Operation 'Invoke CimMethod' complete. VERBOSE: Time taken for configuration job to complete is 2.438 seconds
I am entirely stumped, and nothing relevant comes up when I try to google this
Any ideas what I am doing wrong?
I can copy from the share fine, and using New-Item from a console is fine too…