Skip to content

Instantly share code, notes, and snippets.

@Ba4bes
Created February 25, 2019 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ba4bes/99b6f1647396781a70f495fa1e3cb2cf to your computer and use it in GitHub Desktop.
Save Ba4bes/99b6f1647396781a70f495fa1e3cb2cf to your computer and use it in GitHub Desktop.
A few functions with minimum characters for Cloud shell on a mobile device
function gar {
param(
[Parameter(Mandatory = $false)]
[String]$Name
)
if ($Name) {
get-azresource -Name $Name | Select-Object Name, Type
}
Else {
get-azresource | Select-Object Name, Type
}
}
function avm {
param(
[Parameter(Mandatory = $True)]
[String]
$Name
)
$RG = (get-azresource -Name $Name -ResourceType "Microsoft.Compute/virtualMachines").ResourceGroupName
if ([string]::IsNullOrEmpty($RG)) {
write-output "VM $Name not found"
}
else {
$RG = (get-azresource -Name $Name -ResourceType "Microsoft.Compute/virtualMachines").ResourceGroupName
Start-AzVM $Name -ResourceGroupName $RG
}
}
function qvm {
param(
[Parameter(Mandatory = $True)]
[String]
$Name
)
$RG = (get-azresource -Name $Name -ResourceType "Microsoft.Compute/virtualMachines").ResourceGroupName
if ([string]::IsNullOrEmpty($RG)) {
write-output "VM $Name not found"
}
else {
$RG = (get-azresource -Name $Name -ResourceType "Microsoft.Compute/virtualMachines").ResourceGroupName
Stop-AzVM $Name -ResourceGroupName $RG -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment