powershelldll.net-assemblygacazure-data-explorer

How to load DLL files in PowerShell


I am following MS Document to use Kusto in PowerShell,

When ever I run the installation script ,

$packagesRoot = "C:\Myfiles\tools"
dir $packagesRoot\* | Unblock-File
[System.Reflection.Assembly]::LoadFrom("$packagesRoot\Kusto.Data.dll")

I am getting GAC as False and unable to install the Kusto Dll file as below

enter image description here

Please help me.


Solution

  • Add-Type -LiteralPath "$packagesRoot\Kusto.Data.dll"
    

    The output you're seeing is simply how PowerShell's formatting system represents the System.Reflection.Assembly object returned from the System.Reflection.Assembly.LoadFrom() call - and the fact that such an object was returned implies success.

    The GAC column reflecting False simply tells you that the assembly in the question isn't stored in the GAC.


    As an aside re the GAC (Global Assembly Cache):


    [1] -PassThru always outputs type, not assembly information, so that when you combine -PassThru with -Path / -LiteralPath, i.e. when you load an assembly, it is info objects about the types contained in the assembly that are output (not an object describing the assembly itself, which is what [System.Reflection.Assembly]::LoadFrom does). However, due to a bug as of PowerShell 7.1 relating to forwarded types, the latter aren't included, which can result in no output altogether - see GitHub issue #10802.