@@ -38,8 +38,8 @@ public class DisconnectAzureRmAccountCommand : AzureContextModificationCmdlet
38
38
private const string ContextNameParameterSet = "ContextName" ;
39
39
40
40
41
-
42
- [ Parameter ( ParameterSetName = UserIdParameterSet ,
41
+
42
+ [ Parameter ( ParameterSetName = UserIdParameterSet ,
43
43
Mandatory = true , HelpMessage = "User name of the form [email protected] " , Position = 0 ) ]
44
44
[ ValidateNotNullOrEmpty ]
45
45
[ Alias ( "Id" , "UserId" ) ]
@@ -56,24 +56,32 @@ public class DisconnectAzureRmAccountCommand : AzureContextModificationCmdlet
56
56
[ ValidateNotNullOrEmpty ]
57
57
public string TenantId { get ; set ; }
58
58
59
- [ Parameter ( ParameterSetName = InputObjectParametrSet ,
59
+ [ Parameter ( ParameterSetName = InputObjectParametrSet ,
60
60
Mandatory = true , ValueFromPipeline = true , Position = 0 , HelpMessage = "Account" ) ]
61
61
[ ValidateNotNull ]
62
62
public PSAzureRmAccount InputObject { get ; set ; }
63
-
64
- [ Parameter ( ParameterSetName = ContextParameterSet ,
63
+
64
+ [ Parameter ( ParameterSetName = ContextParameterSet ,
65
65
Mandatory = true , HelpMessage = "Context" , ValueFromPipeline = true , Position = 0 ) ]
66
66
[ ValidateNotNull ]
67
67
public PSAzureContext AzureContext { get ; set ; }
68
68
69
-
70
- [ Parameter ( ParameterSetName = ContextNameParameterSet ,
69
+
70
+ [ Parameter ( ParameterSetName = ContextNameParameterSet ,
71
71
Mandatory = false , HelpMessage = "Name of the context to log out of" ) ]
72
72
[ ValidateNotNullOrEmpty ]
73
73
public string ContextName { get ; set ; }
74
74
75
75
public override void ExecuteCmdlet ( )
76
76
{
77
+ if ( DefaultProfile != null && DefaultProfile . DefaultContext == null )
78
+ {
79
+ WriteVerbose ( string . Format ( "No accounts were found to disconnect from. Ending call to Disconnect-{0}Account." ,
80
+ ResourceManager . Common . AzureRMConstants . AzureRMPrefix ) ) ;
81
+ WriteObject ( null ) ;
82
+ return ;
83
+ }
84
+
77
85
IAzureAccount azureAccount = null ;
78
86
switch ( ParameterSetName )
79
87
{
0 commit comments