Skip to content

Commit 5d2629f

Browse files
ShouldProcess
1 parent 24c2a66 commit 5d2629f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

experiments/Compute.Experiments/AzureRM.Compute.Experiments.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = ".\AzureRM.Compute.Experiments.psm1"
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.0.4'
15+
ModuleVersion = '1.0.5'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

experiments/Compute.Experiments/AzureRM.Compute.Experiments.psm1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.ExternalHelp AzureRM.Compute.Experiments-help.xml
33
#>
44
function New-AzVm {
5-
[CmdletBinding()]
5+
[CmdletBinding(SupportsShouldProcess = $true)]
66
param (
77
[Parameter(Mandatory=$true, Position=0)][string] $Name = "VM",
88
[Parameter()][PSCredential] $Credential,
@@ -42,12 +42,14 @@ function New-AzVm {
4242
$locationi.Value = $Location;
4343
}
4444

45-
$resourceGroup = $rgi.GetOrCreate($Name + "ResourceGroup", $locationi.Value, $null);
46-
$vmResponse = $vmi.Create($Name, $locationi.Value, $resourceGroup.ResourceGroupName);
45+
if ($PSCmdlet.ShouldProcess($Name, "Creating a virtual machine")) {
46+
$resourceGroup = $rgi.GetOrCreate($Name + "ResourceGroup", $locationi.Value, $null);
47+
$vmResponse = $vmi.Create($Name, $locationi.Value, $resourceGroup.ResourceGroupName);
4748

48-
New-PsObject @{
49-
ResourceId = $resourceGroup.ResourceId;
50-
Response = $vmResponse;
49+
New-PsObject @{
50+
ResourceId = $resourceGroup.ResourceId;
51+
Response = $vmResponse;
52+
}
5153
}
5254
}
5355
}

0 commit comments

Comments
 (0)