Tuesday, January 22, 2013

Netapp Replace disk on sans


I would suggest that you be on the line for support for this one (but that being said it was easy to do.)
Once the drive is replace and you need to move the data from the Large 450 drive to the 300 drive do this
Command line
Run the  sysconfig -r
This will give you a list of the drives and the spares will show up in the end
If a spare shows up as NON Zero you must Zero it.
Run this command (it will not hurt anything to run this if there is no disk to Zero)
disk zero spares

Run this command to move the data.
disk replace start  (from drive) (to drive)
Example  disk replace start 1a.44 1a.17        this will move the data from drive 1a.44  to drive 1a.17
Once the data is move the drive will be available for a spare.
 

Powershell Netapp - Total Volume size using get-navol


Purpose:
I needed a way to query a netapp filer to give all the volumes and their total size with snapshot reserve.This is my second powershell script so be easy on me :-) Also this requires dataontap powershell toolkit


              
param([string]$NetAppHost, [string]$username)

Import-module DataOnTap

$PathtoCSV = "C:\NetappTotalVolume.csv"

If ($NetAPPHost){$strNetAPPHost = $NetAPPHost}
ELSE{$strNetAPPHost = Read-Host "What is the Netapp hostname/IP?"}
If (!$strNetAPPHost){Write-Host "Error: Netapp hostname/ip not entered";exit}


If ($username){$strusername = $username}
ELSE{$strusername = Read-Host "What username?"}
If (!$strusername){Write-Host "Error: Username not entered";exit}

Connect-NAController $strNetAPPHost –cred $strusername

$allvolumesnames = get-navol | Select-Object Name,Available,TotalSize,snapshotpercentreserved

#set headers of CSV file
"Hostname,Available Space(GB),Used Space(GB),Total Volume Space(GB)" > $PathtoCSV
foreach ($netapp_vol in $allvolumesnames) {

$CurrentVolname = $netapp_vol.name
$VolumeSizeTotal = [math]::Round([decimal]((($netapp_vol.snapshotpercentreserved * 100) * $netapp_vol.TotalSize) + $netapp_vol.TotalSize)/1gb,2)
$VolumesAvailable =  [math]::Round([decimal]$netapp_vol.available/1gb,2)

#Create/add to CSV file
$Combine = $CurrentVolname,$VolumeAvailable1GB,$VolumeUsedSpace1GB,$VolumeSizeTotal1GB
$Combine -join "," >> $PathtoCSV
                 
    }               

Thursday, January 17, 2013

Powershell VMware NTP


Purpose:
This is my first powershell script. It connects to a esxi host and removes all NTP servers dynamically then sets the new ones.

param([string]$VC, [string]$NTP1, [string]$NTP2)

If ($VC){$strVC = $VC}
ELSE{$strVC = Read-Host "What is the Vcenter hostname?"}
If (!$strVC){Write-Host "Error: Vcenter not entered";exit}

If ($NTP1){$strNTP1 = $NTP1}
ELSE{$strNTP1 = Read-Host "What is the first NTP server?"}
If (!$strNTP1){Write-Host "Error: NTP1 not entered need at least one NTP server";exit}

If ($NTP2){$strNTP2 = $NTP2}
ELSE{$strNTP2 = Read-Host "What is the second NTP server?"}


Connect-VIServer -Server $strVC  #Enter your vCenter Server

$NtpServers = @($strNTP1,$strNTP2)
#http://day2dayadmin.blogspot.com/2009/10/ntp-powershell-its-about-time.html
$ESXHosts = Get-VMHost | Select-Object Name,@{Name="NTP Server";Expression={$_ | Get-VMHostNtpServer}}, @{Name="NTP Running";Expression={($_ | Get-VMHostService | Where-Object {$_.key -eq "ntpd"}).Running}} | Sort-Object -Property "NTP Running", "NTP Server"



ForEach ($ESXHost in $ESXHosts) {
   
   
#Write-Host $ESXHost

   #remove current NTP servers
   Write-Host "Removing NTP servers" -BackgroundColor "Green" -ForegroundColor "Black"
   Remove-VMHostNtpServer -NtpServer $ESXHost."NTP Server" -VMHost $ESXHost.Name
   #Add new NTP servers
   Write-Host "Adding New NTP servers" -BackgroundColor "Green" -ForegroundColor "Black"
   Add-VmHostNtpServer -NtpServer $NtpServers -VMHost $ESXHost.Name
   #Stop NTP service   
   Write-Host "Stopping NTP Service" -BackgroundColor "Green" -ForegroundColor "Black"
   Get-VmHostService -VMHost $ESXHost.Name | Where-Object {$_.key -eq "ntpd"} | Restart-VMHostService
 
}
Write-Host "Done!"