0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

パワーシェル、プロンプト変更方法

Last updated at Posted at 2023-09-08
PS C:\WINDOWS\system32> New-Item $profile -force -type file


    ディレクトリ: C:\Users\(ユーザ名)\Documents\WindowsPowerShell


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        2023/09/08     10:07              0 Microsoft.PowerShell_profile.ps1

PS C:\WINDOWS\system32> notepad $PROFILE
Microsoft.PowerShell_profile.ps1

function prompt { 
    $user = $env:USERNAME 
    $computer = $env:COMPUTERNAME 
    $location = (Get-Location).Path 
    $date = Get-Date -Format "yyyy-MM-dd HH:mm:ss" 
    Write-Host ("PS $user@$computer"+":"+"$location - $date >" )
    }
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name

これは、カレントユーザ名(現在のユーザを表す)

PS C:\WINDOWS\system32> . $PROFILE
PS (ユーザ名)@(PC名):C:\WINDOWS\system32 - 2023-09-08 11:14:51 >

パワーシェル再起動

PS (ユーザ名)@(PC名):C:\WINDOWS\system32 - 2023-09-08 11:18:33 >
PS>

となることを確認

0
0
0

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
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?