Monday, January 7, 2013

Uninstalling Windows Features using Powershell V3

Hi,

In my previous post i posted about on “How to install windows features” using powershell v3. Today i am about to post about how to un-install them.

The un-installation of windows features using powershell quite easy as installing them.

Let’s start.

Lets check if we still have “XPS-Viewer” installed as feature on our windows 8 server machine.,

Get-WindowsFeature -Name "XPS-Viewer"

So XPS-Viewer is still installed.

07-01-2013 15-53-30

Now lets uninstall it using the cmdlet “Uninstall-WindowsFeature”

run  Uninstall-WindowsFeature” with -Name parameter and provide the name of the windows feature which you want to uninstall.

Uninstall-WindowsFeature -Name "XPS-Viewer"

 

07-01-2013 15-54-44

Now it start removing “XPC-Viewer”

07-01-2013 15-54-57

one all done this will show the success windows. you can see in the command line output the value of Success is True.

07-01-2013 15-56-13

to cross check the un-installation lets run  Get-WindowsFeature -Name "XPS-Viewer" again.

and the you can see there is no [x] boxed in the front of the “XPS Viewer” and the install state is available.

07-01-2013 15-56-31

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Thursday, January 3, 2013

Installing Windows Features using Powershell V3

Hi,

While working on Powershell V3 i have realised that Scripting are going to be easy. Scripters just need to add bunch of cmdlets to the scripts and done. In Powershell V3 Microsoft had make CMDLET for almost everything or for every task.

The main task which SYSADMINS do this installing extra windows features in to the server or to the desktops. These features may be setup a server a DHCP,DNS,FAX or a simple feature like installing or enabling XPS viewer.

I am using a fresh installation of “Windows Server 2012 Standard Edition with GUI” and i do often view and read “XPS formatted  Documents”. BY Default the XPS file viewer is not installed on “Windows server 2012”. 

So i think why not install it using the Powershell V3 cmdlet. 

To get the list of all available/installed windows feature we can use the cmdlet

“Get-WindowsFeature”

The features those have [x] in the from of them means that they are installed.  When you query any single feature using  “Get-WindowsFeature” cmdlet then provide the NAME of the feature not the “Display Name”

03-01-2013 12-07-44

Let’s see if the “XPS Viewer” is installed or not.

Get-WindowsFeature -Name “XPS-Viewer”

You can see that XPS-Viewer is available but it is not installed.
03-01-2013 12-08-46

To install Windows features we have to use the cmdlet “Install-WindowsFeature

Let’ install XPS-Viewer, run the below command line.

Install-WindowsFeature -Name “XPS-Viewer”

You can see it start Installing.

03-01-2013 12-10-05

When installation is done it shows the below screen, that installation is “Successful” and Reboot is “Not required” .

03-01-2013 12-11-47
let’s query the “XPS-Viewer” again using Get-WindowsFeature

Get-WindowsFeature -Name “XPS-Viewer”

and now we can see a [x] in the front of Display Name and the Install State in “Installed”

03-01-2013 12-12-12

and we can see XPS Viewer on our Desktop too.

03-01-2013 12-13-25

Nice Smile isn’t.

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Wednesday, January 2, 2013

Setting Display Resolution using Powershell V3

Hi,

First of all I want to congratulate all new MVPs and want to thanks them their contribution to the community . I also want to congratulate “Sarabpreet Singh Anand” who became a “SQL” MVP this year for first time, brother we do proud on you.

Today “New Delhi” is feeling like a big refrigerator the temperature is almost 8 Degree Celcius and a heavy fog is every where.

02-01-2013 13-27-24

anyway…..

I am in love with Powershell V3, I think in this new version we have CMDLET for each and every task. Today i am going to show you a very simple task , the task in setting Display Resolution on Desktop using Powershell V3 Cmdlets.

Open PowerShell Console { You know hot to do this ;o) }

02-01-2013 13-06-19

To know you current display resolution use this cmdlet “Get-DisplayResolution”.

02-01-2013 13-07-04

So my current display resolution is “1920x1080” . Now lets change the resolution using the another cmdlet “Set-DisplayResolution

type and run “Set-DisplayResolution

it ask you to define the width of resolution in pixels : i typed 800

02-01-2013 13-07-50

after define the width in Pixels we have to provide the height pixel size of 600

02-01-2013 13-08-07

