Skip to content

Commit 0fbe671

Browse files
committed
Support Passthru
1 parent 49b18a1 commit 0fbe671

10 files changed

+83
-8
lines changed

src/ResourceManager/Intune/Commands.Intune/Apps/AddIntuneAndroidMAMPolicyAppCmdlet.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ public sealed class AddIntuneAndroidMAMPolicyAppCmdlet : IntuneBaseCmdlet
4141
[ValidateNotNullOrEmpty]
4242
public string AppName { get; set; }
4343

44+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
45+
public SwitchParameter PassThru { get; set; }
4446
/// <summary>
4547
/// Executes the cmdlet.
4648
/// </summary>
4749
public override void ExecuteCmdlet()
4850
{
4951
var payLoad = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(this.IntuneClient, LinkType.App, this.AsuHostName, this.AppName);
50-
this.IntuneClient.Android.AddAppForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.AppName, payLoad).GetAwaiter().GetResult();
52+
var result = this.IntuneClient.Android.AddAppForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.AppName, payLoad).GetAwaiter().GetResult();
53+
54+
if (PassThru)
55+
{
56+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
57+
}
5158
}
5259
}
5360
}

src/ResourceManager/Intune/Commands.Intune/Apps/AddIntuneiOSMAMPolicyAppCmdlet.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ public sealed class AddIntuneiOSMAMPolicyAppCmdlet : IntuneBaseCmdlet
4141
[ValidateNotNullOrEmpty]
4242
public string AppName { get; set; }
4343

44+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
45+
public SwitchParameter PassThru { get; set; }
46+
4447
/// <summary>
4548
/// Executes the cmdlet.
4649
/// </summary>
4750
public override void ExecuteCmdlet()
4851
{
4952
var payLoad = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(this.IntuneClient, LinkType.App, this.AsuHostName, this.AppName);
50-
this.IntuneClient.Ios.AddAppForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.AppName, payLoad).GetAwaiter().GetResult();
53+
var result = this.IntuneClient.Ios.AddAppForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.AppName, payLoad).GetAwaiter().GetResult();
54+
if (PassThru)
55+
{
56+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
57+
}
5158
}
5259
}
5360
}

src/ResourceManager/Intune/Commands.Intune/Apps/RemoveIntuneAndroidMAMPolicyAppCmdlet.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public sealed class RemoveIntuneAndroidMAMPolicyAppCmdlet : IntuneBaseCmdlet
4343
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
4444
public SwitchParameter Force { get; set; }
4545

46+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
47+
public SwitchParameter PassThru { get; set; }
48+
4649
/// <summary>
4750
/// Executes the cmdlet.
4851
/// </summary>
@@ -72,6 +75,12 @@ public override void ExecuteCmdlet()
7275
{
7376
this.WriteWarning(Resources.NoItemsDeleted);
7477
}
78+
79+
if (PassThru)
80+
{
81+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
82+
}
83+
7584
});
7685
}
7786
}

src/ResourceManager/Intune/Commands.Intune/Apps/RemoveIntuneiOSMAMPolicyAppCmdlet.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public sealed class RemoveIntuneiOSMAMPolicyAppCmdlet : IntuneBaseCmdlet
4242

4343
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
4444
public SwitchParameter Force { get; set; }
45+
46+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
47+
public SwitchParameter PassThru { get; set; }
4548
/// <summary>
4649
/// Executes the cmdlet.
4750
/// </summary>
@@ -71,6 +74,11 @@ public override void ExecuteCmdlet()
7174
{
7275
this.WriteWarning(Resources.NoItemsDeleted);
7376
}
77+
78+
if (PassThru)
79+
{
80+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
81+
}
7482
});
7583
}
7684
}

src/ResourceManager/Intune/Commands.Intune/Groups/AddIntuneAndroidMAMPolicyGroupCmdlet.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ public sealed class AddIntuneAndroidMAMPolicyGroupCmdlet : IntuneBaseCmdlet
4141
[ValidateNotNullOrEmpty]
4242
public string GroupName { get; set; }
4343

44+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
45+
public SwitchParameter PassThru { get; set; }
46+
4447
/// <summary>
4548
/// Executes the cmdlet.
4649
/// </summary>
4750
public override void ExecuteCmdlet()
4851
{
4952
var payLoad = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(this.IntuneClient, LinkType.Group, this.AsuHostName, this.GroupName);
50-
this.IntuneClient.Android.AddGroupForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.GroupName, payLoad).GetAwaiter().GetResult();
53+
var result = this.IntuneClient.Android.AddGroupForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.GroupName, payLoad).GetAwaiter().GetResult();
54+
if (PassThru)
55+
{
56+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
57+
}
5158
}
5259
}
5360
}

