Showing posts with label Netapp. Show all posts
Showing posts with label Netapp. Show all posts

Tuesday, May 28, 2013

Powershell: Get permissions on each vfiler cifs share.

Purpose: Get a list of all shares on each vfiler on each filer Notes: This script needs some work with the nested foreach loops and some error check cleanup.

Import-Module dataontap

Function Get-ACLPermissions($Share){
 $acl = Get-Acl -Path $Share
return $ACL
}

$myCol = @()

$AllNetappFiler = "filer03","filer02"

foreach ($NetappFiler In $AllNetappFiler){


  write-host "Scanning $NetappFiler"   
 connect-nacontroller $NetappFiler | out-null
    $Vfilers = get-navfiler * | Select -expand Name
 foreach ($Vfiler in $Vfilers){
  connect-nacontroller $Vfiler 
  $vfiler
  $Shares = get-nacifsshare | Select -expand ShareName
  foreach ($Share in $Shares){
   Write-Host "$Vfiler insideloop"
   
   #If $Vfiler Blank then scan shares on filer.. Need to add logic
   $fullpath = "\\$Vfiler\$Share"
   
   
   
   $ShareACL = Get-ACLPermissions $fullpath
   $o = 0
   $ShareACL.Access | ForEach-Object {
    $Detail = New-Object PSObject  
    $Detail | Add-Member Noteproperty SystemName $NetappFiler
    $Detail | add-member Noteproperty Vfiler $Vfiler
    $Detail | Add-Member noteProperty Share $Share 
    
    $FileSystemRights = $ShareACL.Access[$o] | Select -ExpandProperty FileSystemRights #Example ReadAndExecute 
    $AccessControlType = $ShareACL.Access[$o] | Select -ExpandProperty AccessControlType #Example Allow/Deny
    $IdentityReference = $ShareACL.Access[$o] | Select -ExpandProperty IdentityReference #Example Everyone,Username
    $IsInherited = $ShareACL.Access[$o] | Select -ExpandProperty IsInherited #Are Permissions inherited
    $InheritanceFlags = $ShareACL.Access[$o] | Select -ExpandProperty InheritanceFlags #Type of Inheritance ContainerInherit
    $PropagationFlags = $ShareACL.Access[$o] | Select -ExpandProperty PropagationFlags #PropagationFlags
    
    switch -wildcard ($FileSystemRights) 
        { 
            "268435456*" {$FileSystemRights = "FullControl"} 
            "-536805376*" {$FileSystemRights = "Modify, Synchronize"} 
            "-1610612736*" {$FileSystemRights = "ReadAndExecute, Synchronize"} 
        }
     
    $Detail | Add-Member noteProperty IdentityReference $IdentityReference  
    $Detail | Add-Member noteProperty FileSystemRights $FileSystemRights
    $Detail | Add-Member noteProperty AccessControlType $AccessControlType
    $Detail | Add-Member noteProperty IsInherited $IsInherited
    $Detail | Add-Member noteProperty InheritanceFlags $InheritanceFlags  
    $Detail | Add-Member noteProperty PropagationFlags $PropagationFlags 
    $o++
    
    $myCol += $Detail
    }
  }


 } 
}
$myCol | Export-Csv -Path "c:\temp\Audit_NetappVfilerCifis.csv" -NoTypeInformation

Thursday, February 21, 2013

Powershell - Find VM raw disk path to netapp lun


Purpose:
I needed a way get raw disk mappings from a vmware vm to the lun it is using on a netapp filer. One thing that needs to be edited is the SearchFilers function. Just add your runtime names and what filers they correspond to.Run this from powercli. and this requires the dataontap module which you can get from your now.netapp.com site Note: this script could be improved by gather all lun information from each filer instead of what i did the in the search filer function

              
param([string]$VC)
Import-Module DataONTAP
#########################
####Tony Unger
#########################


#################Functions##############################################
function GetNetappPath([string]$VMHost,[string]$VMHDLunID,[string]$RuntimeName) {
$stor = get-view (Get-VMHostStorage -VMHost $VMHost)
$IscsiWWN = $stor.StorageDeviceInfo.HostBusAdapter | where {$_.GetType().Name -eq "HostInternetScsiHba"} | Select -First 1 -expandproperty IScsiName
Write-Host "Found ISCSI NAME: $IscsiWWN on Host $VMHost"
$c = SearchFilers $IscsiWWN $RuntimeName
Write-Host "Netapp path: $c"
return $c
}

