Monday, January 16, 2012

Alias and Powershell profiles

 

Hi All

I love “RUN” box.  We can open run box “Windows Key + R” and type the Excel, Powerpoint, and click on OK and its open these application which are in the System path.

1

But if you try to run “Excel” or “Powerpoint” etc in PowerShell console they wont work.

13

Everyday i open firefox, Internet Explorer, Ms Word, Ms Excel, Ms PowerPoint from “RUN” box. but today i thought that these application must me run from my powershell console.

The benefit of this is that i don't need to open “RUN” box every time before running any command.

Windows PowerShell Profile

First we need to create a windows powershell profile. It is a simple .ps1 file which reside on your Document folder and it run before opening PowerShell console.

Now open PowerShell Console and in Console type notepad $profile

If you don’t have profile created before it ask you to create a new file. Click on Yes.

2

First i want that whenever I open “PowerShell” console it should run in “D:\PowerShell”, to achieve this we need to use Set-Location cmdlet.

Set-location D:\PowerShell

3

Now save the file and close it. and lets open PowerShell Console again.

Cool!!! now the default path of PowerShell console is set to “D:\PowerShell”

4

Aliases

Our Next Step is to setup alias. to achieve this we are using  Set-Alias .

The Syntax to setup alias is Set-Alias <Name> <Path of file >

We are setting up alias for Word,Excel,Powerpnt,Outlook,Firefox,Internet,Explorer,Chrome,

and the command should be : 

Note: I am using Office 2010 and may be your office path may be different.

 

Set-Alias word        'C:\Program Files\Microsoft Office\Office14\WINWORD.EXE'

Set-Alias powerpnt   'C:\Program Files\Microsoft Office\Office14\POWERPNT.EXE'

Set-Alias excel      'C:\Program Files\Microsoft Office\Office14\EXCEL.EXE'

Set-Alias outlook    'C:\Program Files\Microsoft Office\Office14\OUTLOOK.EXE'

Set-Alias firefox    'C:\Program Files\Mozilla Firefox\firefox.exe'

Set-Alias Iexplore   'C:\Program Files\Internet Explorer\iexplore.exe'

Set-Alias Chrome     'C:\Users\aman.dhally\AppData\Local\Google\Chrome\Application\chrome.exe'

now open our powershell profile again and paste the above command.

5

save the file and close it. and also close the PowerShell console and open it again.

Lets test it now

- Excel => Working

6

- Word => Working

7

- PowerPoint => Working

8

- Outlook => Working

9

Our all Ms Office applications are working .. lets test browsers now.

- Chrome => Working

10

- Firefox => Working

11

- Internet Explorer => Working

12

All is working .. u can add more alias if you want.

Thanks

Aman Dhally

No comments:

Post a Comment