question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DSC fails when using a script resource with Invoke-SPDscCommand

See original GitHub issue

Hi guys,

I’m using a script resource for setting SPSecurityTokenServiceConfig:

$scriptParams = @{ 
	"FormsTokenLifetime" = $ConfigurationData.NonNodeData.SharePoint.SecurityTokenServiceConfig.FormsTokenLifetime;
	"WindowsTokenLifetime" = $ConfigurationData.NonNodeData.SharePoint.SecurityTokenServiceConfig.WindowsTokenLifetime;
	"LogonTokenCacheExpirationWindow" = $ConfigurationData.NonNodeData.SharePoint.SecurityTokenServiceConfig.LogonTokenCacheExpirationWindow;
}
Script SetSPSecurityTokenServiceConfig
{
	GetScript = {
		return @{ Result = "false" }
	}
	SetScript = {
		Invoke-SPDscCommand -ScriptBlock {
			$params = $args[0]
			$sts = Get-SPSecurityTokenServiceConfig -ErrorAction SilentlyContinue | `
					Where-Object { $_.TypeName -eq "Microsoft.SharePoint.Administration.Claims.SPSecurityTokenServiceManager" }
			$sts.FormsTokenLifetime = (New-TimeSpan -Minutes $params.FormsTokenLifetime)
			$sts.WindowsTokenLifetime = (New-TimeSpan -Minutes $params.WindowsTokenLifetime)
			$sts.LogonTokenCacheExpirationWindow = (New-TimeSpan -Minutes $params.LogonTokenCacheExpirationWindow)
			$sts.Update()
	} -Arguments @($using:scriptParams)
	}
	TestScript = {
		return $false
	}
	PsDscRunAsCredential = $SPSetupAccount
	DependsOn            = $FarmWaitTask
}

This resource worked fine with older versions of SharePointDSC, it fails with SharePointDSC 4.5.1:

Verbose logs showing the problem

VERBOSE: [V00PEEE50SPP201]: LCM: [ Start Resource ] [[Script]SetSPSecurityTokenServiceConfig] VERBOSE: [V00PEEE50SPP201]: LCM: [ Start Test ] [[Script]SetSPSecurityTokenServiceConfig] DEBUG: [V00PEEE50SPP201]: [[Script]SetSPSecurityTokenServiceConfig] Begin executing Test Script. DEBUG: [V00PEEE50SPP201]: [[Script]SetSPSecurityTokenServiceConfig] Executing Script: return $false DEBUG: [V00PEEE50SPP201]: [[Script]SetSPSecurityTokenServiceConfig] End executing Test Script. VERBOSE: [V00PEEE50SPP201]: LCM: [ End Test ] [[Script]SetSPSecurityTokenServiceConfig] in 0.2820 seconds. VERBOSE: [V00PEEE50SPP201]: LCM: [ Start Set ] [[Script]SetSPSecurityTokenServiceConfig] VERBOSE: [V00PEEE50SPP201]: LCM: [ End Set ] [[Script]SetSPSecurityTokenServiceConfig] in 0.7030 seconds. PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response. A provider in the host process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : InvalidOperation: (😃 [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : V00PEEE50SPP201 PowerShell DSC resource MSFT_ScriptResource failed to execute Set-TargetResource functionality with error message: Processing data for a remote command failed with the following error message: The WSMan provider host process did not return a proper response. A provider in the host process may have behaved improperly. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : InvalidOperation: (😃 [], CimException + FullyQualifiedErrorId : ProviderOperationExecutionFailure + PSComputerName : Server01

Did some checks with some other simple script resources using Invoke-SPDSCCommand and they all failed with the same error message.

OS: Windows Server 2016 SharePoint: 2019

Any help is appreciated…

Regards, Thomas

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ThomasLiecommented, Jun 22, 2021

Hi Yorick,

it returns exactly the same value…

Mit freundlichen Grüßen / Kind regards

Thomas Lieftüchter

Lieftüchter IT Consulting & Hausverwaltung GbR Römerweg 10a 63303 Dreieich - Germany

Fon: +49 171.2625166 Email: @.@.> Web: https://www.lieftuechter.com/TL

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.

Von: Yorick Kuijs @.> Gesendet: Dienstag, 22. Juni 2021 15:51 An: dsccommunity/SharePointDsc @.> Cc: Thomas Lieftüchter @.>; Author @.> Betreff: Re: [dsccommunity/SharePointDsc] DSC fails when using a script resource with Invoke-SPDscCommand (#1298)

What is the value when you run the following command:

Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB

This should be something like:

WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Shell

Type Name SourceOfValue Value


System.String MaxMemoryPerShellMB 2147483647

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dsccommunity/SharePointDsc/issues/1298#issuecomment-866002364, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALR4I45OELVDVO4HMLOFKETTUCIOBANCNFSM4ZUWO4WA.

0reactions
ykuijscommented, Jan 24, 2022

Closing this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerShell DSC Script Resources Fail
If I use Invoke-Command or Invoke-Expression, it blows up, so it seems like running a separate process is the key. Is there a...
Read more >
DSC Script Resource - PowerShell
It is called by DSC if the TestScript script block returns $false . The SetScript should have no return value. Examples. Example 1:...
Read more >
Troubleshooting DSC Resources
Use this guide to troubleshoot issues with Puppet code containing DSC resources. The resource appears to change on each Puppet run. Some DSC...
Read more >
LCM stuck in busy state after the DSC setscript resource ...
We notice that when the setscript resource returns an error the LCM is stuck in a busy state and we cannot re-run our...
Read more >
dsc_resource Resource - Chef Documentation
The dsc_resource resource allows any DSC resource to be used in a recipe, as well as any custom resources that have been added...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found