# make sure own profile's PATH
PS C:\Users\Administrator> Write-Output $profile
C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Users\Administrator> Get-Item $profile
# none by default
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
# create it
PS C:\Users\Administrator> New-Item $profile -type file -force
Directory: C:\Users\Administrator\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 12/1/2024 4:49 PM 0 Microsoft.PowerShell_profile.ps1
# for example, set command that shows messages in $profile
PS C:\Users\Administrator> Write-Output 'Write-Output "This message is from $profile"' > $profile
PS C:\Users\Administrator> powershell
# run new 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>
|