The sub-techniques beta is now live! Read the release blog post for more info.

PowerShell Profile

Adversaries may gain persistence and elevate privileges in certain situations by abusing PowerShell profiles. A PowerShell profile (profile.ps1) is a script that runs when PowerShell starts and can be used as a logon script to customize user environments. PowerShell supports several profiles depending on the user or host program. For example, there can be different profiles for PowerShell host programs such as the PowerShell console, PowerShell ISE or Visual Studio Code. An administrator can also configure a profile that applies to all users and host programs on the local computer. [1]

Adversaries may modify these profiles to include arbitrary commands, functions, modules, and/or PowerShell drives to gain persistence. Every time a user opens a PowerShell session the modified script will be executed unless the -NoProfile flag is used when it is launched. [2]

An adversary may also be able to escalate privileges if a script in a PowerShell profile is loaded and executed by an account with higher privileges, such as a domain administrator. [3]

ID: T1504
Tactic: Persistence, Privilege Escalation
Platform: Windows
Permissions Required: User, Administrator
Data Sources: Process monitoring, File monitoring, PowerShell logs
Contributors: Allen DeRyke, ICE
Version: 1.0
Created: 14 June 2019
Last Modified: 19 July 2019

Procedure Examples

Name Description

Turla has used PowerShell profiles to maintain persistence on an infected machine.[2]


Mitigation Description
Code Signing

Enforce execution of only signed PowerShell scripts. Sign profiles to avoid them from being modified.

Restrict File and Directory Permissions

Making PowerShell profiles immutable and only changeable by certain administrators will limit the ability for adversaries to easily create user level persistence.

Software Configuration

Avoid PowerShell profiles if not needed. Use the -No Profile flag with when executing PowerShell scripts remotely to prevent local profiles and scripts from being executed.


Locations where profile.ps1 can be stored should be monitored for new profiles or modifications. [4] Example profile locations include:

  • $PsHome\Profile.ps1
  • $PsHome\Microsoft.{{HostProgram}}_profile.ps1
  • $Home\My Documents\PowerShell\Profile.ps1
  • $Home\My Documents\PowerShell\Microsoft.{{HostProgram}}_profile.ps1

Monitor abnormal PowerShell commands, unusual loading of PowerShell drives or modules, and/or execution of unknown programs.