How do you load the toolkit so it autocomplete in Visual Code?

I use mostly visual code for creating the install script but how do i load so the function in the toolkit so it autocomplete in the editor…

thanks

I wasn’t a big fan of Visual Code when I tried it out, but I do recall you need to load a Powershell extension in order to get it to autocomplete and do the color-coding. (File > Preferences > Extensions)

Instead of Visual Code, I’m using the Windows Powershell ISE with an addon called ISESteroids. You may want to give it a look. It’s pretty awesome.

ISESteroids is cool but it not free and…like vscode because there is a dark theme for it and alot of extensions.

got it to work by following these steps:

Configuring PSAppDeployToolkit for Intellisense in Visual Studio Code

  1. Install the PowerShell Extension for VS Code
  2. https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell
  3. Set the default language to PowerShell (optional)
  4. Under Settings (Ctrl+,) find Files: Default Language
  5. Set this to powershell
  6. Close Settings
  7. Download PSAppDeployToolkit
  8. https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/releases
  9. Extract the contents to a folder
  10. Copy the Toolkit folder to a path of your choosing (such as these options)
  11. $Home\Documents\WindowsPowerShell\Modules
  12. $Env:ProgramFiles\WindowsPowerShell\Modules
  13. Mine is copied to: C:\Users\user\Documents\WindowsPowerShell\Modules\AppDeployToolkit
  14. Convert the script to a module
  15. In ISE: Open \Documents\WindowsPowerShell\Modules\AppDeployToolkit_AppDeployToolkitMain.ps1_
  16. File > Save As
  17. Change type to PowerShell Script Module
  18. Change name to: AppDeployToolkit.psm1
  19. Delete AppDeployToolkitMain.ps1, it is no longer needed
  20. Update the PSADT XML
  21. Edit AppDeployToolkitConfig.xml
  22. Edit Toolkit_RequireAdmin (line 17) from True to False
  23. Create a VS Code profile
  24. Launch VS Code and select the PowerShell Integrated Console terminal then type in notepad $profile
  25. If no profile exists, Notepad will ask to create the file, select Yes
  26. Add a line to import the module:
  27. Import-Module $Home\Documents\WindowsPowerShell\Modules\AppDeployToolkit
  28. I also add a line to clear the host, as I don’t want to see the import each time.
  29. Clear-Host
  30. Save Microsoft.VSCode_profile.ps1 and close Notepad
  31. Relaunch VS Code
  32. It will switch to the PowerShell extension, perform the import from the profile, then clear the host.
  33. You can confirm by running: get-help copy-file

Credit to Christian Nyhuus for documenting the steps for ISE

https://www.nyhu.us/powershell/psadt/intellisense-psadt-powershell-ise/ https://www.reddit.com/r/MDT/comments/5e3n5e/autocomplete_for_psadt_in_powershell_ise/

2 Likes

I prefer ISE as I have to move from computer to computer so no need to be install. Also, PSADTK is running with no need to special configuration as shown below.

Thanks for this detailed information, @long!

Based on your post, i edited my $profile-file with this:

$PSADTPath = "H:\Pack\Scripts\GDrive\CMDs\CodeSnippets\Silvermonkey Templates Test\Release\AppDeployToolkit"

If ( Test-Path -Path $PSADTPath ) {
  Copy-Item -Path $PSADTPath -Destination "$env:Temp" -Force -Recurse

  Push-Location "$env:Temp\$(Split-Path -Path $PSADTPath -Leaf)"
  $ToolKit = [XML](Get-Content .\AppDeployToolkitConfig.xml)
  $ToolKit.AppDeployToolkit_Config.Toolkit_Options.Toolkit_RequireAdmin = "False"
  $ToolKit.Save("$pwd\AppDeployToolkitConfig.xml")

  If ( Test-Path -Path .\AppDeployToolkitMain.ps1 ) {
    Move-Item -Path .\AppDeployToolkitMain.ps1 -Destination .\AppDeployToolkitMain.psm1 -Force
  }

  Import-Module .\AppDeployToolkitMain.psm1

  Pop-Location
} 

so it’ll load a fresh copy everytime, i start my favorite editor, or if using vscode: reload the window.

Thank you so much for guiding me in the right direction!

kind regards
BaBa

1 Like