-
Notifications
You must be signed in to change notification settings - Fork 4.1k
latest powershell changes for azurestackhci #29211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
486e37c
656e308
9ab3112
dd0a2ee
19a55b9
fb1b095
c0af3cb
dba104b
45c864f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,9 +102,10 @@ function New-AzStackHCIVMImage{ | |
|
|
||
| [Parameter(ParameterSetName='GalleryImage', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Body')] | ||
| [System.String] | ||
| # Local path of image that the image should be created from. | ||
| [System.Security.SecureString] | ||
| # Local path of image that the image should be created from (as SecureString). | ||
| # This parameter is required for non marketplace images. | ||
| # Use: ConvertTo-SecureString -String "path\to\image.vhdx" -AsPlainText -Force | ||
| ${ImagePath}, | ||
|
|
||
| [Parameter(ParameterSetName='GalleryImage', Mandatory)] | ||
|
|
@@ -333,12 +334,14 @@ function New-AzStackHCIVMImage{ | |
| Start-Sleep -Seconds 5 | ||
| if ($image.ProvisioningStatus -eq "Failed") { | ||
| Break | ||
| } | ||
| } | ||
| if (($PercentCompleted -ne 100) -and ($image.ProvisioningStatus -ne "Failed")) { | ||
| Start-Sleep -Seconds 5 | ||
| } | ||
|
Comment on lines
334
to
+340
|
||
| } | ||
| if ($image.ProvisioningStatus -eq "Failed"){ | ||
| Write-Error $image.StatusErrorMessage -ErrorAction Stop | ||
| } | ||
|
|
||
| } catch { | ||
| $e = $_ | ||
| if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){ | ||
|
|
@@ -416,6 +419,7 @@ function New-AzStackHCIVMImage{ | |
| if ($PSCmdlet.ParameterSetName -eq "GalleryImage") | ||
| { | ||
| try{ | ||
| # ImagePath is already a SecureString, no conversion needed | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Az.StackHCIVM.internal\New-AzStackHCIVMGalleryImage -ErrorAction Stop @PSBoundParameters | ||
| } catch { | ||
| $e = $_ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
|
|
||
| # ---------------------------------------------------------------------------------- | ||
| # | ||
| # Copyright Microsoft Corporation | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------------- | ||
|
|
||
| <# | ||
| .Synopsis | ||
| The operation to save a virtual machine instance. | ||
| .Description | ||
| The operation to save a virtual machine instance. | ||
|
|
||
| .Outputs | ||
| Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IVirtualMachineInstance | ||
| .Notes | ||
| COMPLEX PARAMETER PROPERTIES | ||
|
|
||
|
|
||
| .Link | ||
| https://learn.microsoft.com/powershell/module/az.stackhcivm/Save-AzStackHCIVMVirtualMachine | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #> | ||
| function Save-AzStackHCIVMVirtualMachine { | ||
| [OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IVirtualMachineInstance])] | ||
| [CmdletBinding( PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+31
to
+33
|
||
| param( | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Alias('VirtualMachineName')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # Name of the virtual machine | ||
| ${Name}, | ||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # The name of the resource group. | ||
| # The name is case insensitive. | ||
| ${ResourceGroupName}, | ||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
| [System.String] | ||
| # The ID of the target subscription. | ||
| ${SubscriptionId}, | ||
|
|
||
| [Parameter(ParameterSetName='ByResourceId', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # The ARM Resource ID of the virtual machine. | ||
| ${ResourceId}, | ||
|
|
||
| [Parameter()] | ||
| [Alias('AzureRMContext', 'AzureCredential')] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Azure')] | ||
| [System.Management.Automation.PSObject] | ||
| # The credentials, account, tenant, and subscription used for communication with Azure. | ||
| ${DefaultProfile}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command as a job | ||
| ${AsJob}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Wait for .NET debugger to attach | ||
| ${Break}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
| ${HttpPipelineAppend}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
| ${HttpPipelinePrepend}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command asynchronously | ||
| ${NoWait}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Uri] | ||
| # The URI for the proxy server to use | ||
| ${Proxy}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.PSCredential] | ||
| # Credentials for a proxy server to use for the remote call | ||
| ${ProxyCredential}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Use the default credentials for the proxy | ||
| ${ProxyUseDefaultCredentials} | ||
|
|
||
| ) | ||
| if (($resourceId -match $vmRegex) -or ($name -and $resourceGroupName -and $subscriptionId)){ | ||
| if ($resourceId -match $vmRegex){ | ||
| $subscriptionId = $($Matches['subscriptionId']) | ||
| $resourceGroupName = $($Matches['resourceGroupName']) | ||
| $name = $($Matches['machineName']) | ||
| } | ||
| $resourceUri = "/subscriptions/" + $subscriptionId + "/resourceGroups/" + $resourceGroupName + "/providers/Microsoft.HybridCompute/machines/" + $name | ||
| $PSBoundParameters.Add("ResourceUri", $resourceUri) | ||
| $null = $PSBoundParameters.Remove("SubscriptionId") | ||
| $null = $PSBoundParameters.Remove("ResourceGroupName") | ||
| $null = $PSBoundParameters.Remove("ResourceId") | ||
| $null = $PSBoundParameters.Remove("Name") | ||
|
|
||
| if ($PSCmdlet.ShouldProcess($resourceUri, "Save virtual machine instance")) { | ||
| try{ | ||
| Az.StackHCIVM.internal\Save-AzStackHCIVMVirtualMachine -ErrorAction Stop @PSBoundParameters | ||
| } catch { | ||
| $e = $_ | ||
| if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){ | ||
| Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop | ||
| } else { | ||
| Write-Error -ErrorRecord $e -ErrorAction Stop | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } else { | ||
| Write-Error "One or more input parameters are invalid. Resource ID is: $resourceId, name is $name, resource group name is $resourceGroupName, subscription id is $subscriptionId" -ErrorAction Stop | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
|
|
||
| # ---------------------------------------------------------------------------------- | ||
| # | ||
| # Copyright Microsoft Corporation | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------------- | ||
|
|
||
| <# | ||
| .Synopsis | ||
| The operation to Suspend a virtual machine instance. | ||
| .Description | ||
| The operation to Suspend a virtual machine instance. | ||
|
|
||
| .Outputs | ||
| Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IVirtualMachineInstance | ||
| .Notes | ||
| COMPLEX PARAMETER PROPERTIES | ||
|
|
||
|
|
||
| .Link | ||
| https://learn.microsoft.com/powershell/module/az.stackhcivm/Suspend-AzStackHCIVMVirtualMachine | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #> | ||
| function Suspend-AzStackHCIVMVirtualMachine { | ||
| [OutputType([Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Models.IVirtualMachineInstance])] | ||
| [CmdletBinding( PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| param( | ||
shraddhasun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Alias('VirtualMachineName')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # Name of the virtual machine | ||
| ${Name}, | ||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # The name of the resource group. | ||
| # The name is case insensitive. | ||
| ${ResourceGroupName}, | ||
|
|
||
| [Parameter(ParameterSetName='ByName', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
| [System.String] | ||
| # The ID of the target subscription. | ||
| ${SubscriptionId}, | ||
|
|
||
| [Parameter(ParameterSetName='ByResourceId', Mandatory)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Path')] | ||
| [System.String] | ||
| # The ARM Resource ID of the virtual machine. | ||
| ${ResourceId}, | ||
|
|
||
| [Parameter()] | ||
| [Alias('AzureRMContext', 'AzureCredential')] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Azure')] | ||
| [System.Management.Automation.PSObject] | ||
| # The credentials, account, tenant, and subscription used for communication with Azure. | ||
| ${DefaultProfile}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command as a job | ||
| ${AsJob}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Wait for .NET debugger to attach | ||
| ${Break}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
| ${HttpPipelineAppend}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Runtime.SendAsyncStep[]] | ||
| # SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
| ${HttpPipelinePrepend}, | ||
|
|
||
| [Parameter()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Run the command asynchronously | ||
| ${NoWait}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Uri] | ||
| # The URI for the proxy server to use | ||
| ${Proxy}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [ValidateNotNull()] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.PSCredential] | ||
| # Credentials for a proxy server to use for the remote call | ||
| ${ProxyCredential}, | ||
|
|
||
| [Parameter(DontShow)] | ||
| [Microsoft.Azure.PowerShell.Cmdlets.StackHCIVM.Category('Runtime')] | ||
| [System.Management.Automation.SwitchParameter] | ||
| # Use the default credentials for the proxy | ||
| ${ProxyUseDefaultCredentials} | ||
|
|
||
| ) | ||
| if (($ResourceId -match $vmRegex) -or ($name -and $resourceGroupName -and $subscriptionId)){ | ||
| if ($ResourceId -match $vmRegex){ | ||
| $subscriptionId = $($Matches['subscriptionId']) | ||
| $resourceGroupName = $($Matches['resourceGroupName']) | ||
| $name = $($Matches['machineName']) | ||
| } | ||
| $resourceUri = "/subscriptions/" + $subscriptionId + "/resourceGroups/" + $resourceGroupName + "/providers/Microsoft.HybridCompute/machines/" + $name | ||
| $PSBoundParameters.Add("ResourceUri", $resourceUri) | ||
| $null = $PSBoundParameters.Remove("SubscriptionId") | ||
| $null = $PSBoundParameters.Remove("ResourceGroupName") | ||
| $null = $PSBoundParameters.Remove("ResourceId") | ||
| $null = $PSBoundParameters.Remove("Name") | ||
|
|
||
| if ($PSCmdlet.ShouldProcess($resourceUri, "Suspend virtual machine")) { | ||
| try{ | ||
| Az.StackHCIVM.internal\Suspend-AzStackHCIVMVirtualMachine -ErrorAction Stop @PSBoundParameters | ||
| } catch { | ||
| $e = $_ | ||
| if ($e.FullyQualifiedErrorId -match "MissingAzureKubernetesMapping" ){ | ||
| Write-Error "An older version of the Arc VM cluster extension is installed on your cluster. Please downgrade the Az.StackHCIVm version to 1.0.1 to proceed." -ErrorAction Stop | ||
| } else { | ||
| Write-Error -ErrorRecord $e -ErrorAction Stop | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } else { | ||
| Write-Error "One or more input parameters are invalid. Resource ID is: $ResourceId, name is $name, resource group name is $resourceGroupName, subscription id is $subscriptionid" -ErrorAction Stop | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.