Author Posts

July 18, 2018 at 11:13 am

Hi!
I have been making some scripts and some modules.
Now i am setting up my $PROFILE and was wondering, what do you guys put in your profile?
Any tips for me about what to put in here?

Thanks, Sigurd.

July 18, 2018 at 4:21 pm

This is really a matter of need. So, you will end up with a wide ranging set of responses. Only put in what you need / desire that you use on a daily basis.

You'd have a different configure for the console profile, ISE profile and a VSCode.

I personally use a single profile config and in that template, put logic to check what editor / console in use and branch to what I want loaded. so, this way I really only have one profile to config / manage and backup. Since it is the same info in all named profiles.

Example:

# ISE baseline tools
If ($Host.Name -match 'ISE')
{
    Import-Module -Name ISEModuleBrowserAddon
    Start-Sleep -Seconds 9
    Import-Module -Name PsISEProjectExplorer
    Import-Module -Name PSharp
    Import-Module -Name ClassExplorer


    #Script Browser Begin
    #Version: 1.3.2
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\System.Windows.Interactivity.dll'
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\ScriptBrowser.dll'
    Add-Type -Path 'C:\Program Files (x86)\Microsoft Corporation\Microsoft Script Browser\BestPractices.dll'
    $scriptBrowser = $psISE.CurrentPowerShellTab.VerticalAddOnTools.Add('Script Browser', [ScriptExplorer.Views.MainView], $true)
    $scriptAnalyzer = $psISE.CurrentPowerShellTab.VerticalAddOnTools.Add('Script Analyzer', [BestPractices.Views.BestPracticesView], $true)
    $psISE.CurrentPowerShellTab.VisibleVerticalAddOnTools.SelectedAddOnTool = $scriptBrowser
    #Script Browser End
}

# Console Baseline tools

Import-Module -Name PSReadline
Import-Module -Name Posh-SSH
Import-Module -Name ModuleLibrary -DisableNameChecking
Import-Module -Name ClassExplorer

# Set working path
Push-Location -Path 'D:\Scripts'

# Additional tools 

# Custom Prompt
...

You will still have 3 profiles for the different environments, but the info in them are identical. So, I only make changes in my profile template and copy that to the three profiles on my system.

Microsoft.PowerShell_profile.ps1
Microsoft.PowerShellISE_profile.ps1
Microsoft.VSCode_profile.ps1

I use the same approach on my servers, but with the additional module adds depending on server role. I.e., SQL, Exchange, SharePoint, IIS, AD, etc...

July 18, 2018 at 9:00 pm

Here is an example of one of the ways I use my PS profile script.
http://www.loganboydell.tech/windows-powershell-realizing-your-profiletential/