PowerShell ISE $PROFILE

Welcome Forums Pester PowerShell ISE $PROFILE

Viewing 2 reply threads
  • Author
    Posts
    • #104587
      Participant
      Topics: 15
      Replies: 13
      Points: 92
      Rank: Member

      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.

    • #104609
      Participant
      Topics: 2
      Replies: 1013
      Points: 2,093
      Helping Hand
      Rank: Community Hero

      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…

    • #104641
      Participant
      Topics: 4
      Replies: 90
      Points: 404
      Helping Hand
      Rank: Contributor

      Here is an example of one of the ways I use my PS profile script.

      Windows PowerShell – Realizing your pro(file)tential!

Viewing 2 reply threads
  • The topic ‘PowerShell ISE $PROFILE’ is closed to new replies.