public override void ExecuteCmdlet()

in src/PowerShell/Commands/GetPartnerUserSignInActivity.cs [69:127]


        public override void ExecuteCmdlet()
        {
            Scheduler.RunTask(async () =>
            {
                GraphServiceClient client = PartnerSession.Instance.ClientFactory.CreateGraphServiceClient() as GraphServiceClient;
                IAuditLogRootSignInsCollectionPage collection;
                List<QueryOption> queryOptions = null;
                List<SignIn> signIns;
                string filter = string.Empty;

                client.AuthenticationProvider = new GraphAuthenticationProvider();

                if (StartDate != null)
                {
                    filter = AppendValue(filter, $"createdDateTime ge {StartDate.Value.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)}");
                }

                if (EndDate != null)
                {
                    filter = AppendValue(filter, $"createdDateTime le {EndDate.Value.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)}");
                }

                if (!string.IsNullOrEmpty(UserId))
                {
                    filter = AppendValue(filter, $"userId eq '{UserId}'");
                }

                if (!string.IsNullOrEmpty(filter))
                {
                    queryOptions = new List<QueryOption>
                    {
                        new QueryOption("$filter", $"({filter})")
                    };
                }

                try
                {
                    collection = await client.AuditLogs.SignIns.Request(queryOptions).Top(500).GetAsync(CancellationToken).ConfigureAwait(false);
                    signIns = new List<SignIn>(collection.CurrentPage);

                    while (collection.NextPageRequest != null)
                    {
                        collection = await collection.NextPageRequest.GetAsync(CancellationToken).ConfigureAwait(false);
                        signIns.AddRange(collection.CurrentPage);
                    }
                }
                catch (ServiceException ex)
                {
                    if (!ex.Error.Code.Equals(RequestFromNonPremiumTenant, StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw;
                    }

                    signIns = await GetSignInActivitiesAsync(client).ConfigureAwait(false);
                }

                WriteObject(signIns, true);
            }, true);
        }