Following up on my last post, I have this script that I need to loop
++++++++++++++++++++++++++++++++++++++
Import-Module Dataontap
write-host ""
write-host ""
write-host "This script will list volumes over 80% full, the containing aggregates and snapmirror relationships" -foregroundcolor yellow
write-host ""
write-host ""
write-host "You will also get an option to increase a volume size" -foregroundcolor yellow
write-host ""
write-host ""
$filer = Read-Host "Enter the filer name"
$user = Read-Host "Enter username"
Connect-NaController -Name $filer -Credential $user
get-navol | ? {$_.used -gt 80} | select name,used,@{Name="Available Size (in GB)";Expression={[math]::truncate($_.Available/1gb)}},@{Name="Total Size (in GB)";Expression={[math]::truncate($_.sizetotal/1gb)}} | ft -Autosize | Out-String
write-host ""
write-host ""
write-host "Here are the aggregates:" -foregroundcolor yellow
write-host ""
write-host ""
get-naaggr | select name,@{Name="Total Size (in GB)";Expression={[math]::truncate($_.totalsize/1gb)}},used,@{Name="Available Size (in GB)";Expression={[math]::truncate($_.available/1gb)}} | ft -Autosize | Out-String
write-host ""
write-host ""
write-host "and the snapmirror relationships:" -foregroundcolor yellow
write-host ""
write-host ""
get-navol | ? {$_.used -gt 80} | get-nasnapmirror | select source,destination | ft -Autosize | Out-String
write-host ""
write-host ""
$ans = Read-Host -prompt "Would you like to increase one of the volumes? [Y/N]"
write-host ""
write-host ""
if ($ans -eq "N") {
exit
} else {
$vol = Read-Host "Enter volume name"
$size = Read-Host "How much more space do you want to give it? (example: +100g)"
Set-NaVolsize -Name $vol -NewSize $size -Confirm
Write-Host ""
Write-Host ""
Write-Host "Check the new size:" -foregroundcolor yellow
Write-Host ""
Write-Host ""
Get-NaVol -Name $vol | select name,used,@{Name="Available Size (in GB)";Expression={[math]::truncate($_.Available/1gb)}},@{Name="Total Size (in GB)";Expression={[math]::truncate($_.sizetotal/1gb)}}
}
+++++++++++++++++++++++++++++++++++++++++++
The above gives me the option to increase a volume size but will only run once. I'm after a loop that will give me an option to choose to run the Set-NaVolsize again.
It should be something like this at the end of the script:
$ans = Read-Host -prompt "Would you like to increase another volumes? [Y/N]"
if ($ans -eq "N") {
exit
} else {
$vol = Read-Host "Enter volume name"
$size = Read-Host "How much more space do you want to give it? (example: +100g)"
Set-NaVolsize -Name $vol -NewSize $size -Confirm
Write-Host ""
Write-Host ""
Write-Host "Check the new size:" -foregroundcolor yellow
Write-Host ""
Write-Host ""
Get-NaVol -Name $vol | select name,used,@{Name="Available Size (in GB)";Expression={[math]::truncate($_.Available/1gb)}},@{Name="Total Size (in GB)";Expression={[math]::truncate($_.sizetotal/1gb)}}
}
so the above should loop until the input is N (no) - how do I do that?
Thank you