# Comment line
<#
comment block
#>
function Get-UserInfo {
<#
.SYNOPSIS
Get the Microsoft 365 user information
.DESCRIPTION
Retrieves detailed information about a specified Microsoft 365 user
.PARAMETER Username
The username of the Microsoft 365 user
.EXAMPLE
Get-UserInfo -Username '[email protected]'
Retrieves information for the user '[email protected]'
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$Username
)
# Function code here
}
Usage: Get-Help -Name My-Function -Detailed
List the various PowerShell Profile locations
$profile | Format-List -Force
Load PowerShell without profile
powershell.exe -noprofile
powershell_ise.exe -NoProfile
Profile script Variables load in to global scope context by default.
Help about_profiles and about_scopes
- Windows PowerShell
- Windows PowerShell ISE
- PowerShell on Windows
- PowerShell Core on Windows
- PowerShell Core on Linux
- PowerShell Core on Mac OS
Change unsigned script permissions for single session:
...
AllUsersAllHosts : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\Admin\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\Admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
AllUsersAllHosts : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1
CurrentUserAllHosts : C:\Users\Admin\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\Admin\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
Alternate sort order
The PowerShell console supports the following basic profile files. These file paths are the default locations.
- All Users, All Hosts
- Windows -
$PSHOME\Profile.ps1 - Linux -
/opt/microsoft/powershell/7/profile.ps1 - macOS -
/usr/local/microsoft/powershell/7/profile.ps1
- Windows -
- All Users, Current Host
- Windows -
$PSHOME\Microsoft.PowerShell_profile.ps1 - Linux -
/opt/microsoft/powershell/7/Microsoft.PowerShell_profile.ps1 - macOS -
/usr/local/microsoft/powershell/7/Microsoft.PowerShell_profile.ps1
- Windows -
- Current User, All Hosts
- Windows -
$HOME\Documents\PowerShell\Profile.ps1 - Linux -
~/.config/powershell/profile.ps1 - macOS -
~/.config/powershell/profile.ps1
- Windows -
- Current user, Current Host
- Windows -
$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 - Linux -
~/.config/powershell/Microsoft.PowerShell_profile.ps1 - macOS -
~/.config/powershell/Microsoft.PowerShell_profile.ps1
Microsoft advises against redirecting the Documents folder with GPO or OneDrive as this may break PowerShell Profile and Module load paths.
The profile scripts are executed in the order listed. This means that changes made in the **AllUsersAllHosts** profile can be overridden by any of the other profile scripts. The **CurrentUserCurrentHost** profile always runs last. In PowerShell Help, the **CurrentUserCurrentHost** profile is the profile most often referred to as *your PowerShell profile*. - Windows -
Other programs that host PowerShell can support their own profiles. For example, Visual Studio Code (VS Code) supports the following host-specific profiles.
- All users, Current Host -
$PSHOME\Microsoft.VSCode_profile.ps1 - Current user, Current Host -
$HOME\Documents\PowerShell\Microsoft.VSCode_profile.ps1
The profile paths include the following variables:
- The
$PSHOMEvariable stores the installation directory for PowerShell - The
$HOMEvariable stores the current user's home directory
https://code.visualstudio.com/docs/terminal/profiles
C:\Users\{USERNAME}\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState
C:\Users\{username}\AppData\Local\Microsoft\Windows Terminal\settings.json
%userprofile%\AppData\Local\Microsoft\Windows Terminal\settings.json
$settings = (Get-Item "C:\users\$env:UserName\AppData\Local\Packages\Microsoft.WindowsTerminal_*\LocalState\settings.json")
$settings.DirectoryName
The powershell.config.json file contains configuration settings for PowerShell. PowerShell loads this configuration at startup.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_config
(not including the previews)
There are multiple ways to install PowerShell in Windows. Each install method is designed to support different scenarios and workflows. Choose the method that best suits your needs.
- Winget - Recommended way to install PowerShell on Windows clients
- MSI package - Best choice for Windows Servers and enterprise deployment scenarios
- ZIP package - Easiest way to "side load" or install multiple versions
- Use this method for Windows Nano Server, Windows IoT, and Arm-based systems
- .NET Global tool - A good choice for .NET developers that install and use other global tools
- Microsoft Store package - An easy way to install for casual users of PowerShell but has limitations
** Note**
The installation commands in this article are for the latest stable release of PowerShell. To install a different version of PowerShell, adjust the command to match the version you need. The following links direct you to the release page for each version in the PowerShell repository on GitHub.
- Stable release: https://aka.ms/powershell-release?tag=stable
- LTS release: https://aka.ms/powershell-release?tag=lts
- Preview release: https://aka.ms/powershell-release?tag=preview
Download links for every package are found in the Assets section of the Release page. The Assets section may be collapsed, so you may need to click to expand it.
Note: PowerShell 7.4 installs to a new directory and runs side-by-side with Windows PowerShell 5.1. PowerShell 7.4 is an in-place upgrade that removes previous versions of PowerShell 7
By default, Windows Store packages run in an application sandbox that virtualizes access to some filesystem and registry locations. Changes to virtualized file and registry locations don't persist outside of the application sandbox.
This sandbox blocks all changes to the application's root folder. Any system-level configuration settings stored in $PSHOME can't be modified. This includes the WSMAN configuration. This prevents remote sessions from connecting to Store-based installs of PowerShell. User-level configurations and SSH remoting are supported.
The following commands need write to $PSHOME. These commands aren't supported in a Microsoft Store instance of PowerShell.
Register-PSSessionConfigurationUpdate-Help -Scope AllUsersEnable-ExperimentalFeature -Scope AllUsersSet-ExecutionPolicy -Scope LocalMachine