Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TCEDIT your PowerShell Profile

Aug
1,949
71
The TCEDIT command allows one to easily edit the TCMD.INI or the TCSTART.BTM files using the /INI and /START command line options, without having to know where these files are located.

While there is no command line option for TCEDIT to easily edit my PowerShell Profile, it is still easy to do so using;
Code:
tcedit %@pshell[$Profile]
That way, I don't have to know where my PowerShell Profile is located, in order to edit it.

Joe
 
It's a bit different here. PowerShell doesn't seem to know the name of it's profile file. In PowerShell, I get

Code:
V:\> $profile
C:\Users\vefatica\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

V:\> type $profile
type : Cannot find path 'C:\Users\vefatica\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1' because it does not exist.
At line:1 char:1
+ type $profile
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\vefati...ell_profile.ps1:String) [Get-Content], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
 
It does load a profile; this one

Code:
 C:\Users\vefatica\Documents\WindowsPowerShell\profile.ps1
.

At least it could name the one it used.
 
Never mind, looks like "profile.ps1" is just one of the possible profiles it tries to load at startup. The preferred (most specific) name is "Microsoft.PowerShell_profile.ps1"
 
From SS64:
To support configurations for multiple users on the same machine, there are 4 locations where you can store a Profile.ps1 file:
1. "All users" profile "<Installation Directory>\profile.ps1"
2. "All users," host-specific profile "<Installation Directory>\Microsoft.PowerShell_profile.ps1"
3. Current user profile "<My Documents>\WindowsPowerShell\profile.ps1"
4. Current User, host-specific profile"<My Documents>\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"

To see the Powershell profiles on my system;
Code:
pshell /s "$profile | Get-Member -Type NoteProperty"
Code:
   TypeName: System.String

Name                   MemberType   Definition                                                                          
----                   ----------   ----------                                                                          
AllUsersAllHosts       NoteProperty string AllUsersAllHosts=C:\WINDOWS\system32\WindowsPowerShell\v1.0\profile.ps1      
AllUsersCurrentHost    NoteProperty string AllUsersCurrentHost=C:\WINDOWS\system32\WindowsPowerShell\v1.0\Microsoft.P...
CurrentUserAllHosts    NoteProperty string CurrentUserAllHosts=e:\Documents\WindowsPowershell\profile.ps1               
CurrentUserCurrentHost NoteProperty string CurrentUserCurrentHost=e:\Documents\WindowsPowershell\Microsoft.PowerShell...

On my system;
Code:
pshell /s "test-path -path $Profile"
...returns True.

On my system;
Code:
pshell /s "test-path -path $Profile.AllUsersCurrentHost"
...returns False.

WAD, as $Profile is just a pointer to the profile file name.

Joe

Ref: about_Profiles
Ref: $Profile
 
I have Powershell Preview 7.3.0 and version 5.1 on my WIndows 11 box. And the profiles are in different places, so I simply have each profile contain one line:

. c:\powshell\myalias.ps1

I do like to simplify things when possible.
 
Back
Top