public/Set-AzureVMSize.ps1

function Set-AzureVMSize {
[cmdletbinding()]

param (

    [string]$VMName,
    [string]$NewVMSize

)

    Process 
    {

        Try {
            # couldn't explicitly get the vm for whatever reaso by passing the rg and vm name's as string....so doing the below :( I <3 Microsoft.
            $vm = Get-AzureRmResource -ErrorAction Stop -Verbose | 
            Where-Object {$_.name -like $VMName}
            $vm = $vm | Get-AzureRmVM
            $vm.HardwareProfile.VmSize = $NewVMSize
        }
        Catch {
            $error[0].Exception
            break
        }
        
        Try {
            $results = $vm | Update-AzureRmVM -ErrorAction Stop -Verbose
        }
        Catch {
            $error[0].Exception
            break
        }

    } #end process block

}