File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
src/ResourceManager/Profile/Commands.Profile/Context Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,7 @@ protected override AzureContext DefaultContext
36
36
{
37
37
if ( DefaultProfile == null || DefaultProfile . Context == null )
38
38
{
39
- WriteError ( new ErrorRecord (
40
- new PSInvalidOperationException ( "Run Login-AzureRmAccount to login." ) ,
41
- string . Empty ,
42
- ErrorCategory . AuthenticationError ,
43
- null ) ) ;
39
+ return null ;
44
40
}
45
41
46
42
return DefaultProfile . Context ;
@@ -49,7 +45,16 @@ protected override AzureContext DefaultContext
49
45
50
46
public override void ExecuteCmdlet ( )
51
47
{
52
- WriteObject ( ( PSAzureContext ) AzureRmProfileProvider . Instance . Profile . Context ) ;
48
+ var context = ( PSAzureContext ) AzureRmProfileProvider . Instance . Profile . Context ;
49
+ if ( context == null )
50
+ {
51
+ WriteError ( new ErrorRecord (
52
+ new PSInvalidOperationException ( "Run Login-AzureRmAccount to login." ) ,
53
+ string . Empty ,
54
+ ErrorCategory . AuthenticationError ,
55
+ null ) ) ;
56
+ }
57
+ WriteObject ( context ) ;
53
58
}
54
59
}
55
60
}
You can’t perform that action at this time.
0 commit comments