Category Archives: Uncategorized

How to Install git on Centos 7

I found my self needing git to pull down scripts for ansible. Thus this is how to configure git on Centos 7.

 

  1. # yum install git -y
  2. git --version
  3. You should see a version like this. Install Done!

git version

 

  1. Next lets configure it!
  2. # git config --global user.name "Your Name"
  3. # git config –global user.email “[email protected]
  4.  # git config –list
  5. You should see the following, and we are done!

configgit

  1. Lets create a new location for our git repository
  2. mkdir /git
  3. cd /git
  4. git init
  5. now lets pull down a configure we want to use.
  6. the command git clone (URL) clones a entire repository down to your server or workstation.
  7. Enjoy!

 

Sources.

How To Install Git on CentOS 7 https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7

Using Git with Github. http://blog.scottlowe.org/2015/01/26/using-git-with-github/

A Non-Programmer’s Introduction to Git http://blog.scottlowe.org/2015/01/14/non-programmer-git-intro/

credit to Scott Lowe and Josh Barnett

 

 

 

Roger L

PowerCLI: Get VM disk usage per cluster

powercli

 

 

Today I was asked to gather a list of all VMs within a given cluster and report on their disk usage (all the VMs are thick provisioned) and currently do not have a tool to perform a seemly simple task. After some searching I have found many versions of this script around the internet but none that quite suited me needs. I have modified about 50% of the original script to suit my needs and added these features.

  • Prompts for vCenter hostname or IP
  • Requires user to select a cluster
  • Queries vCenter for list of cluster names (for use above)
  • Limits results to specified cluster
  • Prompts for output filename
  • Default saves to current user’s Documents folder
  • Prints location of filename
  • Auto launches file once complete

I should also mention that I am not a script writer. My abilities exist in finding, understanding (most of the time), and modifying existing Powershell scripts. I will be unable to assist with drastic modifications to any script.

Requirements: VMware PowerCLI, vCenter Credentials with appropriate permissions

How to run: Save below script to .ps1 format and run from PowerCLI. No need to modify anything to make compatible with your environment.

$vCenterName = Read-Host -Prompt ‘Enter vCenter hostname or IP’
Write-Host “Connecting…”
connect-viserver $vCenterName

$MyCollection = @()

get-cluster | select-object name
$ClusterName = Read-Host -Prompt ‘Enter Cluster Name (must be exact)’
$ClusterFilter = get-view -ViewType ClusterComputeResource -Property Name -Filter @{“Name” = $ClusterName } | select -ExpandProperty MoRef

$AllVMs = Get-View -ViewType VirtualMachine -SearchRoot $ClusterFilter | Where {-not $_.Config.Template}
$SortedVMs = $AllVMs | Select *, @{N=”NumDisks”;E={@($_.Guest.Disk.Length)}} | Sort-Object -Descending NumDisks

ForEach ($VM in $SortedVMs){
$Details = New-object PSObject
$Details | Add-Member -Name Name -Value $VM.name -Membertype NoteProperty
$DiskNum = 0
Foreach ($disk in $VM.Guest.Disk){
$Details | Add-Member -Name “Disk$($DiskNum)path” -MemberType NoteProperty -Value $Disk.DiskPath
$Details | Add-Member -Name “Disk$($DiskNum)Capacity(MB)” -MemberType NoteProperty -Value (

[math]::Round($disk.Capacity/ 1MB))
$Details | Add-Member -Name “Disk$($DiskNum)FreeSpace(MB)” -MemberType NoteProperty -Value ([math]::Round($disk.FreeSpace / 1MB))
$DiskNum++
}
$MyCollection += $Details
}

$OutputFileName = Read-Host ‘Enter filename including extension (.csv)’
$MyCollection | Export-Csv $env:USERPROFILE\Documents\$OutputFileName

Write-Host “File has been saved to” $env:USERPROFILE\Documents\$OutputFileName

explorer.exe $env:USERPROFILE\Documents\$OutputFileName

# Out-GridView, Export-Csv, ConvertTo-Html or ConvertTo-Xml can be used above instead