Yesterday I posted my experiences in setting up the latest build of VSCode on how to use a PowerShell terminal session. As I explained, in this particular session I didn't want to run any profile scripts. My reasoning was that this session obviously wasn't the ISE nor was I likely to use the session like I do the traditional console host. But, I also realized there were some tools and settings I would find useful. Obviously I didn't want to manually configure the VSCode PowerShell session every time it started. It needed a profile script.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
Since VS Code is simply running PowerShell.exe, there were no new profile options. So I created my own. I wrote a simple PowerShell script that dot sourced a few items so that I'd have access to tools and functions in this terminal. As well as defining variables that will be unique to this session.
#profile script for VS Code PowerShell session Write-Host "Configuring VSCode PowerShell Terminal" -ForegroundColor Yellow #dot source some useful commands and tools . C:\scripts\Copy-HistoryCommand.ps1 . C:\scripts\Tee-MyObject.ps1 . C:\scripts\jdh-variables.ps1 . C:\scripts\jdh-psdrives.ps1 . C:\scripts\jdh-aliases.ps1 . C:\Scripts\Copy-Command\Copy-Command.ps1 #define some VSCode specific variables for future use. $InVSCode = $True
This is essentially a stripped down variation of my normal PowerShell profile script. Next, I modified the batch file I'm using to launch PowerShell in VSCode.
::STARTPS.BAT ::This batch file is intended to start a PowerShell session ::as an integrated terminal window in VS Code @echo off ::Force running the 64bit version of PowerShell c:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe -nologo -noexit -noprofile -file c:\scripts\vscode-profile.ps1
I'm telling PowerShell to run a script file and then not exit. Now when I launch PowerShell in VSCode I get a result like this:
I'm looking forward to exploring how I can use VSCode in my daily script developing. There are limitations today, but I know we're just getting started and I'm very interested to see where we end up.