Windows 2016
Sponsored Link

PowerShell : Set Profile2019/03/06

 
Set Profile it is loaded when PowerShell starts.
[1] By default, Profile does not exist, so create it first and set any commands or variables you like.
# 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 bind argument to parameter 'Path' because it is null.
At line:1 char:10
+ Get-Item $profle
+          ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemComm
   and

# create it
PS C:\Users\Administrator> New-Item $profile -type file -force 

    Directory: C:\Users\Administrator\Documents\WindowsPowerShell


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         3/6/2019  19:10 AM              0 Microsoft.PowerShell_profile.ps1


# for example, set command that shows messages [This is from $profile]
PS C:\Users\Administrator> Write-Output 'Write-Output "This is from $profile"' > $profile 
PS C:\Users\Administrator> exit 

# run PowerShell
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

# message is displayed
This is from C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Users\Administrator>
Matched Content