# 自身の profile の PATH 確認
PS C:\Users\Administrator> Write-Output $profile
C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Users\Administrator> Get-Item $profile
# ファイルは存在しない
Get-Item : Cannot find path 'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' because it
does not exist.
At line:1 char:1
+ Get-Item $profile
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\Admini...ell_profile.ps1:String) [Get-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemCommand
# ファイル新規作成
PS C:\Users\Administrator> New-Item $profile -type file -force
Directory: C:\Users\Administrator\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 12/23/2022 12:19 AM 0 Microsoft.PowerShell_profile.ps1
# 例として PowerShell 起動時にメッセージを表示
PS C:\Users\Administrator> Write-Output 'Write-Output "This message is from $profile"' > $profile
PS C:\Users\Administrator> exit
# PowerShell 起動
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
This message is from C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Users\Administrator>
|