vmware

Edit VMs using PowerShell and PowerCLI

Posted by robd on January 28, 2019
powershell, vmware / No Comments

To resize VMs using PowerShell with PowerCLI from a csv list, first install the software:

 

https://my.vmware.com/web/vmware/details?downloadGroup=PCLI650R1&productId=614

 

Then create a list of servers to resize and save it as a CSV file in C:\temp\VMs.csv:

 

 

Save the below as Something.PS1 and run from PowerCLI

Note: Change VCENTRE to your vCentre, this script will TURN THE SERVER OFF then give each VM two CPUs, one socket and 5GBs of RAM.

 

 

Tags: , ,

Orphaned VM in VMWare 6.5

Posted by robd on January 24, 2019
vmware / No Comments

Had an issue where I’d deleted a VMDK from a LUN and was left with orphaned VM in vSphere, no problem I thought…right click and remove from inventory.  The problem is, all options were greyed out:

So what to do?

Enable SSH on the host.

Connect wit Putty and run:

List all registered VMs

Then to unregistered:

 

Tags: , , ,

Citrix and vCentre

Posted by robd on September 05, 2018
Citrix, vmware / No Comments

Annoyingly our venctre broke recently meaning our Citrix clients wouldnt boot which had the knock on affect users couldnt logon.

To easily check the connection status of citrix and vcentre, you can run the following PowerShell command on a Citrix delivery server (or whereever Citrix PS is installed):

This is what it looks like when its broken, notice the State:

Fixing vcentre and rebooting the citrix server it then looks like this:

 

Tags: , , ,

Ratio of Physical CPUs to Virtual CPUs in VMware

Posted by robd on August 06, 2018
powershell, vmware / 1 Comment

My colleague Welsh Dai made this sweet bit of PowerShell to see the ratio of physical CPUs to Virtual CPUs:

 

Here’s a picture

Tags: , , ,

How to setup Cisco port mirroring to a VM

Posted by robd on December 06, 2017
Networking, vmware / 1 Comment

Today we needed to mirror a port on a Cisco switch in a country far far away meaning we couldn’t just wander down with a laptop.

So to get around this we decided to mirror the port to a VM that’s on site, here’s how we did it:

There’s two switches between the VM and the port we want to mirror so first we have to setup the port mirroring on every switch using RSPAN (Remote Switched Port Analyser) and a new vlan.

Add an RSPAN vlan to both the switch with the port to mirror, and to the switch that has the packet capture device on.

Then make sure that RSPAN vlan is trunked between the 2 switches and on the VMWARE interface.

Assuming the following;

You use vlan 999 for the RSPAN vlan.

The port you want to mirror is on switch 1 port g1/0/2.

You want to send the mirrored traffic to switch 2 port 1/0/23 (the port that connects to VMWARE).

You are going to use monitor session 1 on both switches. (this can be any session number between 1-66, and can be different on each switch).

On Switch 1 (mirror port 2 and punt out the traffic to 9999)

On Switch 2 (suck in all traffic from 9999 and punt it to port 23)

You can see that the monitoring is set up with;

Network Diagram:

Next, we need to do the VMware side of things:

 

Setup a new port group on a vswitch:

Although we chose vlan 9999 when its pushed to the new port it will not be tagged so choose all:

Next edit the port group and allow Promiscuous mode, this will allow traffic not destined for the VMs MACs (normal behaviour, any traffic not destined to a VM MAC will be dropped):

Add a NIC to your VM using the port group:

Don’t worry about a IP etc:

Fire up Wireshark:

Look at all these glorious packets:

 

 

Tags: , , , ,

Failed to connect virtual device ethernet0

Posted by robd on May 04, 2017
vmware, vSphere / 2 Comments

Today I noticed a NIC was down on a VM, had a look and noticed it was disconnected:

 

 So I ticked the box and clicked ok and got the follow error:

Weird, so I thought I’d check the port ID for that virtual switch:

Looks like something else is on that port id:

Scroll down the list to find a free port ID and then go back to the VM and change the port ID and boom you should be able to connect.

Tags: , ,

VMware – Increase disk past 2TB

Posted by robd on February 16, 2017
vmware, vSphere / 1 Comment

