Showing posts with label Powershell and Vmware. Show all posts
Showing posts with label Powershell and Vmware. Show all posts

Wednesday, October 9, 2013

Enable useSSLtrasport in VMware Mirage using Powershell.

 

mirage

As i always says, Powershell is a Sanjivini  for system administrators, You are use Powershell to do anything you like to do, and it is bless when it comes to create a fix, patch, automate some tasks.

Do you ever used VMware Mirage? If not ? try it, it is a cool applications. We are using VMware mirage in our environment.

Today , we did some changes on our VMware Mirage server and we changes the server’s connection mode to basic to SSL.

No we need to change some settings on the Mirage clients, we have approx 500 Mirage client installed.

Then i tried to find the solution first on how to change the Mirage Client’s connection mode to SSL and I have found the solution here :  https://communities.vmware.com/message/2297120

The Solution is “Edit the Wanova.Desktop.service.exe.config file and modify the "Key"  "useSslTransport" to true and then restart the Wanova Mirage service

And when i was reading about the solution , few things start coming in my mind:

  1. Stop “Wanova Mirage server”  service | okey, i can use Stop-Service cmdlet.
  2. modify Wanova.Desktop.service.exe.config  file | XML can be done easily.
  3. Start “Wanova Mirage server”  service | Use Start-Service cmdlet.

The last thing which come in my mind , i can script it, i can script it.

And here is complete and i added comments so that it would be easily understandable.

Download link : http://gallery.technet.microsoft.com/Enable-useSSLtrasport-in-cb341ad5

# Notes :-

#             --->   Please run this script as "Administrator"

#        Tested on : 64 Bit Client of Mirage.

#                  : 64 Bit Windows 7 Professional. 

 

# testing for file first

 

$testWanovaFile = Test-Path 'C:\Program Files\Wanova\Mirage Service\Wanova.Desktop.Service.exe.config'

 

#

if ( $testWanovaFile -eq $true )

 

       {

 

              # Mapping confifuration file as XML

              [xml] $wanovaXmlFile =  get-content 'C:\Program Files\Wanova\Mirage Service\Wanova.Desktop.Service.exe.config'

 

              # Finding the useSSLTransport Attribute

              $useSslKey = $wanovaXmlFile.configuration.appSettings.add | where { $_.Key -match "useSslTransport" }

 

              # Processing

 

              # If the UseSSL is not set to true

              if ( $useSslKey.value  -ne $true )

                     {

                          

                           # Stopping Wanova Mirage Desktop Service

                           Write-Warning "Stopping Wanova Desktop Service."

                      Stop-Service "Wanova Mirage Desktop Service" -Force

                     

                           # Setting SSLkey value to True

                           Write-Warning "Setting useSslTransport value to true"

                           $useSslKey.value = "true"

                     

                           # Saving the file with changes

                           Write-Warning "Saving the Configuration file."

                      $wanovaXmlFile.Save('C:\Program Files\Wanova\Mirage Service\Wanova.Desktop.Service.exe.config')

                     

                           # Staring the Service again

                           Write-Host "Starting Wanova Desktop Service." -ForegroundColor 'Green'

                           Start-Service "Wanova Mirage Desktop Service"

 

                     }

 

              else {

 

                           Write-Host "Value already set to true " -ForegroundColor 'Green'

 

                     }

      

       }

 

else

       {

      

       Write-Warning "Mirage Doesn't seem installed on this $env:COMPUTERNAME laptop"

      

       }     

 

###---- end of the script

Moral of the story: if you know PowerShell, you can fix every ( except broken heart ) thing.

I tested this on : Windows 7 64 Bit and with Mirage 64 Bit Client.

Download link : http://gallery.technet.microsoft.com/Enable-useSSLtrasport-in-cb341ad5

Thanks for your time.

Thanks

Aman Dhally

clip_image001 clip_image002 clip_image003 clip_image005  clip_image007

Wednesday, July 25, 2012

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

 

Hi,

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. ( http://newdelhipowershellusergroup.blogspot.in/2012/07/powershell-vmware-getting-started-with.html )

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.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

00403skh

Wednesday, July 18, 2012

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

 

HI,

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.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

Monday, July 16, 2012

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

 

Hi,

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.

Capture

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

Capture-2

Installing "VMware VIX"

Capture-3

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

Capture-4

Patent Windows ,,, Click on "Next"

Capture-5

Accept -- "Term and Conditions" :)

Capture-6

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"

Capture-7

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

Capture-8

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

Capture-9

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 192.168.1.200 -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.

Thanks!

Aman Dhally

Buy-More-Twitter-Followers 4fb29548b6adc  linkedin

004kc401