GithubHelp home page GithubHelp logo

Comments (2)

kwirkykat avatar kwirkykat commented on May 30, 2024

@rsganta There are 2 problems here:

  1. $IsExists = $GetScript This line isn't actually executing $GetScript. It just assigns the variable $IsExists to the string that is $GetScript. Because $IsExists is assigned to a non-null string, the following if statement just evaluate if $IsExists is null (false) or not (true). Since $IsExists will never be null in this case, it will always your TestScript will always return true which means that SetScript will never run. In order to actually execute the string, you can turn the string into a ScriptBlock and then execute that with &. So this line in TestScript should look like this:
    $fileExists = & ([ScriptBlock]::Create($GetScript))
  2. GetScript doesn't return a value. So even if you correctly put in the solution for issue 1, then GetScript will always return null which means that TestScript will always return false and Set will always run. You want to return the value of $IsStrongNameExists from your GetScript instead of assigning it to a variable. Like this:
    return Test-Path -Path $strongName

from psdscresources.

rsganta avatar rsganta commented on May 30, 2024

thank you. I also find the other way of the solution by putting logic directly in the test-script and so it does not depend on get-script.
One more question, I noticed below error sometimes when I run the script. Though set executes successfully but throws the below error.
VERBOSE: [997C-DM2-TAP01]: LCM: [ Start Set ] [[Script]SecurityTokenService]
VERBOSE: [997C-DM2-TAP01]: [[Script]SecurityTokenService] Performing the operation "Set-TargetResource" on target "Executing the SetScript with the user supplied credential".
VERBOSE: [997C-DM2-TAP01]: LCM: [ End Set ] [[Script]SecurityTokenService] in 0.6720 seconds.
PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: An item with the same key has already been added.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost

from psdscresources.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.