OK, I've refined my script a bit. I realize this question is about a year and a half old, but I'm answering it anyway.
This script is provided as-is with no warranty or guarantee. I've not tested it beyond my own environment. I assume no liability or responsibility for its use. That being said, I hereby present:
# resizemirs.ps1
# Copyright © 2012, Jim Haddad
#
# This script will query mirror pairs between filers
# to check the source and destination sizes of each volume.
# If the destination volume is smaller than the source volume,
# The destination volume will be resized.
#
function GetVolSize ($Filer, $VolName) {
# Connect to the specified filer.
# Get the size of the source volume in bytes.
$FilerObj = connect-nacontroller $Filer -rpc
$VolSize = Get-NaVolSize $VolName
$VolBytes = $VolSize.VolumeSize
return $VolBytes
} # function GetSourceSize
function GetNewVolSize ($SourceVolBytes) {
# Starting with the size of the source volume,
# add on an additional 3% to pad the new size
# for the destination.
# Convert that to megabytes, and round it off.
# Add an "m" to the end of the string to match
# the required syntax for sending the command
# to the Filer.
$Padding = $SourceVolBytes*.03
$NewVolBytes = $SourceVolBytes + $Padding
$NewVolMB = $NewVolBytes/(1024*1024)
$NewVolRounded = ([math]::round($NewVolMB,0))
$NewVolSize = [string]::join('',($NewVolRounded,'m'))
return $NewVolSize
} # function GetNewSize
function SetNewVolSize ($Filer, $VolumeName, $NewVolSize) {
$FilerObj = connect-nacontroller $Filer -rpc
Set-NaVolSize $VolumeName $NewVolSize
} # function SetNewVolSize
# Main {
# Get the SnapMirror status for each filer.
# For each SnapMirror, parse out the source and destination filers and volumes.
# Call the function to get the size for each source volume.
# Call the function to get the size for each destination volume.
# If the destination size is less than the source size:
# Call the function to calculate the new size for the destination volume.
# Set the destination volume to the new size.
Import-Module DataONTAP
$Report = @()
$BlankLine = ""
#### Insert your own filer names in the following line:
$FilerList = "filer1","filer2","filer3"
####
Foreach ($Filer in $FilerList) {
$FilerObj = connect-nacontroller $Filer -rpc
$FilerMirrors = Get-NaSnapMirror
Foreach ($Pair in $FilerMirrors) {
$Source = $Pair.source.split(":")
$SourceFiler = $Source[0]
$SourceVolName = $Source[1]
$SourceVolBytes = GetVolSize $SourceFiler $SourceVolName
$ReportLine1 = $SourceVolName + ": " + $SourceVolBytes
$Destination = $Pair.destination.split(":")
$DestFiler = $Destination[0]
$DestVolName = $Destination[1]
$DestVolBytes = GetVolSize $DestFiler $DestVolName
$ReportLine2 = $DestVolName + ": " + $DestVolBytes
if ($DestVolBytes -lt $SourceVolBytes) {
$NewVolSize = GetNewVolSize $SourceVolBytes
$ReportLine3 = "Destination volume will be resized to: " + $NewVolSize
SetNewVolSize $DestFiler $DestVolName $NewVolSize
} else {
$ReportLine3 = "Destination Volume Size is OK."
} # if ($DestVolBytes -lt $SourceVolBytes)
$Report = $Report + $ReportLine1 + $ReportLine2 + $ReportLine3 + $BlankLine
} # Foreach ($Pair in $MirrorPairs)
} # Foreach ($Filer in $FilerList)
echo $Report > ResizeReport.txt
# } Main