Quantcast
Channel: SharePoint 2013 - Setup, Upgrade, Administration and Operations forum
Viewing all articles
Browse latest Browse all 21070

Desired State Configuration add snapin

$
0
0

Hi

I cant find information about this issue anywhere, so I shall try my luck here:-)

Using server 2012R2 with Powershell 5 and Desired State Configuration.

I have created a DSC module with dscresources (class 5) for configuring SharePoint. Meaning additional configurations in addition to the SharePointDSC module in PowerShell Gallery and github repository.

When running SharePoint cmdlets in powershell it is neccessary to add the SharePoint snapin:

 if ((Get-PSSnapin -Registered -Name 'microsoft.sharepoint.powershell') -ne $null)
        {
            try
            {
                Add-PSSnapin 'microsoft.sharepoint.powershell'
                Write-Debug 'Added microsoft.sharepoint.powershell snapin'
            }
            catch
                {
                    throw 'There was a problem loading snapin microsoft.sharepoint.powershell.'
                }
        }
        else
        {
            throw 'microsoft.sharepoint.powershell snapin is not installed on this system!'
        }


However, when running my mof (Managed Object Format) file with verbose I get the message:

PowerShell DSC resource SkaDscResourceSharePoint  failed to execute Test functionality with error message: There was a problem loading snapin microsoft.sharepoint.powershell.+ CategoryInfo          : InvalidOperation: (:) [], CimException+ FullyQualifiedErrorId : ProviderOperationExecutionFailure+ PSComputerName        : localhost

I have tried just adding the snapin like this

add-PSSnapin microsoft.sharepoint.powershell

But that gives me the error :

An item with the same key has already been added

Any hints and tips are welcome!

brgs

Bjørn


Viewing all articles
Browse latest Browse all 21070

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>