Tried to increase a disk past 2TB today on a VM on a ESXi 6.0.0 (via vSphere) host but kept getting this:

Well it was driving me nuts until I turned the VM off and tried again…..it worked.

Tags: , ,

VDI Images with VMware Tools SVGA driver – Warning!

Posted by robd on April 16, 2016
Citrix, vmware / No Comments

If you are building a Client/Server that is going to be used in a VDI environment don’t install the VMware SVGA WDDM driver as part of the VMware tools install.

 

It can cause issues like Black screens, Users not connecting etc and the first step Citrix get you to perform is to remove them, with XenDesktop this is fairly easy but time consuming with VDI-in-a-Box you can’t…

 

For XenDesktop, If you have installed them you can us the follow these steps to remove the driver:

  • Remove VDA agent(s)
  • Reboot
  • Remove VMware Tools
  • Reboot
  • Install VMware tools (Custom install without SVGA driver)
  • Reboot
  • Install VDA agent(s)
  • Reboot
  • Update the Catalogue

 

For VDI-in-a-Box, If you have installed them you can us the follow these steps to remove the driver:

  • Start again with new image.

 

Notes:

If you already have it installed and it’s not causing any issues you can leave it as is.

If you don’t remove the VDA agent before Uninstall/reinstall VMware tools, the guest will break.

VDI-in-a-Box installs the VDA agents when you import the image, you can’t get them any other way. (confirmed by Citrix Support)

 

Both these links mention VMware 4.1 U1 but Citrix have confirmed it is still affects later versions.

http://support.citrix.com/article/CTX123952

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1011709

Tags: , ,

VMware vCenter Server 5.5 Database is Full

Posted by robd on May 27, 2015
SQL, vmware, vSphere / 12 Comments

So today a vCenter Server Service wouldnt start Java was going mental and we kept seeing event IDs 1105 and 1827.  So what this means is our SQL Express instance reached the limits the size of databases i.e. 10GB on SQL Express 2008 R2.

Error_event1

Error_event

You can confirm this by looking at the size of the VIM_VCDB.MDF file in c:\program files\Microsoft SQL Server\MSSQL10_50.VIM_SQLEXP\MSSQL\Data, if its 10GB then your in trouble.

So the first thing to do is fire up Microsoft SQL Server Management studio and run a standard report against the VIM_VCDB by right clicking the DB > Reports > Standard Reports > Disk Usage by Top Tables:

Error1

From here you can see which tables are causing the problems, in my case its dbo.VPX_EVENT_ARG which is massive.

So from here you need to purge the above table:

  1. From Microsoft SQL Server Management studio
  2. Click databases to expand and select VIM_VCDB > Tables.
  3. Right-click the dbo.VPX_PARAMETER table and select Open.Note

    : If you are using SQL Server 2008, right-click the dbo.VPX_PARAMETER table and click Edit Top 200 Rows.
    Error3

  4. Modify event.maxAge to 30, and modify the event.maxAgeEnabled value to true.
  5. Modify task.maxAge to 30, and modify the task.maxAgeEnabled value to true.

Error5.5

Error5

  1. Next run a built-in stored procedure to shink the logs:
  2. Go to VIM_VCDB > Programmability > Stored Procedures.

Error6

3. Right-click dbo.cleanup_events_tasks_proc and select Execute Stored Procedure. This purges the data from the vpx_event, vpx_event_arg, and vpx_task tables based on the date specified for maxAge.

Now the records have been purged you need to shrink the DB:

  1. As before connect using SQL Server Management Studio.

ExecuteScript

2. Right click on the VIM_VCDB database and New Query, when the white SQLQuery box opens type the below and click ! Execute

3. It’ll start running and when its finished you should see:

ExecuteScript2

Check the size of the file again and you should be able to start the services.

 

Tags: , , , ,

How to add a vlan on VMWare (in my case to use with Citrix):

Posted by robd on December 19, 2014
Citrix, vmware / No Comments