02-01-2013 13-10-01

Hit enter .

Now a new windows opens and asking for the confirmation that if we want to apply the display setting or not, if you enter “Y” new display resolution will be applied, if you enter “N” then you are back to the original display resolution nothing will be changes and if you type or enter nothing you will be back to original display settings.

In my case i type and enter “Y”

02-01-2013 13-08-32

and my display resolution is changed.

02-01-2013 13-09-36

Smile cool…..

but wait… we can make the above in to  one-liner so that we can  use this on our scripts so that it won’t ask for any confirmation window.

Set-DisplayResolution -Width 800 -Height 600 -Force

02-01-2013 13-38-52

 

Thanks

Aman Dhally

 

clip_image001 clip_image002 clip_image003 clip_image005 clip_image007

Tuesday, January 1, 2013

Managing Control Panel Items using Powershell v3.

Hi,

First of all “Happy New Year” everyone. New year is started and this is a good time to start learning  new things. I think the best things to learn for me is a “Powershell Version 3”.

Yesterday i installed a “Windows Server 2012 Standard Edition with GUI” in a virtual machine. As i am planning to cover new cmdlets on “Powershell Version"3” and then we can end up by writing scripts.

01-01-2013 11-21-04 “I like  it”

The interface of “Windows Server 2012 Standard Edition”  is pretty neat and clean. I like GUI interface of the server 2012 to be it feel very sober and attractive”

My current “Windows 2012 Server” machine is a standalone and not added to Active Directory yet.

To check the version of Powershell on “Windows 2012 server” Click on Powershell icon to open powershell console and type the cmdlet “$PSVersionTable

$PSVersionTable

You can see in below image that the Powershell version 3.0 is installed.


01-01-2013 11-24-01


In few of my old scripts when i want to open any control panel item i used to call the .CPL extensions. for example if i want to open “Network Connection” then i used to call “NCPA.cpl” in my script.


But in Powershell V3 they actually created a 2 new cmdlets to open control panel items and believe me they are going to be very handy.


The first cmdlet is “Get-ControlPanelItem

Get-ControlPanelItem


when you run “Get-ControlPanelItem” in Powershell console this gives  list of Names of  all items those are in control panel.


01-01-2013 11-25-50


Now we know how many and which items we have in control panel. To open those items we need second cmdlet which “Show-ControlPanelItem

Show-ControlPanelItem

lets open few control panel items.

Show-ControlPanelItem -Name "Folder Options"

01-01-2013 11-29-31


and lets open Display Properties.

Show-ControlPanelItem -Name "Display"

01-01-2013 11-27-53


Cool isn't?


Thanks


Aman Dhally


join aman on facebook Join aman on Linkedin follow aman on Twitter blogger-icon

Monday, December 31, 2012

Google Paid Tribute to the DELHI RAPE victim….thanks a lot GOOGLE.

Hi,

Today when i open Google.com today i saw a candle in the bottom of the Google search box.

and when i hover my mouse over it .. it said…”In the Memory of Delhi BraveHeart”

thanks Google.com to pay the tribute to the DELHI Rape Victim.

31-12-2012 12-18-39

Thanks

Aman

Thursday, December 13, 2012

Loops: Do While in PowerShell.

Hi,

As i mentioned earlier that i am very busy in the month on October and November that’s why i was not able to write any article on Powershell, but i am little free now and will try to publish articles whenever i get free time.

Today one of my fried call me and he was having some problem understanding DO WHILE loop, I explained the working of the loop over the phone to him and i thought it is worth writing a post on it.

the working of do while loop is simple.

do { code block }
while ( condition )

for example.

do { Dancing }
while ( music is playing )

You got an idea ? isnt ?

That means do  something till while condition is true. Like in above not-IT example do the Dancing till the Music is Playing Smile 

In IT world we can use it in a various ways . Lets try this ….

  • Open Notepad

13-12-2012 15-18-38

and type the below in the powershell console.

  • Do { Ping google.com } while ( Get-Process Notepad | Select-Object  -Property Responding )

what is happening?

Powershell Will Ping Google.Com till the notepad windows is open.

You can notice our Notepad windows is open and we have constantly pinging Google.com and after 4 Pings it starts again. 

13-12-2012 15-23-46

I hope it is little bit clear now Smile 

Thanks

Aman Dhally

join aman on facebook Join aman on Linkedin follow aman on Twitter