Skip to content

Commit 6e0b9ea

Browse files
committed
Add Rdp file
1 parent ef56c83 commit 6e0b9ea

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/ResourceManager/Compute/Commands.Compute/Common/ConstantStringTypes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ public static class ProfileNouns
8080
public const string VirtualMachineImageSku = "AzureVMImageSku";
8181

8282
public const string VirtualMachineUsage = "AzureVMUsage";
83+
84+
public const string RemoteDesktopFile = "AzureRemoteDesktopFile";
8385
}
8486
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Compute.Common;
16+
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Management.Compute;
18+
using Microsoft.Azure.Management.Compute.Models;
19+
using System;
20+
using System.Management.Automation;
21+
22+
namespace Microsoft.Azure.Commands.Compute
23+
{
24+
[Cmdlet(VerbsCommon.Get, ProfileNouns.RemoteDesktopFile)]
25+
public class GetAzureRemoteDesktopFile : VirtualMachineBaseCmdlet
26+
{
27+
[Parameter(
28+
Mandatory = true,
29+
Position = 0,
30+
ValueFromPipelineByPropertyName = true,
31+
HelpMessage = "The resource group name.")]
32+
[ValidateNotNullOrEmpty]
33+
public override string ResourceGroupName { get; set; }
34+
35+
[Alias("ResourceName", "VMName")]
36+
[Parameter(
37+
Mandatory = true,
38+
Position = 1,
39+
ValueFromPipelineByPropertyName = true,
40+
HelpMessage = "The resource name.")]
41+
[ValidateNotNullOrEmpty]
42+
public override string Name { get; set; }
43+
44+
45+
public override void ExecuteCmdlet()
46+
{
47+
base.ExecuteCmdlet();
48+
49+
if (!string.IsNullOrEmpty(this.Name))
50+
{
51+
if (Status)
52+
{
53+
var result = this.VirtualMachineClient.GetWithInstanceView(this.ResourceGroupName, this.Name);
54+
WriteObject(result.ToPSVirtualMachineInstanceView(this.ResourceGroupName, this.Name));
55+
}
56+
else
57+
{
58+
var result = this.VirtualMachineClient.Get(this.ResourceGroupName, this.Name);
59+
WriteObject(result.ToPSVirtualMachine(this.ResourceGroupName));
60+
}
61+
}
62+
else
63+
{
64+
VirtualMachineListResponse result = null;
65+
66+
if (!string.IsNullOrEmpty(this.ResourceGroupName))
67+
{
68+
result = this.VirtualMachineClient.List(this.ResourceGroupName);
69+
}
70+
else if (this.NextLink != null)
71+
{
72+
result = this.VirtualMachineClient.ListNext(this.NextLink.ToString());
73+
}
74+
else
75+
{
76+
var listParams = new ListParameters();
77+
result = this.VirtualMachineClient.ListAll(listParams);
78+
}
79+
80+
WriteObject(result.ToPSVirtualMachineList(this.ResourceGroupName), true);
81+
}
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)