Pages

28 May 2019

Create a PowerShellISE and PowerShell profile

Load all your favorite modules at startup, set locations, clear screens, start transcripts in a smart way.

First create your profile if none exists.
Open the PowerShellISE and in the console window run:
if (!(test-path $profile)) {new-item -type file -path $profile -force}
This will create the profile file used by the PowerShellISE only.

If you run this from the regular PowerShell window a profile file will also be created but it will be used by the regular PowerShell only.

The PowerShellISE profile file is always located at:
%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

The PowerShell profile file is always located at:

%UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Notice this profile file has a different name

Then open this file and add the following:
Add-PSsnapin *Exchange* -ErrorAction SilentlyContinue
Import-Module IsePackV2 -Force
Set-Location C:\
[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://proxy.domain.lan:8080')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
Start-Transcript -Path "\\domain.lan\someshare$\userhome\Transscripts\$env:computername.txt"

No comments:

Post a Comment