Comments (2)
@rsganta There are 2 problems here:
$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))
- 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.
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)
- setGroup: Error when I try to exclude a user from Users builtin group HOT 3
- Package missing build number in version Metadata HOT 2
- Set-StrictMode behavior breaks valid Configurations from (x)PSDesiredStateConfiguration HOT 3
- PsDscRunAsCredential with empty password throws error "Object reference not set to an instance of an object."
- Script Resource "No user exists"
- WindowsOptionalFeature: Get Method fails if OptionalFeature has no custom properties when called by the LCM.
- Archive: Special Characters not supported in file names within zip files
- WindowsFeatureSet broken when using member Source HOT 3
- Environment: Implement 'User' target HOT 1
- File: Default checksum type not documented
- Service: Invoke-DscResource fail to update a service HOT 3
- Fix CI Pipeline Failures
- Registry: Set "Absent" with ValueData fails if Key uses "HKEY_LOCAL_MACHINE\..." HOT 1
- Registry: add option to require reboot after setting
- User: Test-DscResource fails for user that is disabled by resource
- Archive: DSC resouce does not support paths longer than 260
- MSFT_GroupResource: SAMR can be blocked by domain controller GPO in Get-TargetResource HOT 1
- Group: Get-TargetResource throws with single member in group due to Type mismatch HOT 2
- WindowsFeature: Resource thinks Windows Server 2022 Azure Edition Core is a Client OS HOT 1
- WindowsProcess DSC resource fails intermittently with "Failed to wait for processes to start." HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psdscresources.