public override void ExecuteCmdlet()
        {
            PasswordProfile profile = null;

#pragma warning disable 0618
            if (!string.IsNullOrEmpty(Password))
#pragma warning restore 0618
            {
                profile = new PasswordProfile
                {
#pragma warning disable 0618
                    Password = Password,
#pragma warning restore 0618
                    ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false
                };
            }

            var userUpdateParameters = new UserUpdateParameters(EnableAccount, DisplayName, profile);

            ExecutionBlock(() =>
            {
                if (ShouldProcess(target: UPNOrObjectId, action: string.Format("Updating properties for user with upn or object id '{0}'", UPNOrObjectId)))
                {
                    WriteObject(ActiveDirectoryClient.UpdateUser(UPNOrObjectId, userUpdateParameters));
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            PasswordProfile profile = null;

            if (Password != null && Password.Length > 0)
            {
                string decodedPassword = SecureStringExtensions.ConvertToString(Password);
                profile = new PasswordProfile
                {
                    Password = decodedPassword,
                    ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false
                };
            }

            var userUpdateParameters = new UserUpdateParameters
            {
                AccountEnabled  = EnableAccount,
                DisplayName     = DisplayName,
                PasswordProfile = profile
            };

            ExecutionBlock(() =>
            {
                if (this.IsParameterBound(c => c.InputObject))
                {
                    UPNOrObjectId = !string.IsNullOrEmpty(InputObject.UserPrincipalName) ?
                                    InputObject.UserPrincipalName :
                                    InputObject.Id.ToString();
                }
                else if (this.IsParameterBound(c => c.UserPrincipalName))
                {
                    UPNOrObjectId = UserPrincipalName;
                }
                else if (this.IsParameterBound(c => c.ObjectId))
                {
                    UPNOrObjectId = ObjectId;
                }

                if (ShouldProcess(target: UPNOrObjectId, action: string.Format("Updating properties for user with upn or object id '{0}'", UPNOrObjectId)))
                {
                    WriteObject(ActiveDirectoryClient.UpdateUser(UPNOrObjectId, userUpdateParameters));
                }
            });
        }
Exemplo n.º 3
0
        public override void ExecuteCmdlet()
        {
            PasswordProfile profile = null;

            if (Password != null && Password.Length > 0)
            {
                string decodedPassword = SecureStringExtensions.ConvertToString(Password);
                profile = new PasswordProfile
                {
                    Password = decodedPassword,
                    ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false
                };
            }

            var userUpdateParameters = new UserUpdateParameters(EnableAccount, DisplayName, profile);

            ExecutionBlock(() =>
            {
                if (ShouldProcess(target: UPNOrObjectId, action: string.Format("Updating properties for user with upn or object id '{0}'", UPNOrObjectId)))
                {
                    WriteObject(ActiveDirectoryClient.UpdateUser(UPNOrObjectId, userUpdateParameters));
                }
            });
        }