Export PSSession - PowerShell


Export-PSSession exports a PowerShell session to a file, enabling you to share and recreate sessions across different computers or environments. It saves the session’s configuration, including its runspaces, modules, snap-ins, and variables.


Export-PSSession [-Path] <string> [-Force] [-IncludeModules] [-Prefix] <string> [-AllowNonInteractive]


  • -Path: Specifies the file path to export the session to. If the file exists, it prompts you for confirmation before overwriting. Default: Current directory.
  • -Force: Exports the session without prompting for confirmation, even if the file exists.
  • -IncludeModules: Exports the session with all loaded modules. By default, only essential modules are included.
  • -Prefix: Specifies a prefix to use for exported module names. Default: “EP_”
  • -AllowNonInteractive: Exports the session even if it contains non-interactive credentials. This can lead to security risks, so use with caution.


  • Export a session to a file:
Export-PSSession -Path "C:\Example\MySession.psses"
  • Export a session with all loaded modules:
Export-PSSession -Path "C:\Example\MySession.psses" -IncludeModules
  • Export a session without prompting:
Export-PSSession -Path "C:\Example\MySession.psses" -Force

Common Issues

  • Access Denied: Ensure you have write permissions to the target folder.
  • Non-Interactive Credentials: When exporting sessions with non-interactive credentials, consider the security implications and use appropriate measures to protect the exported data.


  • Import-PSSession: Imports an exported session file, re-establishing the session’s environment on another computer.
  • PowerShell Remoting: Export and import sessions to facilitate remote PowerShell management.
  • Scripting: Automate session management tasks by incorporating Export-PSSession into scripts.
  • New-PSSession: Creates a new PowerShell session.
  • Enter-PSSession: Enters a PowerShell session.