Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 305 additions & 0 deletions src/Azs.Compute.Admin/custom/Get-AzsDisk.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@

# ----------------------------------------------------------------------------------
#
# 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
Returns the disk.
.Description
Returns the disk.
.Example
PS C:\> Get-AzsDisk
.Example
PS C:\> Get-AzsDisk -Name "426b8945-8a24-42ad-acdc-c26f16202489"

ActualSizeGb : 24
DiskId : 426b8945-8a24-42ad-acdc-c26f16202489
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/providers/Microsoft.Compute.Admin/locations/north
west/disks/426b8945-8a24-42ad-acdc-c26f16202489
Location : northwest
ManagedBy :
Name : northwest/426b8945-8a24-42ad-acdc-c26f16202489
ProvisionSizeGb : 127
SharePath : \\SU1FileServer.azs-long02-int.selfhost.corp.microsoft.com\SU1_ObjStore_3
Status : Unattached
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/resourceGroups/LADTEST/providers/Microsoft.Comput
e/Disks/TEST_OsDisk_1_426b89458a2442adacdcc26f16202489
.Example
PS C:\> Get-AzsDisk -Count 3

ActualSizeGb : 24
DiskId : 20f1619e-4210-47f6-81e6-b89e3028df06
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/providers/Microsoft.Compute.Admin/locations/north
west/disks/20f1619e-4210-47f6-81e6-b89e3028df06
Location : northwest
ManagedBy :
Name : northwest/20f1619e-4210-47f6-81e6-b89e3028df06
ProvisionSizeGb : 127
SharePath : \\SU1FileServer.azs-long02-int.selfhost.corp.microsoft.com\SU1_ObjStore_4
Status : Unattached
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/resourceGroups/RG1/providers/Microsoft.Compute/Di
sks/TEST_OsDisk_1_20f1619e421047f681e6b89e3028df06

ActualSizeGb : 24
DiskId : 38a767e4-4ceb-49fb-a53c-48de9b08aaae
DiskSku : Standard_LRS
DiskType : Disk
Id : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/providers/Microsoft.Compute.Admin/locations/north
west/disks/38a767e4-4ceb-49fb-a53c-48de9b08aaae
Location : northwest
ManagedBy :
Name : northwest/38a767e4-4ceb-49fb-a53c-48de9b08aaae
ProvisionSizeGb : 127
SharePath : \\SU1FileServer.azs-long02-int.selfhost.corp.microsoft.com\SU1_ObjStore_4
Status : Unattached
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/resourceGroups/SCTE/providers/Microsoft.Compute/D
isks/SCTETest_OsDisk_1_38a767e44ceb49fba53c48de9b08aaae

ActualSizeGb : 24
DiskId : 426b8945-8a24-42ad-acdc-c26f16202489
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/providers/Microsoft.Compute.Admin/locations/north
west/disks/426b8945-8a24-42ad-acdc-c26f16202489
Location : northwest
ManagedBy :
Name : northwest/426b8945-8a24-42ad-acdc-c26f16202489
ProvisionSizeGb : 127
SharePath : \\SU1FileServer.azs-long02-int.selfhost.corp.microsoft.com\SU1_ObjStore_3
Status : Unattached
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/74c72bdc-d917-431c-a377-8ca80f4238a0/resourceGroups/LADTEST/providers/Microsoft.Comput
e/Disks/TEST_OsDisk_1_426b89458a2442adacdcc26f16202489
.Example
PS C:\> Get-AzsDisk -Status All -ScaleUnit s-cluster -VolumeLabel Objstore_4

ActualSizeGb : 2
DiskId : e4732f76-0753-40ec-80f5-8effdd0b437d
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/providers/Microsoft.Compute.Admin/locations/redmond/disks/e4732f76-0753-40ec-80f5-8effdd0b437d
Location : redmond
ManagedBy : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/rbactest/providers/Microsoft.Compute/virtualMachines/test1
Name : redmond/e4732f76-0753-40ec-80f5-8effdd0b437d
ProvisionSizeGb : 30
SharePath : \\SU1FileServer.s11r0401.masd.stbtest.microsoft.com\SU1_ObjStore_4
Status : Reserved
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/RBACTEST/providers/Microsoft.Compute/Disks/test1_OsDisk_1_e4732f76075340ec80f58effdd0b437d

ActualSizeGb : 1
DiskId : 0485cbc9-1efa-43bd-86c2-0e201d79c528
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/providers/Microsoft.Compute.Admin/locations/redmond/disks/0485cbc9-1efa-43bd-86c2-0e201d79c528
Location : redmond
ManagedBy : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/rbactest/providers/Microsoft.Compute/virtualMachines/test1
Name : redmond/0485cbc9-1efa-43bd-86c2-0e201d79c528
ProvisionSizeGb : 64
SharePath : \\SU1FileServer.s11r0401.masd.stbtest.microsoft.com\SU1_ObjStore_4
Status : Reserved
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/TESTRG1/providers/Microsoft.Compute/Disks/gpsdisk

