-
Notifications
You must be signed in to change notification settings - Fork 107
Using the Script resource in configurations that use SharePointDsc
In some circumstances you may find yourself needing to use a Script resource to be able to perform a function that is not included in SharePointDsc. If your script resource needs to add the SharePoint snap-in you may find that this will cause issues with other resources provided by SharePointDsc (as discussed in in this issue). To work around this, it is recommended that instead of loading the snap-in yourself you use the Invoke-SPDscCommand helper to achieve this. This helper method will load the snap-in for you in the same way that the native resources of SharePointDsc do, and will avoid conflicts with it being loaded multiple times.
An example of this in a script resources is shown below:
Script SPDscExample
{
GetScript = {
Invoke-SPDscCommand -ScriptBlock {
# Your code goes here
}
}
...
}
If you need to pass a credential or additional arguments, you can use the -Credential and -Arguments parameters for these purposes also.
- Home
- Getting Started
- Pre-requisites
- Installing the module
- Exporting SharePoint Configuration
- Creating Configuration Files
- Pre-created Examples
- Creating an Azure development environment
- Understanding Resources & Syntax
- Remote PowerShell Authentication
- Contributing to SharePointDsc
- Other useful modules for SharePoint DSC configurations