You are here

Portable set-up/“launcher” for PowerShell

2 posts / 0 new
Last post
JCSalomon
Offline
Last seen: 3 years 7 months ago
Joined: 2007-09-25 17:40
Portable set-up/“launcher” for PowerShell

A “real” Portable PowerShell (e.g., https://portableapps.com/node/3922) is not what I’m after. I’ve begun to put together a portable set-up which is useable on systems that have PowerShell installed; this would be a launcher useable similarly to Command Prompt Portable.

Here’s PowerShellPortable.cmd:

@echo off

:: Home
set HomeDrive=%~d0
set HomePath=\Documents
set Home=%HomeDrive%%HomePath%

:: I set %Path% here in my personal set-up; this is an area where coordination with Command Prompt Portable would be helpful

powershell -ExecutionPolicy Unrestricted -NoProfile -NoExit -File %HOME%\WindowsPowerShell\Profile.ps1

exit

And here’s X:\Documents\WindowsPowerShell\Profile.ps1:

# Set and force overwrite of the $Home variable
Set-Variable Home $Env:Home -Force

# Set the "~" shortcut value for the FileSystem provider
(get-psprovider 'FileSystem').Home = $Env:Home

# Set this file as the profile for things like the posh-git installer
Set-Variable Profile $MyInvocation.MyCommand.Path

# Add local module path
$ProfilePath = split-path -parent $MyInvocation.MyCommand.Definition
$Env:PSModulePath = "$ProfilePath\Modules;" + $Env:PSModulePath

This works for me, but I would like to make this fit better with the PortableApps setup, and would welcome tips and advice.

Maggard
Offline
Last seen: 6 months 2 weeks ago
Joined: 2006-02-11 01:14
Portable Set-Up/“launcher” for PowerShell

Would adding PowerShell installation verification be feasible? Perhaps checking and outputting to the CMD Console a message that PowerShell is not installed and provide the link for download or link to TechNet's Guide:
http://social.technet.microsoft.com/wiki/contents/articles/21016.how-to-...

.:.
~maggard

Log in or register to post comments