void IOrganizationOperation.SetTenantUpgradeCapability(string identity, bool tenantUpgradeCapabilityEnabled) { using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers")) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("Set-Mailbox"); pscommand.AddParameter("Identity", identity); pscommand.AddParameter("Arbitration"); pscommand.AddParameter("Force"); pscommand.AddParameter("TenantUpgrade", tenantUpgradeCapabilityEnabled); try { anchorRunspaceProxy.RunPSCommand <Mailbox>(pscommand); } catch (MigrationPermanentException ex) { this.Context.Logger.Log(MigrationEventType.Error, "Unable to set TenantUpgrade capability for '{0}': {1}", new object[] { identity, ex }); throw; } } }
void IOrganizationOperation.InvokeOrganizationCmdlet(string organizationId, string cmdlet, bool configOnly) { using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers")) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand(cmdlet); pscommand.AddParameter("Identity", organizationId); if (configOnly && cmdlet.Contains("Start-OrganizationUpgrade")) { pscommand.AddParameter("ConfigOnly"); } try { anchorRunspaceProxy.RunPSCommand <PSObject>(pscommand); } catch (MigrationPermanentException ex) { this.Context.Logger.Log(MigrationEventType.Error, "{0} '{1}' failed due to {2}", new object[] { cmdlet, organizationId, ex }); throw; } } }
// Token: 0x0600003D RID: 61 RVA: 0x00002F64 File Offset: 0x00001164 protected virtual void CreateMigrationBatch(MailboxId migrationMailbox, byte[] csvFile) { for (int i = 0; i < 3; i++) { try { using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(base.Context, base.Context.ApplicationName)) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("New-MigrationBatch"); pscommand.AddParameter("XO1", true); pscommand.AddParameter("CSVData", csvFile); pscommand.AddParameter("Partition", migrationMailbox); anchorRunspaceProxy.RunPSCommand <PSObject>(pscommand); } base.Context.Logger.Log(MigrationEventType.Information, "Successfully created new migration batch against {0}", new object[] { migrationMailbox }); break; } catch (InvalidRunspaceStateException ex) { base.Context.Logger.Log(MigrationEventType.Error, "PS Runspace was closed so command could not be run : {0}", new object[] { ex }); } } }
private void RunPSCommandForOrgOrUser(PSCommand cmd) { using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers")) { try { anchorRunspaceProxy.RunPSCommand <PSObject>(cmd); } catch (MigrationPermanentException ex) { this.Context.Logger.Log(MigrationEventType.Error, "Run cmd {0} failed due to {1}", new object[] { cmd.ToString(), ex }); throw; } } }
List <TenantOrganizationPresentationObjectWrapper> IOrganizationOperation.GetAllOrganizations(bool checkAllPartitions) { List <TenantOrganizationPresentationObjectWrapper> result; using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers")) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("Get-AccountPartition"); Collection <AccountPartition> collection = null; try { collection = anchorRunspaceProxy.RunPSCommand <AccountPartition>(pscommand); } catch (MigrationPermanentException ex) { this.Context.Logger.Log(MigrationEventType.Error, "Get-AccountPartition failed: {0}", new object[] { ex }); throw; } pscommand.Clear(); List <TenantOrganizationPresentationObject> list = new List <TenantOrganizationPresentationObject>(); if (collection == null || collection.Count == 0) { result = null; } else { Collection <AccountPartition> collection2 = new Collection <AccountPartition>(); if (!checkAllPartitions) { AccountPartition accountPartition = collection.FirstOrDefault((AccountPartition p) => p.IsLocalForest); if (accountPartition == null) { this.Context.Logger.Log(MigrationEventType.Information, "No LocalForest partitions found", new object[0]); return(null); } collection2.Add(accountPartition); this.Context.Logger.Log(MigrationEventType.Information, "Get-Organization will run on partition: {0} IsLocalPartition: {1}", new object[] { collection2.ElementAt(0).Name, collection2.ElementAt(0).IsLocalForest }); } else { collection2 = collection; } foreach (AccountPartition accountPartition2 in collection2) { pscommand.AddCommand("Get-Organization"); pscommand.AddParameter("AccountPartition", accountPartition2); pscommand.AddParameter("Filter", "OrganizationStatus -eq 1"); Stopwatch stopwatch = Stopwatch.StartNew(); Collection <TenantOrganizationPresentationObject> collection3 = new Collection <TenantOrganizationPresentationObject>(); try { collection3 = anchorRunspaceProxy.RunPSCommand <TenantOrganizationPresentationObject>(pscommand); this.Context.Logger.Log(MigrationEventType.Information, "Get-Organization ran for partition {0} in: {1}, found {2} orgs.", new object[] { accountPartition2.Name, stopwatch.Elapsed.TotalSeconds, collection3.Count }); } catch (MigrationPermanentException ex2) { this.Context.Logger.Log(MigrationEventType.Error, "Get-Organization failed for Partition {0} : {1}", new object[] { accountPartition2.Name, ex2 }); throw; } List <TenantOrganizationPresentationObject> collection4 = CommonUtils.RandomizeSequence <TenantOrganizationPresentationObject>(collection3.ToList <TenantOrganizationPresentationObject>()); list.AddRange(collection4); } List <TenantOrganizationPresentationObjectWrapper> list2 = new List <TenantOrganizationPresentationObjectWrapper>(); foreach (TenantOrganizationPresentationObject tenant in list) { list2.Add(new TenantOrganizationPresentationObjectWrapper(tenant)); } result = list2; } } return(result); }
void IOrganizationOperation.CreateAnchorMailbox(string tenantId) { using (AnchorRunspaceProxy anchorRunspaceProxy = AnchorRunspaceProxy.CreateRunspaceForDatacenterAdmin(this.Context, "upgradehandlers")) { PSCommand pscommand = new PSCommand(); pscommand.AddCommand("New-Mailbox"); pscommand.AddParameter("Arbitration"); pscommand.AddParameter("Organization", tenantId); pscommand.AddParameter("Name", "Migration.8f3e7716-2011-43e4-96b1-aba62d229136"); pscommand.AddParameter("DisplayName", "Microsoft Exchange Migration"); pscommand.AddParameter("UserPrincipalName", "Migration.8f3e7716-2011-43e4-96b1-aba62d229136@" + tenantId); pscommand.AddParameter("OverrideRecipientQuotas"); Mailbox mailbox; try { mailbox = anchorRunspaceProxy.RunPSCommandSingleOrDefault <Mailbox>(pscommand); } catch (MigrationPermanentException ex) { this.Context.Logger.Log(MigrationEventType.Error, "Unable to create Migration Mailbox for organization '{0}': {1}", new object[] { tenantId, ex }); throw; } pscommand = new PSCommand(); pscommand.AddCommand("Set-Mailbox"); pscommand.AddParameter("Identity", mailbox.Identity); pscommand.AddParameter("Arbitration"); pscommand.AddParameter("ProhibitSendReceiveQuota", "10GB"); pscommand.AddParameter("ProhibitSendQuota", "10GB"); pscommand.AddParameter("IssueWarningQuota", "9GB"); pscommand.AddParameter("RecoverableItemsQuota", "30GB"); pscommand.AddParameter("RecoverableItemsWarningQuota", "20GB"); pscommand.AddParameter("UseDatabaseQuotaDefaults", false); pscommand.AddParameter("SCLDeleteEnabled", false); pscommand.AddParameter("SCLJunkEnabled", false); pscommand.AddParameter("SCLQuarantineEnabled", false); pscommand.AddParameter("SCLRejectEnabled", false); pscommand.AddParameter("HiddenFromAddressListsEnabled", true); pscommand.AddParameter("Management", true); pscommand.AddParameter("Force"); pscommand.AddParameter("TenantUpgrade", true); int config = this.Context.Config.GetConfig <int>("NumberOfSetMailboxAttempts"); int config2 = this.Context.Config.GetConfig <int>("SetMailboxAttemptIntervalSeconds"); for (int i = 1; i <= config; i++) { try { anchorRunspaceProxy.RunPSCommand <Mailbox>(pscommand); break; } catch (MigrationPermanentException ex2) { this.Context.Logger.Log(MigrationEventType.Warning, "Unable to set defaults for anchor Mailbox for organization '{0}' after {1} attempt(s): {2}", new object[] { config, tenantId, ex2 }); if (i >= config) { this.Context.Logger.Log(MigrationEventType.Error, "Gving up attempts to set defaults for anchor Mailbox for organization '{0}': {1}", new object[] { tenantId, ex2 }); throw; } Thread.Sleep(config2 * 1000); } } } }