Skip to content

Symbolic link errors on subsequent applys #87

@ScottGuymer

Description

@ScottGuymer

I am using the symbolic link resource and it applies successfully the first time and creates the link correctly. But on subsequent runs, it fails.

I think its something to do with the test function as it seems to think that the link doesn't exist and tries to re-create it when it already exists.

My DSC config is

    $documents = [Environment]::GetFolderPath("MyDocuments")    
    cSymbolicLink powershellProfileLink {
      Ensure          = "Present"
      SourcePath      = "C:\code\powershell-profile\"
      DestinationPath = "$documents\WindowsPowerShell\"
      DependsOn       = "[cGitRepository]powershellProfile"
    }

the error message is.

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Resource ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Test     ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Test     ]  [[cSymbolicLink]powershellProfileLink]  in 0.0590 seconds.
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Set      ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]:                            [[cSymbolicLink]powershellProfileLink] DestinationPath : 'C:\Users\320047825\OneDrive - Philips\Documents\WindowsPowerShell\',  SourcePath :
'C:\code\powershell-profile\', IsDirectory : 'False'
Exception calling "CreateSymLink" with "3" argument(s): "Cannot create a file when that file already exists"
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Win32Exception
    + PSComputerName        : localhost

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Set      ]  [[cSymbolicLink]powershellProfileLink]  in 0.1390 seconds.
The PowerShell DSC resource '[cSymbolicLink]powershellProfileLink' with SourceInfo 'C:\code\windows-dev-config\devMachineConfig.ps1::85::5::cSymbolicLink' threw one or more non-terminating errors while running
the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 18.029 seconds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions