/// <summary> /// Process the record /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); ComputeServiceConnection newCloudComputeConnection = null; WriteDebug("Trying to login to the REST API"); try { newCloudComputeConnection = LoginTask().Result; if (newCloudComputeConnection != null) { WriteDebug(String.Format("CaaS connection created successfully: {0}", newCloudComputeConnection)); SessionState.AddComputeServiceConnection(newCloudComputeConnection); WriteObject(newCloudComputeConnection); } } catch (AggregateException ae) { ae.Handle( e => { ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.AuthenticationError, newCloudComputeConnection)); return(true); }); } }
/// <summary> /// Process the record /// </summary> protected override void ProcessRecord() { base.ProcessRecord(); ComputeServiceConnection newCloudComputeConnection = null; WriteDebug("Trying to login to the REST API"); try { newCloudComputeConnection = LoginTask().Result; if (newCloudComputeConnection != null) { WriteDebug(string.Format("CaaS connection created successfully: {0}", newCloudComputeConnection)); if (string.IsNullOrEmpty(Name)) { Name = Guid.NewGuid().ToString(); WriteWarning( string.Format("Connection name not specified. Therefore this connection name will be a random GUID: {0}", Name)); } if (!SessionState.GetComputeServiceConnections().Any()) { WriteDebug("This is the first connection and will be the default connection."); } SessionState.AddComputeServiceConnection(Name, newCloudComputeConnection); if (SessionState.GetComputeServiceConnections().Count > 1) { WriteWarning( "You have created more than one connection on this session, please use the cmdlet Set-CaasActiveConnection -Name <name> to change the active/default connection"); } SessionState.AddComputeServiceConnection(Name, newCloudComputeConnection); WriteObject(newCloudComputeConnection); } } catch (AggregateException ae) { ae.Handle( e => { ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.AuthenticationError, newCloudComputeConnection)); return(true); }); } }