/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerUser newUser; string country; CustomerId.AssertNotEmpty(nameof(CustomerId)); if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.NewPartnerCustomerUserWhatIf, UserPrincipalName))) { country = (string.IsNullOrEmpty(UsageLocation)) ? PartnerSession.Instance.Context.CountryCode : UsageLocation; string stringPassword = SecureStringExtensions.ConvertToString(Password); newUser = new CustomerUser { PasswordProfile = new PasswordProfile() { ForceChangePassword = ForceChangePassword.IsPresent, Password = stringPassword }, DisplayName = DisplayName, FirstName = FirstName, LastName = LastName, UsageLocation = country, UserPrincipalName = UserPrincipalName }; CustomerUser createdUser = Partner.Customers[CustomerId].Users.CreateAsync(newUser).GetAwaiter().GetResult(); WriteObject(new PSCustomerUser(createdUser)); } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerId.AssertNotEmpty(nameof(CustomerId)); UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers[UserId].DeleteAsync().ConfigureAwait(false).GetAwaiter().GetResult(); WriteObject(true); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { if (!ShouldProcess(Resources.SetPartnerCustomerConfigurationPolicyWhatIf, PolicyId)) { return; } List <PolicySettingsType> policySettings = new List <PolicySettingsType>(); if (OobeUserNotLocalAdmin) { policySettings.Add(PolicySettingsType.OobeUserNotLocalAdmin); } if (SkipEula) { policySettings.Add(PolicySettingsType.SkipEula); } if (SkipExpressSettings) { policySettings.Add(PolicySettingsType.SkipExpressSettings); } if (RemoveOemPreinstalls) { policySettings.Add(PolicySettingsType.RemoveOemPreinstalls); } if (SkipOemRegistration) { policySettings.Add(PolicySettingsType.SkipOemRegistration); } ConfigurationPolicy configurationPolicy = GetCustomerPolicy(CustomerId, PolicyId); if (!string.IsNullOrEmpty(Name)) { configurationPolicy.Name = Name; } if (!string.IsNullOrEmpty(Description)) { configurationPolicy.Description = Description; } configurationPolicy.PolicySettings = policySettings; ConfigurationPolicy devicePolicy; CustomerId.AssertNotEmpty(nameof(CustomerId)); try { devicePolicy = Partner.Customers[CustomerId].ConfigurationPolicies[PolicyId].Patch(configurationPolicy); WriteObject(new PSConfigurationPolicy(devicePolicy)); } finally { devicePolicy = null; } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { if (!ShouldProcess(Resources.NewPartnerCustomerConfigurationPolicyWhatIf)) { return; } List <PolicySettingsType> policySettings = new List <PolicySettingsType>(); if (OobeUserNotLocalAdmin) { policySettings.Add(PolicySettingsType.OobeUserNotLocalAdmin); } if (SkipEula) { policySettings.Add(PolicySettingsType.SkipEula); } if (SkipExpressSettings) { policySettings.Add(PolicySettingsType.SkipExpressSettings); } if (RemoveOemPreinstalls) { policySettings.Add(PolicySettingsType.RemoveOemPreinstalls); } if (SkipOemRegistration) { policySettings.Add(PolicySettingsType.SkipOemRegistration); } ConfigurationPolicy configurationPolicy = new ConfigurationPolicy { Name = Name, Description = Description, PolicySettings = policySettings }; ConfigurationPolicy devicePolicy; CustomerId.AssertNotEmpty(nameof(CustomerId)); try { devicePolicy = Partner.Customers[CustomerId].ConfigurationPolicies.Create(configurationPolicy); WriteObject(new PSConfigurationPolicy(devicePolicy)); } finally { devicePolicy = null; } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerId.AssertNotEmpty(nameof(CustomerId)); UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); try { Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers[UserId].Delete(); WriteObject(true); } catch (PSPartnerException ex) { throw new PSPartnerException("Error removing user " + UserId + "from role " + RoleId, ex); } }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { CustomerUser newUser; string country; CustomerId.AssertNotEmpty(nameof(CustomerId)); try { if (ShouldProcess(string.Format(CultureInfo.CurrentCulture, Resources.NewPartnerCustomerUserWhatIf, UserPrincipalName))) { country = (string.IsNullOrEmpty(UsageLocation)) ? PartnerProfile.Instance.Context.CountryCode : UsageLocation; string stringPassword = SecureStringExtensions.ConvertToString(Password); newUser = new CustomerUser { PasswordProfile = new PasswordProfile() { ForceChangePassword = ForceChangePassword.IsPresent, Password = stringPassword }, DisplayName = DisplayName, FirstName = FirstName, LastName = LastName, UsageLocation = country, UserPrincipalName = UserPrincipalName }; CustomerUser createdUser = Partner.Customers[CustomerId].Users.Create(newUser); WriteObject(new PSCustomerUser(createdUser)); } } catch (PSPartnerException ex) { throw new PSPartnerException("Error creating user:" + UserPrincipalName, ex); } finally { newUser = null; country = null; } }