public override void ExecuteCmdlet() { string decodedPassword = SecureStringExtensions.ConvertToString(Password); var userCreateparameters = new UserCreateParameters { AccountEnabled = true, DisplayName = DisplayName, MailNickname = MailNickname, PasswordProfile = new PasswordProfile { Password = decodedPassword, ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false }, UserPrincipalName = UserPrincipalName }; if (this.IsParameterBound(c => c.ImmutableId)) { userCreateparameters.ImmutableId = ImmutableId; } ExecutionBlock(() => { if (ShouldProcess(target: UserPrincipalName, action: string.Format("Adding a new user with UPN '{0}'", UserPrincipalName))) { WriteObject(ActiveDirectoryClient.CreateUser(userCreateparameters)); } }); }
public override void ExecuteCmdlet() { var userCreateparameters = new UserCreateParameters { AccountEnabled = true, DisplayName = DisplayName, PasswordProfile = new PasswordProfile { #pragma warning disable 0618 Password = Password, #pragma warning restore 0618 ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false }, UserPrincipalName = UserPrincipalName }; if (!string.IsNullOrEmpty(ImmutableId)) { userCreateparameters.ImmutableId = ImmutableId; } ExecutionBlock(() => { if (ShouldProcess(target: UserPrincipalName, action: string.Format("Adding a new user with UPN '{0}'", UserPrincipalName))) { WriteObject(ActiveDirectoryClient.CreateUser(userCreateparameters)); } }); }