Search code examples
powershellchocolateypowershell-module

How to import Chocolatey function, core and extension to PowerShell sessions?


I find many Chocolatey helper functions:

C:\ProgramData\chocolatey\helpers\functions

and extension functions

C:\ProgramData\chocolatey\extensions\chocolatey-core

are very useful when you develop even non Chocolatey packages. Is there any way to import these function to Powershell scripts and Powershell Console sessions?


Solution

  • when you install chocolatey, it puts a few lines of code in your powershell profile that load the various extensions & functions. [grin] you can find the various profiles here ...

    $Profile |
        Select-Object -Property *
    

    you can find the choco files here ...

    Get-ChildItem -Path env:\choc*
    

    for me, the loader is here ...

    C:\ProgramData\chocolatey\lib\chocolatey\tools\chocolateyInstall\helpers\chocolateyProfile.psm1
    

    the code in my profile that loads it is ...

    Import-Module $ChocolateyProfile