Management

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 785 other subscribers

Social

  • LinkedIn
  • RSS Feed for Posts
  • Twitter
  • StumbleUpon

Start powershell with the same settings everytime.

Do you need to add the same command’s in powershell everytime you start powershell?

This can be done automatically !

 

I always start powershell with start-stranscript and change the default location to C:\Scripts.

You can execute this automatically :

 

First check wetter there is a Profile in use

Test-Path $profile

 

False => there is no profile => create a new profile

True => There already is a profile

 

Create a new profile:

New-Item -path $profile -type file –force

 

Edit an existing profile:

If ((Test-Path $Profile) -eq “True”) {Notepad $Profile}

 

You can view the location of you’re $Profile by executing :

$Profile

 

Add you’re default command’s and save

Change the windows size + scroll back buffer

$Shell = $Host.UI.RawUI
$size = $Shell.WindowSize
$size.width=80
$size.height=60
$Shell.WindowSize = $size
$size = $Shell.BufferSize
$size.width=80
$size.height=5000
$Shell.BufferSize = $size

 

Change title:

$Shell.WindowTitle=”VSPBreda”

 

Change colors:

$shell.BackgroundColor = “Gray”
$shell.ForegroundColor = “Black”

 

Add alias to scripts you’ll often use:

new-item alias:cal -value C:\Windows\System32\calc.exe

 

Clear your screen :

Clear-host

 

 

 

Screen output :

 

Now we can call the scripts often used with their alias

(in this example I’ve used cal for calculator.exe, you can use every script you want)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.