When Windows PowerShell starts, standard modules are loaded and the location of the prompt is set to C:\Users\Username. If you want to load additional modules, create an alias for a command, or simply display information, then it´s a good idea to create a Powershell Profile.
The profile is loaded by a PS1 file, which is located (once it is created) in the users Documents folder and is loaded at startup of PowerShell.
It is necessary to verify that the Execution Policy allows to run ps1 files. The Execution Policy should be set to either Remotesigned or Unrestricted (not recommended).
If the policy is configured to Restricted, then the Execution Policy must be adjusted.
Configuring a Profile for the current user
Now the file can be created with New-Item.
New-Item -ItemType File -Path $Profile -Force
The file is stored in the user profile C:\User\UserName\Documents\WindowsPowerShell.
Configure a Profile for all users
If you want to configure a profile for all users run
New-Item -ItemType File -Path $PROFILE.AllUsersAllHosts -Force
This will configure a profile file for all users and all hosts (PowerShell and Powershell ISE).
Once created open it with PowerShell ISE.
Writing the Script (Current User)
Open the file in Windows Explorer or in PS. For coding, I recommend PowerShell ISE.
Now you can customize your script. I have prepared an example. Copy the code and run it.
Write-Host "Welcome to" (Invoke-Expression hostname) -ForegroundColor Green Write-Host "You are logged in as" (Invoke-Expression whoami) Write-Host "Today:" (Get-Date) Set-Location c:\ New-Alias Time Get-Date -Force Write-Host "PowerShell"($PSVersionTable.PSVersion.Major)"awaiting your commands."
Now close PowerShell and open it again.
Finally, I want to share my profile. I set the location to C: and I reduced the size of the window. At the end you can see Start-Transcript. That records all the work on.
set-location c:\ cls $Shell = $Host.UI.RawUI $size = $Shell.WindowSize $size.width=80 $size.height=34 $Shell.WindowSize = $size $size = $Shell.BufferSize $size.width=80 $size.height=3000 $Shell.BufferSize = $size Start-Transcript
More about Start-Transcript in my article: PowerShell: Documenting your work with Start-Transcript