Windows10 Powershellの起動時に.ps1を起動

windows 10Powershell起動時に何かを起動したい場合に方法を記述する。

  • Powershellを実行する


  •  Powershellの起動時スクリプトファイルのパスを探す。


$profileを実行し、WindowsPowerShell\Microsoft.PowerShell_profile.ps1のパスを探す。 PS C:\Users\pdpaaa> $profile C:\Users\pdpaaa\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  • $profileのパスにMicrosoft.PowerShell_profile.ps1がなければ、作成する。試しで書きを記述する。

Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete

 

  • Powershellの実行権限の変更


    起動時に.ps1を起動できるようにするため、下記のコマンドで確認
    PS C:\PowerShell> Get-ExecutionPolicy
    Restricted
  • Restrictedである場合は実行権限を変更

    下記を実行し、エラーがでれば、Powershellを管理者権限で実行してください。変更後、Powershell再実行、コマンド候補が出るようになれば成功する。


    PS C:\PowerShell> Set-ExecutionPolicy RemoteSigned

コメント

タイトルとURLをコピーしました