Wednesday, July 25, 2012

Powershell & VMware: "Stopping" running Virtual Machines on VMware server using PowerCLI.



The one of the main task as a administrator we do is shutting down and powering on the machines :) . Let see how we can stop/shutdown virtual machines using PowerCLI.

Let's Start.

Connected to your VMware VSphere Server first using PowerCLI. ( )

use Get-VM cmdlet to list all Virtual Machine

25-07-2012 11-40-52

I want to stop/shutdown the virtual machine whose name is "Mrtg-Linux" and you can see the current state of the Virtual machine is "PoweredOn"

we can use Stop-VM cmdlet to stop  virtual machines.  in -VM provide the name of the Virtual machine and it ask you for confirmation type Y and press enter.

Stop-VM -VM Mrtg-Linux

Once you run this cmdlet

25-07-2012 11-59-50

and In case you face RED RED error and not able to STOP Virtual machine :) then use -KiLL Parameter

25-07-2012 12-30-54

Stop-VM -VM Mrtg-Linux  -kill

25-07-2012 12-33-34

Ok, and ok i know , i know you want to suppress the Confirmation isnt ? GEEK

to suppress the confirmation dialogue use -Confirm:$false

Stop-VM -VM Mrtg-Linux  -kill -Confirm:$false

25-07-2012 12-37-06

All Done, Happy :) ?

Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin


Monday, July 23, 2012

Reset "Internet Explorer" Settings to default using PowerShell script.


Few days back we deployed an internal software, that software is Web based application, and users just need to open it on their browsers and start working on them.

Few of the users facing some problem and when we talked to our software development team they told us that they all need to reset their internet explorer settings to default.

Resetting "Internet Explorer" setting to default is an easy job, but when you need to do it on 20+ computers , that became hard.

First i thought to write a "How To" to the users but you know users always thinks they are clever and they don't follow everything which we mentioned in the "HOW TO" documents.

then i thought to automate it using the powershell script. The script is one-liner but i added few logic in to it.
You can include this script in any Desktop management script or so.

Download the script form this link :

Few Screenshots of the script.

If the script found that IE window is open. it throw an error.

23-07-2012 16-10-52

23-07-2012 15-31-17

23-07-2012 15-39-12

Download the script form this link  : 

Thanks for reading.

Aman Dhally
Buy-More-Twitter-Followers 4fb29548b6adc linkedin

Thursday, July 19, 2012

Our Group is a part of "O'Reilly User Group Program" now...


Hi Guys,

Our group is now the part of "O'Reilly User Group Program".

Thanks "O'Reilly  to approve our membership, and thanks for your supports to the community groups like us.

19-07-2012 11-30-50


Aman Dhally

Wednesday, July 18, 2012

Powershell and VMware: "Get the list of all Virtual machines on VMware VSphere Server using PowerCLI.



In my first post about "Getting Started with VMware Vshpere PowerCLI" i already showed how to connect with VMware server.

Our today's task is simple. you get the list of all Virtual machines, and then we search for all "Powered ON" machines and after that all "Power off" machines.

Nothing complicated here. this is just a simple task and again the basic usage of Powershell is applies here. and we have some good "best friend " cmdlets those always with us. these cmdlets are "where-Object", "Select-Object".

Let's Start

Connect to your VMware server first using Connect-VIServer cmdlet. Once you successfully connected.

Run the Get-VM cmdlet.

That will show you the list of all Virtual machines including their "Power State"

18-07-2012 13-01-59 

If you want to see all the properties of Virtual Machines, run the below cmdlet.

Get-VM | Format-List *

Now you can see that we have detailed information about virtual machines.

18-07-2012 13-06-21 

And in case you want to know about a single Virtual Machine , use Get-Vm  and -Name of the machine and then Piped it to fl *

Get-Vm -Name "Dummy-Windows7" | fl * 

18-07-2012 13-18-05 

As i mentioned in the starting that our original target is to find the list of all Up and Running Virtual machines. To achieve that we can use Where-Object and show that Virtual machines whose status is equal to "Powered ON".

Get-vm | where { $_.PowerState -eq "PoweredOn"}

18-07-2012 13-20-08 

Finally i got he list of all "Power ON " server and  i am happy now :)


Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

Monday, July 16, 2012

Powershell & VMware: Getting started with VMware vSphere™ PowerCLI.



Sometime when i meet with IT Administrator who are handling lots of server in their environment, and I asked them that if they know PowerShell., and the answer is "We DONT", because we mainly works on "VMware", "Symantec" and we don't think so that Powershell helps us.

That statement was right few year ago, but now every major Software companies tried to make their Software products "PowerShell" enable.

One the major company is "VMware", they make their software products Powershell enable and they developed "PowerCLI" to manage one of their famous product  "VMWARE VSphere" .

These days most of the companies using "VMware Vsphere", to virtualized their servers.

If you have  VMWARE virtualized environment in you environment, you can manage them using "PowerCLI"

"Getting Started"

Step:1 "Download the setup file from VMware website"

To manage your VSphere server with powershell, we need to download and install "PowerCLI" form VMware website.

Step:2 "Install the downloaded "PowerCLI" software."

Once you download the  setup file "VMware-PowerCLI-5.0.1-581491.exe", run it.

16-07-2012 16-41-51

setup launched and it is extracting files.


Now it ask you, that it is going to download some extra {VMware VIX} files from the Internet., Click on "OK"


Installing "VMware VIX"


