Profiles

The current user profile on Linux resides under the home directory:

~/.config/powershell 

Two profiles can be created: CurrentUserCurrentHost (Microsoft.PowerShell_profile.ps1) and Current User (profile.ps1). Inspecting the automatic variable, $PROFILE shows the first of these:

  1. The directory will need to be created prior to use; the following command creates it:
New-Item ~/.config/powershell -ItemType Directory 
  1. Create a simple profile file by sending a string to a file:
‘Write-Host “Welcome to PowerShell” -ForegroundColor Green’ |
Out-File .config/powershell/profile.ps1
  1. The AllUser profile may be created under PowerShell's installation directory, in this case, alpha 12, as this is the version I have installed:
/opt/microsoft/powershell/6.0.0-alpha.12 
  1. Writing to this area of the filesystem requires the root privileges:
sudo vi /opt/microsoft/powershell/6.0.0-alpha.12/profile.ps1 
  1. Inside vi, press i to enter insert mode and then type the following:
Write-Host 'This is the system profile' -ForegroundColor Yellow 
  1. Once completed, press Esc, then type :wq to save and quit vi.
  2. As with PowerShell on Windows, this will be executed before a user-level profile that shows the following in the console when the shell is started:
This is the system profile 
Welcome to PowerShell 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.247.125