ActualSizeGb : 1
DiskId : 137893db-e7ce-4907-a488-b35c5e928614
DiskSku : Premium_LRS
DiskType : Disk
Id : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/providers/Microsoft.Compute.Admin/locations/redmond/disks/137893db-e7ce-4907-a488-b35c5e928614
Location : redmond
ManagedBy : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/rbactest/providers/Microsoft.Compute/virtualMachines/test1
Name : redmond/137893db-e7ce-4907-a488-b35c5e928614
ProvisionSizeGb : 55
SharePath : \\SU1FileServer.s11r0401.masd.stbtest.microsoft.com\SU1_ObjStore_4
Status : Reserved
Type : Microsoft.Compute.Admin/locations/disks
UserResourceId : /subscriptions/7829c784-cd3f-464a-b195-3be83c964c9c/resourceGroups/RBACTEST/providers/Microsoft.Compute/Disks/testdd

.Inputs
Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.IComputeAdminIdentity
.Outputs
Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.Api20210401.IDisk
.Notes
COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

INPUTOBJECT <IComputeAdminIdentity>: Identity Parameter
[DiskId <String>]: The disk guid as identity.
[Id <String>]: Resource identity path
[Location <String>]: Location of the resource.
[MigrationId <String>]: The migration job guid name.
[Offer <String>]: Name of the offer.
[Publisher <String>]: Name of the publisher.
[QuotaName <String>]: Name of the quota.
[Sku <String>]: Name of the SKU.
[SubscriptionId <String>]: Subscription credentials that uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.
[Type <String>]: Type of extension.
[Version <String>]: The version of the resource.
.Link
https://docs.microsoft.com/en-us/powershell/module/azs.compute.admin/get-azsdisk
#>
function Get-AzsDisk {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.Api20210401.IDisk])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='Get')]
[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Runtime.DefaultInfo(Script='(Get-AzLocation)[0].Location')]
[System.String]
# Location of the resource.
${Location},

[Parameter(ParameterSetName='Get', Mandatory)]
[Alias('DiskId')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Path')]
[System.String]
# The disk guid as identity.
${Name},

[Parameter(ParameterSetName='Get')]
[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String[]]
# Subscription credentials that uniquely identify Microsoft Azure subscription.
# The subscription ID forms part of the URI for every service call.
${SubscriptionId},

[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Models.IComputeAdminIdentity]
# Identity Parameter
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
${InputObject},

[Parameter(ParameterSetName='Get')]
[Parameter(ParameterSetName='GetViaIdentity')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.Management.Automation.SwitchParameter]
# Switch for whether summary or detailed disk size information is returned.
${ShowSizeDetail},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.Int32]
# The maximum number of disks to return.
${Count},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.String]
# The scale unit which the resource belongs to.
${ScaleUnit},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.String]
# The share which the resource belongs to.
${SharePath},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.Int32]
# The start index of disks in query.
${Start},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.String]
# The parameters of disk state.
${Status},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.String]
# User Subscription Id which the resource belongs to.
${UserSubscriptionId},

[Parameter(ParameterSetName='List')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Query')]
[System.String]
# The volume label of the volume which the resource belongs to.
${VolumeLabel},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.ComputeAdmin.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process {
# Generated cmdlet does not support {prefix}/{name} for ScaleUnit name, so extract the {name} part here
if ($PSBoundParameters.ContainsKey(('Name')))
{
if ($null -ne $Name -and $Name.Contains('/'))
{
$PSBoundParameters['Name'] = $Name.Split("/")[-1]
}
}

Azs.Compute.Admin.internal\Get-AzsDisk @PSBoundParameters
}

}
6 changes: 6 additions & 0 deletions src/Azs.Compute.Admin/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ directive:
subject: DiskMigrationJob
variant: CancelViaIdentity
remove: true

# Hide the auto-generated Get-AzsDisk and expose it through customized one
- where:
verb: Get
subject: Disk
hide: true

# Hide the auto-generated New-AzsDiskMigrationJob and expose it through customized one
- where:
Expand Down
9 changes: 2 additions & 7 deletions src/Azs.Compute.Admin/test/Common.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
$global:SkippedTests = @(
"TestDeleteNonExistingQuota",
"TestListDisks",
"TestGetDisk",
"TestGetDiskMigrationJob",
"TestNewDiskMigrationJob",
"TestStopDiskMigrationJob"
)
"TestDeleteNonExistingQuota"
)
Loading