LoginSignup
0

posted at

Terminalから使うPowerShellとVS CodeのPowerShell Extensionのコンソールとで同じプロファイルを使いたい

はじめに

最近ではPowerShellでいろんなことができるようになってきたのでよく使うのですが、PowerShell Script開発のお供であるVS CodeのPowerShell Extensionを使っていると、通常のPowerShellとはなんとなく違うPowerShellが出ているんですよね。
この画像の"pwsh"というのが通常のPowerShellなのですが、その上の"PowerShell Extension"ってやつです。

2022-11-23_01.png

別に詳しく調べたわけではないので正確なことは知らないのですが、ちょっと触った感じだと"pwsh"と見ているプロファイルが違ったので、今回はこの"PowerShell Extension"でも"pwsh"と同じプロファイルを参照するようにしようというお話です。

前提条件

  • WindowsにプリインストールされているWindows PowerShellではなく、GitHubで開発されているPowerShell Coreを使っていること(GitHub - PowerShell/PowerShell: PowerShell for every system!)
  • PowerShellを管理者権限で実行できること
  • PowerShellのプロファイルが存在していること(%USERPROFILE%\Documents\PowerShell\Microsoft.PowerShell_profile.ps1)

環境情報

私が使用している環境の情報です。

項目
OS Windows 11 Pro
Windows バージョン 21H2
PowerShell バージョン 7.3.0

手順

① PowerShellを管理者として実行

② プロファイルのあるフォルダへ移動

cd ($PROFILE | Split-Path)

③ 下記のコマンドを実行してVSCode用のPowerShellプロファイルにシンボリックリンクを張る

New-Item -ItemType SymbolicLink -Path Microsoft.VSCode_profile.ps1 -Target $PROFILE

以上で完了です。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0