My current Citrix XenDesktop environment has out grown its original IP scope and I wanted to move it to a new dedicated VLAN with scope to grow even more. Below is brief guide in the steps taken.
Stage 1 – Creating the DHCP Scope
•    Logged onto your DC and open DHCP, drill down on IPv4, right click and select New Scope.
1
•    Give the Scope a name “Citrix Guest VM’s” and description.
2
•    Enter the IP range you would like addresses DHCP to give out (it always a could idea to leave some spare at the end for static IPs)
3
•    Add any exclusions you wish
•    Lease duration I left default of 8 days
•    Proceed to “Yes, I want to configure these options now”
•    Default Gateway is the IP address you will assign your Core Switch / Router in your network when creating the VLAN in the next stage. 192.168.25.254
4
•    Next select/enter your DNS servers
•    WINS Server if any
•    Active Scope – Select “Yes, I want to activate this scope now”
•    Finish

Stage 2 – Creating a new VLAN
In my environment we use HP Procurve Switches, so the following config are HP cmds.
•    Log on to your Core Switch / Router and use the follow config.

Config Break down
1 Enter configuration mode
2. Created VLAN 3025
3. Naming the VLAN
4. Creating the default gateway ip address for the VLAN
5 & 6. DHCP Servers
7. Tagging – You need to tagged any ports you would like to traffic to run through, see below.
8. Exit VLAN config
9. Save
Tagging
You need to proceed to create the VLAN and tagged the ports through your network you intend the traffic to run through. In my situation I stated by creating the VLAN on both core switches and had to tagged ports through to my server rack switches and then uplinks to my ESXi Hosts.
5
Testing
Once all the tagging was done I wanted to do some testing before I moved onto VMware VCentre.
From my core switch I untagged a port on VLAN 3025 (untagged assigns an the device connected to that port the IP in that specified VLAN). Plugged in my laptop and check the address assigned. It was a success I received a address from the 192.168.25.0/24 range, I could double check this by looking at the address leased on the DHCP server.
If you was not successful at this point please go back and review as the stage will not work

Stage 3 – VMware VCentre
•    Adding the Virtual Machine Port Group  (VLAN) onto a vSwitch (virtual switch) in VMware
Open up VMware Client, navigate to the your Cluster
– Select your host (if you have mulitple you will need to do this to all of them)- Select the Configuration tab
– Select Networking from the left side menu
– Click ” Add Networking at the top”
6
Add Virtual Machine, click next
7
Select the vSwitch you are currently using, for exmaple mine is “vSwitch0″
8
Give the Port Group a name, i suggest using the same as the VLAN on the physical switches.
Enter the VLAN ID – 3025
9
View Summery and Click Finish.

You have now added a new VLAN (port Group) into VMware ESXi and can now been given to VMs, in our case our VDI solution.
To check this, edit any VM which is sitting on any of the host you have just configured, select the NIC and you should be able to drop now the menu to select “Citrix Guest VMs” network.

10

Now this is great, you are able to change the VM to a new network…… but I have 200 VMs!
It is not feasible to sit there and manually reconfigure and 200 machines and reboot them, plus you would be taking down your environment for a long time.
Stage 4 – VMware vSphere PowerCLI
How to automate the NIC change for multiple VMs
1. Download VMware vSphere PowerCLI

2. Install and connect to you Vcentre Server

11
Once Successfully connected you can start issuing powershell commands. Use get-vicommand to see a list of all PowerCLI commands.
To complete this task we just need:
– The list of machines from the XenDesktop machine catalog.
Commands used:

Scenario:
– Machine Catalog Name: “Admin Desktop”
– Machine names: “monvdiad##”
-Current Network: “Server Network”
-New Network: “Citrix Guest VMs”
** Make sure the account you are using have elevated rights in vSphere
PowerCLI Commands to change VLAN
To obtain a list of all XenDekstop VMs in that catalog issue following command use the wildcard display all machines that start with “MONVDIAD*”

If the above query returns the list of the correct VM’s then proceed to change the NIC with the code below.

Press “A” to accept the changes and watch the magic begin.
Once complete I personally would give the affected VM’s a reboot with the following cmd

Again press “A” to accept
You can check your work by manually check a VM or issue the following cmd which will query and display any VM using “Citrix Guest VMs” Port Group as a selected network.

Jobs a good un!

Tags: , , , , ,

Copy Protected by Chetan's WP-Copyprotect.