src/ResourceManager/Intune/Commands.Intune/Groups/AddIntuneiOSMAMPolicyGroupCmdlet.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,20 @@ public sealed class AddIntuneiOSMAMPolicyGroupCmdlet : IntuneBaseCmdlet
4141
[ValidateNotNullOrEmpty]
4242
public string GroupName { get; set; }
4343

44+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
45+
public SwitchParameter PassThru { get; set; }
46+
4447
/// <summary>
4548
/// Executes the cmdlet.
4649
/// </summary>
4750
public override void ExecuteCmdlet()
4851
{
4952
var payLoad = AppOrGroupPayloadMaker.PrepareMAMPolicyPayload(this.IntuneClient, LinkType.Group, this.AsuHostName, this.GroupName);
50-
this.IntuneClient.Ios.AddGroupForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.GroupName, payLoad).GetAwaiter().GetResult();
53+
var result = this.IntuneClient.Ios.AddGroupForMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name, this.GroupName, payLoad).GetAwaiter().GetResult();
54+
if (PassThru)
55+
{
56+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
57+
}
5158
}
5259
}
5360
}

src/ResourceManager/Intune/Commands.Intune/Groups/RemoveIntuneAndroidMAMPolicyGroupCmdlet.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public sealed class RemoveIntuneAndroidMAMPolicyGroupCmdlet : IntuneBaseCmdlet
4343

4444
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
4545
public SwitchParameter Force { get; set; }
46+
47+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
48+
public SwitchParameter PassThru { get; set; }
4649
/// <summary>
4750
/// Executes the cmdlet.
4851
/// </summary>
@@ -72,6 +75,11 @@ public override void ExecuteCmdlet()
7275
{
7376
this.WriteWarning(Resources.NoItemsDeleted);
7477
}
78+
79+
if (PassThru)
80+
{
81+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
82+
}
7583
});
7684
}
7785
}

src/ResourceManager/Intune/Commands.Intune/Groups/RemoveIntuneiOSMAMPolicyGroupCmdlet.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public sealed class RemoveIntuneiOSMAMPolicyGroupCmdlet : IntuneBaseCmdlet
4141

4242
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
4343
public SwitchParameter Force { get; set; }
44+
45+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
46+
public SwitchParameter PassThru { get; set; }
4447
/// <summary>
4548
/// Executes the cmdlet.
4649
/// </summary>
@@ -70,6 +73,11 @@ public override void ExecuteCmdlet()
7073
{
7174
this.WriteWarning(Resources.NoItemsDeleted);
7275
}
76+
77+
if (PassThru)
78+
{
79+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
80+
}
7381
});
7482
}
7583
}

src/ResourceManager/Intune/Commands.Intune/Policy/RemoveIntuneAndroidMAMPolicyCmdlet.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class RemoveIntuneAndroidMAMPolicyCmdlet : IntuneBaseCmdlet
3737
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
3838
public SwitchParameter Force { get; set; }
3939

40+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
41+
public SwitchParameter PassThru { get; set; }
4042
#endregion params
4143

4244
/// <summary>
@@ -52,11 +54,16 @@ public override void ExecuteCmdlet()
5254
this.Name,
5355
() =>
5456
{
55-
var res = this.IntuneClient.Android.DeleteMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name).GetAwaiter().GetResult();
56-
if (res.Response.StatusCode == HttpStatusCode.NoContent)
57+
var result = this.IntuneClient.Android.DeleteMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name).GetAwaiter().GetResult();
58+
if (result.Response.StatusCode == HttpStatusCode.NoContent)
5759
{
5860
this.WriteWarning(Resources.NoItemsDeleted);
5961
}
62+
63+
if (PassThru)
64+
{
65+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
66+
}
6067
}
6168
);
6269
}

src/ResourceManager/Intune/Commands.Intune/Policy/RemoveIntuneiOSMAMPolicyCmdlet.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class RemoveIntuneiOSMAMPolicyCmdlet : IntuneBaseCmdlet
3636
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
3737
public SwitchParameter Force { get; set; }
3838

39+
[Parameter(Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
40+
public SwitchParameter PassThru { get; set; }
3941
#endregion params
4042

4143
/// <summary>
@@ -51,11 +53,16 @@ public override void ExecuteCmdlet()
5153
this.Name,
5254
() =>
5355
{
54-
var res = this.IntuneClient.Ios.DeleteMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name).GetAwaiter().GetResult();
55-
if (res.Response.StatusCode == HttpStatusCode.NoContent)
56+
var result = this.IntuneClient.Ios.DeleteMAMPolicyWithHttpMessagesAsync(this.AsuHostName, this.Name).GetAwaiter().GetResult();
57+
if (result.Response.StatusCode == HttpStatusCode.NoContent)
5658
{
5759
this.WriteWarning(Resources.NoItemsDeleted);
5860
}
61+
62+
if (PassThru)
63+
{
64+
this.WriteObject(result.Response.StatusCode == HttpStatusCode.OK ? true : false);
65+
}
5966
}
6067
);
6168
}

0 commit comments

Comments
 (0)