locked
Powershell Customization RRS feed

  • Question

  • Hi Experts,

    When Windows PowerShell starts, standard modules are loaded and the location of the prompt is set to C:\Users\Username.Is there a way to configure this so that when I start powershell I get computer name, usename, date, time, different colour, windows size or anything that I want?
    Sunday, August 20, 2017 7:49 AM

Answers

  • Yes, you will need to create powershell profile, edit it and type in the values you would like to have. 

    Example

    You can create a new profile with 

    New-Item -ItemType File -Path $Profile -Force
    Then you can open powershell ISE 
    ise $profile
    Next what you can type in is for example: 
    Write-Host "Welcome to" (Invoke-Expression hostname) -ForegroundColor Green
    Write-Host "You are logged in as" (Invoke-Expression whoami)
    Write-Host "Today:" (Get-Date)
    Set-Location c:\
    New-Alias Time Get-Date -Force
    Write-Host "PowerShell"($PSVersionTable.PSVersion.Major)"awaiting your commands."
    Close the powershell and re-open it again

    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org

    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 8:06 AM
  • Yes, you can do it with

    New-Item -ItemType File -Path $PROFILE.AllUsersAllHosts -Force
    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org


     
    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 8:21 AM
  • Just to point that there are 6 different profiles that you can create so you can choose the one which is best for you. 

    Current User, Current Host
    Current User, All Hosts   
    All Users, Current Host - console   
    All Users, All Hosts      
    Current user, Current Host - ISE
    All users, Current Host - ISE  

    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org

    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 8:23 AM
  • Yes, this may help

    https://www.howtogeek.com/50236/customizing-your-powershell-profile/

    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org

    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 9:08 AM

All replies

  • Very nice, many thanks Nedim, Can we use it for all users or only one user? It looks like that this command will create only for my user account. 
    Sunday, August 20, 2017 8:14 AM
  • Yes, you can do it with

    New-Item -ItemType File -Path $PROFILE.AllUsersAllHosts -Force
    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org


     
    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 8:21 AM
  • Just to point that there are 6 different profiles that you can create so you can choose the one which is best for you. 

    Current User, Current Host
    Current User, All Hosts   
    All Users, Current Host - console   
    All Users, All Hosts      
    Current user, Current Host - ISE
    All users, Current Host - ISE  

    ------------------------------------------------------------------------------------------------------------
    If you found this post helpful, please give it a "Helpful" vote. 
    Please remember to mark the replies as answers if they help.

    nedimmehic.org

    • Marked as answer by Lucas Wagner Sunday, August 20, 2017 10:01 AM
    Sunday, August 20, 2017 8:23 AM
  • Thank you. Is there a way to change the size or colour of the powershell window as well?
    Sunday, August 20, 2017 8:48 AM