microsoft / SharePointDSC.Reverse

Extracts a Desired State Configuration Script from an existing SharePoint Farm
MIT License
40 stars 27 forks source link

Unable to find type [System.Management.Automation.Hashtable] error on Win2016 server #95

Open abates100 opened 4 years ago

abates100 commented 4 years ago

Details of the scenario you try and problem that is occurring: Just installed the latest ReverseDSC and SharePointDSC modules from PSGallery. The script loads, pops up the new selection UI, starts outouting some information then throws errors like below on a new SP2019 install running as admin account, farm account or install account. The errors are all referencing types from 'System.Management.Automation...

Configuring Dependencies... Property 'Mandatpry' cannot be found for type 'System.Management.Automation.CmdletBindingAttribute'. At C:\Program Files\WindowsPowerShell\Modules\ReverseDSC\2.0.0.0\ReverseDSC.Core.psm1:809 char:20

[ ..AP03 ] Generating the SharePoint Prerequisites Installation... [ ..AP03 ] Generating the SharePoint Binary Installation... [ ..AP03 ] Scanning the SharePoint Farm... Unable to find type [System.Management.Automation.Hashtable]. At C:\Program Files\WindowsPowerShell\Modules\ReverseDSC\2.0.0.0\ReverseDSC.Core.psm1:352 char:17

The DSC configuration that is using the resource:

Version of the Operating System and PowerShell the DSC Target Node is running: Windows Server 2016 Standard Major Minor Build Revision


5 1 14393 3053

Version of the DSC module you're using:

Script version: .VERSION 3.4.0.0 Modules ReverseDSC PSGallery 2.0.0.0
SharePointDSC PSGallery 3.7.0.0

heinrich-ulbricht commented 4 years ago

Ran into this as well while using Office365DSC. Searching on GitHub for Mandatpry lead me here. I did not dig for the source of the error but at this point just assume it's the same issue. The error for me pops up when refreshing the module list in the ISE command add-on. Furthermore, the module Office365DSC is missing from the module list, I assume due to the error.

The error message is:

---------------------------
Windows PowerShell ISE - Error
---------------------------
Failed to refresh. Message: 'Property 'Mandatpry' cannot be found for type 'System.Management.Automation.CmdletBindingAttribute'.'.
---------------------------
OK   
---------------------------

Some assumptions here. I'm happy to dig further if necessary.

fyi @NikCharlebois

NikCharlebois commented 4 years ago

@heinrich-ulbricht can you please confirm what version of ReverseDSC you are using? Latest few versions don't seem to have that anywhere. Latest version should currently be 2.0.0.2 make sure you use the Office365DSC version from GitHub to get the latest bits. Next release to the gallery is planned for Wednesday 22nd.

heinrich-ulbricht commented 4 years ago

@NikCharlebois I installed Office365DSC from the PS Gallery yesterday in a brand new clean Windows VM on Azure.

Those are the versions I got:

Version    Name                                Repository           Description                                                                                                           
-------    ----                                ----------           -----------                                                                                                           
2.0.2.4    AzureAD                             PSGallery            Azure Active Directory V2 General Availability Module....                                                             
16.0.19... Microsoft.Online.SharePoint.Powe... PSGallery            Microsoft SharePoint Online Services Module for Windows PowerShell                                                    
2.0.26     Microsoft.PowerApps.Administrati... PSGallery            PowerShell interface for Microsoft PowerApps and Flow Administrative features                                         
1.0.3      MicrosoftTeams                      PSGallery            Teams Cmdlets module                                                                                                  
0.8.3      MSCloudLoginAssistant               PSGallery            Checks the current status of connections to (and as required, prompts for login to) various Microsoft Cloud platforms.
1.1.183.17 MSOnline                            PSGallery            Microsoft Azure Active Directory Module for Windows PowerShell                                                        
1.0.1.1395 Office365DSC                        PSGallery            This DSC module is used to configure and monitor Office365 tenants, including SharePoint Online, Exchange, Teams, etc.
2.0.0.0    ReverseDSC                          PSGallery            This DSC module is used to extract the DSC Configuration of existing environments.                                    
3.16.19... SharePointPnPPowerShellOnline       PSGallery            SharePoint Patterns and Practices PowerShell Cmdlets for SharePoint Online                                            

What is the latest "version from GitHub" and what is the recommended way to upgrade?

I currently see those options:

SqlSusan commented 3 years ago

I'm also experiencing this issue with when trying to use ReverseDSC for SQL Server: Unable to find type [System.Management.Automation.Hashtable]. At C:\Program Files\WindowsPowerShell\Modules\ReverseDSC\ReverseDSC.Core.psm1:352 char:17

Seems to be ok if it's called directly rather than using a function.

This works: `$module = Resolve-Path ($DSCPath + "\DSCResources\MSFT_SQLServerNetwork\MSFT_SQLServerNetwork.psm1") Import-Module $module $params = Get-DSCFakeParameters -ModulePath $module

$params.InstanceName = $SqlInstance.InstanceName
$params.ProtocolName = "Tcp"`

This doesn't `function Read-SQLNetwork {
param ( [Parameter()] [System.Object] $SqlInstance ) $module = Resolve-Path ($DSCPath + "\DSCResources\MSFT_SQLServerNetwork\MSFT_SQLServerNetwork.psm1") Import-Module $module $params = Get-DSCFakeParameters -ModulePath $module

$params.InstanceName = $SqlInstance.InstanceName
$params.ProtocolName = "Tcp"

$results = Get-TargetResource @params

$Global:dscConfigContent += "        SQLServerNetwork " + [System.Guid]::NewGuid().toString() + "`r`n"
$Global:dscConfigContent += "        {`r`n"
$Global:dscConfigContent += Get-DSCBlock -Params $results -ModulePath $module
$Global:dscConfigContent += "        }`r`n"

} Read-SQLNetwork -SqlInstance $sqlInstance`