Once it finished Installing "Vmware VIX", after that Setup Window comes. Click on "Next"


Patent Windows ,,, Click on "Next"


Accept -- "Term and Conditions" :)


Now choose which product do you want  to install and where you want to install. for me, i am going to use only "vSphere PowerCLI" , and i prefer default location of installations. Click on "Next"


here comes our favourite button "INSTALL" , click on it .


One it done installing, an Installation completed windows will come and click on "FINISH"


Step:3 "Use it"

To open the "PowerCLI" interface, either you can click on it's shortcut on your desktop 16-07-2012 17-05-11  or from All Programs > VMware > "Vmware vShpere PowerCLI "16-07-2012 17-04-35


Open Console , and it will show you how to connect the the VMware Server.

16-07-2012 17-15-10

To connect with the VMware Server, use the Connect-VIServer cmdlet,  and then type Server address and username and password

Connect-VIServer -Server -User amanDh -Password KiddinGmE

Once you connect with the VMware Server, you may see some Certificate related error, that is may be you are using default certificate .

Once you connected with VMWARE Server using PowerCLI , run the Get-VM cmdlet and that will list of all Virtual Machines on VMware Server, including their status.

16-07-2012 17-09-56

That's all , more to come soon.

Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin


Friday, July 6, 2012

Test Connectivity of Multiple Server and then do "Trace Route" on failed servers using powershell script.


Yesterday one of our "New Delhi PowerShell User Group" member was trying to do the following.

Ping a list of Internet and External Server, and then do the "Trace Route" on the failed ones.  He was facing a problem using "foreach" cmdlets.

to help him i tried to write a script for him and he liked it .. So i think that i should share this script with everyone so that everyone else can be benefitted.

The Script is very easy, you can download the script form here:

Download Link :

This script  doing  Test-Connection to the all Computers in $servers and if test failes then it does 
trace route to that Server. 

Screenshot of the Script.

06-07-2012 12-05-56

Download Link :

Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers  4fb29548b6adc


Thursday, July 5, 2012

Powershell script to take backups on USB Drive.



For one of my friend i was working on a backup Script. He want to take his backup to a USB Drive.

First time i thought that it is going to be easy , but found some glitches but fixed them later using "BING" :o) .

Download the Script from this link :

This script is simple.

  1. Check for any USB DISK attached { for now it works only with one USB attached"
  2. If the USB disk in attached,after that it calculated the total amount of data in the folder specified
    1. If the total size of data is Greater Then Free Disk space, it gives you an error
    2. If we have more then free space of total amount of data , then it create a folders in USB Drive named as
      1. backup_DATE
    3. Once data is copied successfully , it open backup Folder

By default it backup only

  1. C:\Users\URSERNAME\Desktop
  2. C:\Users\URSERNAME\Documents
  3. C:\Users\URSERNAME\Music
  4. C:\Users\URSERNAME\Pictures
  5. C:\Users\URSERNAME\Downloads
  6. C:\Users\URSERNAME\Favourites

and i am using Robocopy.exe to take backup.

and i tested this script on windows7 OS with One USB Drive attached and it works for me .

Few Screenshots

05-07-2012 11-59-35

05-07-2012 13-02-06

04-07-2012 15-44-50


Download the Script from this link : 


Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers  4fb29548b6adc


Wednesday, July 4, 2012

Powershell and office 365 : "Getting Started with Office 365 and PowerShell"



These days every one knows about  "Microsoft Office 365" , It's cool , economical and reliable, and i hope sooner or later every SMBs,MNC will migrate to "Office 365".  Once everyone moved to "office 365" then i am sure every administrator missing , messing up with the servers. ;o)


Today i planned to get started with Powershell and "Office 365", i want to know how it works and how to configure Powershell to works with "Office 365", I was thinking that it could be hard , but somehow i am pretty amazed that this is quite simple and pretty well explained on "Microsoft office 365" website.

Here is link for that site. 

The Process is Simple

  • Step : 1
    • Download and Install "Microsoft Online Services Sign-in Assistant"
  • Step : 2
    • Download and install "Microsoft Online Services Module for windows Powershell"

All Done .. {Installation wise }

  • Step : 3
    • Start Using it Geek...

Now there are two ways to access these Module.

  • Way : 1
    • When you finished installing "Microsoft Online Services Module for windows Powershell", The installer adds the program to your Start menu and a shortcut to your desktop. Just click on the below ICON and that open a powershell with "Msonline" office 365 module loaded.

              04-07-2012 19-05-51

  • Way : 2
    • You favourite Geeky way.
      • Open PowerShell Console
      • and type our favourite cmdlet  Import-Module Msonline

        04-07-2012 19-08-02

Which ever the way used to open "Powershell Console" we need to require to connect to "MSOnline" cloud service.

let have a look which cmdlets its having.

Get-Command -Module Msonline

04-07-2012 19-15-30

and we are interested in "Connect-MsolService"

Ok, its time to connect to the Cloud.

in console type "Connect-MsolService" cmdlet and it open a Credential window , type your admin Username {}  and password in the credential windows and click on "OK".

04-07-2012 19-25-39

if you see any RED RED thing that means your are providing wrong username and password.

and is you got nothing and you came back on the shell that means everything is good.

04-07-2012 19-26-13

Now it's time to test it.

ok. let run this cmdlet "Get-MsolCompanyInformation" and see if we got something.

Ok i got the correct data....Hurray !!!!!!!!

04-07-2012 19-32-24 

Thanks for reading.


Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc