#Import-Module: Unable to find type [System.Diagnostics.FileVersionInfo].

18 messages · Page 1 of 1 (latest)

untold adder
#

because Im getting an error on Connect-DbaInstance -ConnectionString $connstring
error: ```
Connect-DbaInstance: The 'Connect-DbaInstance' command was found in the module 'dbatools', but the module could not be loaded. For more information, run 'Import-Module dbatools'.


I tried to do import-module dbatools
But there is an another error: `Import-Module: Unable to find type [System.Diagnostics.FileVersionInfo].`

How to overcome these errors?
silver agate
#

what PowerShell version are you using?

untold adder
#

7.2.8

#

Powershell Core

silver agate
#

that type exists on Windows and Linux, not sure how you've got to the point where it's not present. Does anything else fail?

untold adder
#

WHen I hit (Get-Module).Name I only have this modules

#
Az.Sql
Microsoft.PowerShell.Management
Microsoft.PowerShell.Security
Microsoft.PowerShell.Utility
PackageManagement
PowerShellEditorServices.Commands
PowerShellEditorServices.VSCode
PowerShellGet
PSReadLine
SqlServer```
silver agate
#

that's the VS Code terminal by the looks of it?

#

same happens in the regular PS console?

untold adder
#

hm, i tlooks its working in regular PS console

silver agate
#

you should have this assembly loaded: ```ps
[AppDomain]::CurrentDomain.GetAssemblies() | ? Location -match 'FileVersionInfo'

#

win PS loads it from elsewhere, but PS 6+ uses the dll shipped with PS itself

#

in VS Code, you could try ```ps
Add-Type -Path C:\Program Files\PowerShell\7\System.Diagnostics.FileVersionInfo.dll

untold adder
#

Add-Type: Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path 'C:\Program' because it does not exist."

silver agate
#

oops, sorry, forgot quotes

#
Add-Type -Path "C:\Program Files\PowerShell\7\System.Diagnostics.FileVersionInfo.dll"
untold adder
#

yes, now it works! I was just restarted vs code

silver agate
#

weird though, you really shouldn't have to do that