Disable Solarwinds Alerting With PowerShell

A customer is currently using solarwinds to monitor there virtual infastructure, when they do there patching they need to login to the solarwinds console, and manually step though each of the virtual machines/objects they are going to patch and put them into maintenance mode so the on-call guy doesnt get flooded with alerts.

To help matters and save a bit of time i used the below piece of powershell scripting to take away that manual task and only require a text file with a list of the servers to be modified (this is assuming you have the swisPowershell installed:

1
Install-Module -Name SwisPowerShell

swmaintme.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Check if the powershell module that is used is actually loaded and if not load it up
Import-Module SwisPowerShell  
# Hours passed when running script e.g (./swmaintme.ps1 12) will set maintance for 12 hours
$hours=$args[0]
# Where is the server file located (file is a text file with just server names not FQDN)
$serverlist = Get-Content -Path "'path to imput text file'\unmanageme.txt"
# What is the solarwinds server (can only be ran from here as port 17777 is not open remotely :( )  
$strsolarWindServer="Solarwinds Server name Here"  
# Lets connected to the server listed above nice and trusted
$swis = Connect-Swis -Hostname $strsolarWindServer -Trusted
# For each time you look at a line in the text file above do this >>>>>
foreach($server in $serverlist){  
 
    $strQuery = "SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'"  
    $uris = Get-SwisData $swis $strQuery
#   Important line where we actually set the server to unmanaged and status 9 and then set it to maintance from when script was run to the hours we said at start  
    $uris | ForEach-Object { Set-SwisObject $swis $_ @{Status=9;Unmanaged=$true;UnmanageFrom=[DateTime]::UtcNow;UnmanageUntil=[DateTime]::UtcNow.AddHours($hours)}}  
}

Once you maintenance is finished and i the following script will take the same input file and put them back into monitoring mode, unless of course you wish to wait till your maintenance period you specified in the first script ends.

swunmaintme.ps1

1
2
3
4
5
6
7
8
9
10
Import-Module SwisPowerShell  
$serverlist = Get-Content -Path "'path to imput text file'"\unmanageme.txt"
$strsolarWindServer="
Solarwinds Server name Here"  
$swis = Connect-Swis -Hostname $strsolarWindServer -Trusted

foreach($server in $serverlist){  
    $strQuery = "
SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'"  
    $uris = Get-SwisData $swis $strQuery
    $uris | ForEach-Object { Set-SwisObject $swis $_ @{Status=1;Unmanaged=$false}}  
}

New Release: PowerCLI 11.4.0

New version of  PowerCLI released version 11.4.0

Heres a brief breakdown of the updates included:

PowerCLI 11.4.0 comes with the following updates:

  • Add support for Horizon View 7.9
  • Added new cmdlets to the Storage module
  • Updated Storage module cmdlets
  • Updated HCX module cmdlets

Dont forget its easy to update your powercli version (see below)

1
Update-Module VMware.PowerCLI

And finally heres a link to the vmware article with all the info https://blogs.vmware.com/PowerCLI/2019/08/new-release-powercli-11-4-0.html?src=so_5a314d05e49f5&cid=70134000001SkJn

Horizon Admin Login Issue UAG Deployment

I have been going through the process of replacing the security servers on my homelab over the weekend with Universal Access gateways (UAG). The process has been fine and to be honest very straight forward.

There is no point me going though the install process as Carl Stalhood has a excellent walkthough on his blog https://www.carlstalhood.com/vmware-unified-access-gateway/

One issue that i did have after the installation and configuration of the UAG was access to my Horizon Admin Page /admin and /newadmin after the installation.As i dont access it local from the connection server, what i had forgotten was to do the following:

For each connection server create a text file named locked.properties in “Location Where you have installed Horizon View”\Server\sslgateway\conf

1
2
3
4
5
6
7
8
9
Open or Create a locked.properties file using a plain text editor.
Add this line:

checkOrigin=false

Note: Ensure the locked.properties file is not in .txt extension after saving.
 
Save and close the file.
Restart the VMware Horizon View Connection Server service.

Once this was done i could login to my Horizon Admin page, there is a Vmware KB article at https://kb.vmware.com/s/article/2144768

Installing Ansible/AWX ready for VMware Automation on Unbuntu 8.04LTS

I have just started to look into using Ansible for automating some of the tasks we current use on customer infrastructure, from VM template deployment to the install/configure of bespoke applications within the VM.

For my testlab i though i would install ansible and the relevant VMware required modules like Python SDK for VMware and pyvmomi. I also installed AWX to provide a GUI for the task scheduler and to better understand how Ansible Tower works.

To get started with the installation we deploy a simple unbuntu 8.04LTS server using the default options (The VM specs are 2vcpu 16GB ram and a 120GB VMDK). I then ran through the process below to get ansible/AWX and of course Vmware SDK for Python installed. We have a number or requirements as we are running AWX in a docker (it should be noted that i prefer to put this in /opt but that a personal thing)

1
2
3
4
5
6
7
8
9
10
apt-add-repository --yes --update ppa:ansible/ansible
apt install ansible -y
apt install docker.io
apt install python-pip -y
pip install docker
pip install docker-composer
apt install nodejs npm -y
npm install npm --global
cd /opt
git clone https://github.com/ansible/awx.git

At this stage we can install AWX however if we were to use the default options the postgress data would be placed in /tmp which means it would be reset every reboot and we would loose out current configuration, as shown below I prefer to edit the inventory and put it to /opt/pgdocker. (again this is personal choice and you can put it anywhere you want)

1
2
3
4
5
cd /opt
mkdir pgdocker
cd awx/installer
edit inventory change postgres data files location to /opt/pgdocker
ansible-playbook -i inventory install.yml

You should now be able to visit http:\\(your servername) and login with a username of admin and a password of password

Next we want to install the VMware SDK for python and pyvmomi for ansible.

1
2
3
4
5
6
cd /opt
clone https://github.com/vmware/vsphere-automation-sdk-python.git
cd vsphere-automation-sdk-python
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///opt/vsphere-automation-sdk-python/lib

pip install pyvmomi

Congrats you now have Ansible/AWX/Python all ready for working with Vsphere.

I will be doing an article covering some of the basics of using Ansible and VMware together in another post.

vExpert 2019

For the second year running I have been lucky enough to be awarded the VMware vExpert award. I’m proud of the contributions im able to make to this amazing virtualisation community. The vExpert list is constantly growing, and it’s amazing to continue to be part of this list of experts and community.

vExperts demonstrate significant contributions to the community and a willingness to share their expertise with others.

Export A Running VM From vCloud

Late last year i wrote about identifying chain linked VM’s within the vCloud environment, since then ive had to export a number of virtual machines from vCloud back to native vSphere.

For some of the process we need to use the ManagedBy.PS1 powershell script provided by VMware in this artice (its attached) https://kb.vmware.com/s/article/2032366

The script that i wrote to do this is below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Export VM script for vCloud (required ManagedBy Script from VMware)

# Variables for the vApp Decommission.
$disablespec = New-Object VMware.Vim.VirtualMachineConfigSpec
$disablespec.vAppConfigRemoved = $True

# Text file with list of VM's we want to export from vCloud
$vms = Get-Content "vms.txt"

Foreach ($vm in $vms) {

$vm = "$vm"

Write-Host "Cleaning UUID UP :" $vm
#Remove vCloud UUID settings in vmx configuration
Get-AdvancedSetting -entity "$vm" -Name cloud.uuid|Remove-AdvancedSetting

Write-Host "Unlinking VM from vCloud Management :" $vm
# Unlink managed by
Invoke-Expression -Command '.\ManagedBy.ps1 -Cmd Clear -VMs $vm'

Write-Host "Removing vApp Flag :" $vm
#Remove vApp Flag
$vm = Get-VM $vm | Get-View
$vm.ReconfigVM($disablespec)

}

This successfully cleans up the VM removing the UUID in advanced settings are un-linking it from vcloud, it also changes the VM from a vApp to a standard VM. What you will be left with is the same VM with a (UUID reference number after it). Should you wish to remove this UUID referance number you can do afterwards with the script below, however check your backup technology before hand as it may see the changes as a new system and remove your historical references.

1
2
3
4
5
6
7
8
9
10
11
# Same text file that was used for the vCloud Export
$vms = Get-Content "vms.txt"

Foreach ($vm in $vms) {

    $vm = "$vm"
    Write-Host "Current VM Name :" $vm
    $newvm = $vm.Substring(0, $vm.IndexOf('('))
    Write-Host "New VM Name :" $newvm
    Set-VM -VM $vm -Name $newvm
}

And that should be it.

Horizon Composer Install on Windows 2016 (Rollback Issue)

Interesting one today, installing horizon composer on a windows 2016 virtual machine. All the usual checks done for the ODBC settings etc, however constantly getting a rollback error message. After digging around in the logs i spotted error 1603., which after a quick check though the VMware knowledge base i found the following article https://kb.vmware.com/s/article/58887?lang=en_US Seems its a well know issue with thankfully a quick fix.

Power Down the virtual machine in question

Edit the virtual machine and disable Secure boot

Install Composer

Once installed shut down the virtual machine again

Re-enable secure boot.

 

So far its working for me.

vSphere 6.7 Update 1 Available

You have probably already seen this in the news already but vSphere 6.7 Update 1 has now released to download. Link Is below in case you need it:

vSphere 6.7 Update 1 Download Link

 

Also to get a bit more info on whats under the hood on the updated vSphere web client i would recommend the following:

https://blogs.vmware.com/vsphere/2018/10/fully-featured-vsphere-client-in-vsphere-6-7-update-1.html?src=so_5a314d05e49f5&cid=70134000001SkJn

https://docs.vmware.com/en/VMware-vSphere/6.5/rn/vsphere-client-65-html5-functionality-support.html

 

ISSUES

So far VEEAM is the only thing ive heard so far that has an issue: https://www.veeam.com/kb2784

New Release: PowerCLI 11.0.0

New version of  PowerCLI released version 11

Heres a brief breakdown of the updates included:

  • Added a new Security module
  • Added new cmdlets for Host Profiles
  • Added a new cmdlet to interact with NSX-T in VMware Cloud on AWS
  • Support for vSphere 6.7 Update 1
  • Support for NSX-T 2.3
  • Support for Horizon View 7.6
  • Support for vCloud Director 9.5
  • Multiplatform support for the Cloud module
  • Updated the Get-ErrorReport cmdlet
  • Removed the PCloud module
  • Removed the HA module

Dont forget its easy to update your powercli version (see below)

1
Update-Module VMware.PowerCLI

 

And finally heres a link to the vmware article with all the info

https://blogs.vmware.com/PowerCLI/2018/10/new-release-powercli-11-0-0.html

vCloud Identifying Chain Linked VM’s

Currently working on a project to decommission a very old non updated vcloud infrastructure for a customer who wants to move back to vsphere. They don’t really utilize the full vCloud feature set as it was put in as part of a larger project that never came to fruition.  Part of the first step should be to see what chain linked virtual machines we have, as if not when we attempt to migrate them away we are just going to give ourselves a world of pain. The PowerCLI below should identify all the virtual machines within the VDC’s and how long the chain length is.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if( (Get-Module -Name "VMware.VimAutomation.Cloud" -ErrorAction SilentlyContinue) -eq $null)

{Import-Module VMware.VimAutomation.Cloud}

Connect-CIServer -Server "your vcloud director fqdn" -ErrorAction Stop

$VApps = Get-CIVApp

Foreach($vapp in $VApps){

$vms = $vapp.ExtensionData.children.vm

foreach($vm in $vms){

$CL = $vm.VCloudExtension.any.VirtualDisksMaxChainLength

if($CL -gt 1){

$info = $vm.Name + " chain length=" + $CL

$info}

}}
« Older posts