function SearchFilers([string]$IscsiWWN,[string]$RuntimeName){

switch -wildcard ($RuntimeName) 
    { 
       #Add all you runtime names here with what filer
        "vmhba40:C0:T0*" {$NetappFiler = "x.x.x.x"} 
        
        default {Write-host "Error! determining filer - $RuntimeName not found";read-host}
    }
 
 Write-host "Connecting to $NetappFiler"
connect-nacontroller $NetappFiler | out-null

$Igroup = get-nalun | Get-Nalunmap | Select Name,Initiators | Where {$_.Initiators -like $IscsiWWN} | Select -First 1 -expandproperty Name
$a = get-nalunbyigroup $Igroup $VMHDLunID | Select -ExpandProperty Path
Write-Host "SearchFilers function: $a"
$a = "$NetappFiler$a"
 return $a
 }
 
#################Functions##############################################
########################
$PathtoCSV = "C:\temp\VMlunID.csv"
########################
If ($VC){$strVC = $VC}
ELSE{$strVC = Read-Host "What is the Vcenter hostname?"}
If (!$strVC){Write-Host "Error: Vcenter not entered";exit}
Connect-VIServer -Server $strVC  #Enter your vCenter Server
"Hostname,DiskID,CapacityG,HD Path,ScsiCanonicalName,LunID,ESX Host,Netapp Path" > $PathtoCSV
Write-Host "Getting VM Information from Vcenter. This can take awhile based on how many VM you have"
$Disks = Get-VM | Get-HardDisk | Where {"RawPhysical","RawVirtual" -contains $_.DiskType}
Write-Host "Completed getting VM Information from Vcenter"
Write-Host ""
Write-Host "Querying SCSI Information for Vcenter"
#Adding all hosts Canonicalnames and runtimes names to a hash table 
#thanks http://communities.vmware.com/people/LucD
$lunTab = @{}
Get-VMHost  | Get-ScsiLun | %{
  $lunTab.Add($_.VMHost.Name + $_.CanonicalName, $_.RuntimeName)
}
Write-Host "Completed SCSI Information for Vcenter"

Foreach ($Disk in $Disks) {
$VMName = $Disk.Parent
write-host "VM Name: $VMName"
$VMHDname = $Disk.Name
write-host "Hard drive ID: $VMHDname"
$VMCapacityGB = $Disk.capacityGB
write-host "Lun Capacity(GB): $VMCapacityGB"
$VMHDPath = $Disk.filename
write-host "RAW VMDK Path: $VMHDPath"
$VMScsiCanonicalName = $Disk.ScsiCanonicalName
write-host "$ScsiCanonicalName: $VMScsiCanonicalName"
$VMHost = Get-VM $VMName | Select -ExpandProperty VMHost
write-host "ESX Host: $VMHost"
$RuntimeName = $lunTab[$VMHost.Name + $Disk.SCSICanonicalName]
write-host "RuntimeName: $RuntimeName"
$VMHDLunID = $RuntimeName.Substring($RuntimeName.LastIndexof(“L”)+1)
Write-Host "LunID: $VMHDLunID"
$NetappPath = GetNetappPath $VMHost $VMHDLunID $RuntimeName
Write-host "PathtoNetapp: $NetappPath"
$Combine = $VMName,$VMHDname,$VMCapacityGB,$VMHDPath,$VMScsiCanonicalName,$VMHDLunID,$VMHost,$NetappPath
Write-Host "Writing to $PathtoCSV"
$Combine -join "," >> $PathtoCSV
}

Tuesday, January 22, 2013

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
                 
    }               

Friday, March 19, 2010

Alua - Asymmetric Logical unit access

- industry standard protocol that enables the communication of storage paths and path characteristics between an initiator port and a target port.

If your storage array is ALUA compliant (as NetApp arrays are) then you’re in luck because the vSphere NMP is, by default, ALUA aware.

To enable Aula the igroups must be changed on each controller in the cluster

igroup set "igroupname" alua yes

Install ESX host utilities from netapp and run
config_mpath -s -m -a netappcontroller:root:password -a netappcontroller:root:password

This will enable round robin.

Round robin will allow for proper load balancing mult pathing

esxcli nmp device list on each ESX host to ensure RR and Aula are working
http://now.netapp.com/NOW/knowledge/docs/ontap/rel732_vs/html/ontap/bsag/GUID-EB9DBAE9-1E88-4421-9D02-FD820589515D.html

Tuesday, January 5, 2010

Sophos and Netapp

So for the past few weeks I have had a case open with Netapp about any time a disk is formatted with windows it reaches 100% then the entire OS becomes unstable. .. This happens on both a physical box and a virtual box.

After a week of testing looking for issues I decide to create a new virtual while they look at logs. One by one I install 3rd party applications and end up on Sophos Antivirus. It seems a part of Sophos call "Data Control" when enable causes this issue to happen. When disable formating the lun works correctly.. So Data Control may need to be disabled in Sophos to properly format a disk till either netapp or sophos gets back to me if the issue is even related to them.. .

Powershell: Microsoft Graph to add new roles to application registration

PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...