dataplat / Invoke-SqlCmd2

PowerShell module containing Invoke-SqlCmd2
MIT License
68 stars 35 forks source link

PowerShell Core Support #22

Closed jakedenyer closed 4 years ago

jakedenyer commented 6 years ago

Was just trying this Command in PowerShell Core 6.1 and noticed while using it with the -As PSObject switch, it was failing. The command was unable to import the inline C# code for DBNullScrubber.

I know PowerShell Core isn't called out as supported. I'm just working on refactoring an internal module that uses this command quite often.

I was able to get this working by changing the following line.

Add-Type -TypeDefinition $cSharp -ReferencedAssemblies 'System.Data', 'System.Xml' -ErrorAction stop

To

Add-Type -TypeDefinition $cSharp -ReferencedAssemblies 'System.ComponentModel.TypeConverter','System.Data', 'System.Data.Common', 'System.Xml', 'System.Management.Automation' -ErrorAction stop

This isn't really an issue, more of a suggestion if people are trying to convert this to PowerShell Core. (Keep in mind - i did not test this fully, just the -As PSObject switch)

jeremymcgee73 commented 5 years ago

This should work after my PR gets merged! https://github.com/sqlcollaborative/Invoke-SqlCmd2/pull/21

jeremymcgee73 commented 5 years ago

@jakedenyer Can you try the latest version from Github? I believe your issue should be resolved.