How to change a user account non-root on multiple esx hosts 4

We currently use the script below to change the root password, but we need a to change a non-root user account that does not have access to the root of how.

So if the script could be changed to connect to each server with root and then change the password of the root no account that might be useful.

Any help would be appreciated.

-Steve

#
# This script changes the password to root on all ESX host in the esxservers.txt text file
#

# Add toolkit-VI #.
Add-PSsnapin VMware.VimAutomation.Core
Initialize - VIToolkitEnvironment.ps1

# Get old credential root
$oldrootPassword = "Enter the old root password" Read-Host - AsSecureString
$oldrootCredential = new-object - typename System.Management.Automation.PSCredential - argumentlist 'root', $oldrootPassword

# New information for the identification of root
$newrootPassword = "Enter the new root password" Read-Host - AsSecureString
$newrootCredential = new-object - typename System.Management.Automation.PSCredential - argumentlist 'root', $newrootPassword
$newrootPassword2 = Read-Host "Retype new root password" - AsSecureString
$newrootCredential2 = new-object - typename System.Management.Automation.PSCredential - argumentlist 'root', $newrootPassword2
$WarningPreference = "SilentlyContinue".

# Compare passwords
If ($newrootCredential.GetNetworkCredential ().) Password - ceq $newrootCredential2.GetNetworkCredential (). {Password)

# Create the new object of root account
$rootaccount = new-Object VMware.Vim.HostPosixAccountSpec
$rootaccount.id = 'root '.
$rootaccount.password = $newrootCredential.GetNetworkCredential (). Password
$rootaccount.shellAccess = ' / bin/bash ".

# The list of text file host servers to change the root password on
Get-Content esxservers.txt | %{
SE connect-VIServer $_-user root - password $oldrootCredential.GetNetworkCredential (). Password - ErrorAction SilentlyContinue - ErrorVariable ConnectError. Out-Null
If ($ConnectError - not $Null) {}
Write-Host "ERROR: unable to connect to the ESX Server: ' $_
}
Else {}
$si = get-view ServiceInstance
$acctMgr = get-view-Id $si.content.accountManager
$acctMgr.UpdateUser ($rootaccount)
Write-Host "Root password changed successfully on ' $_
Disconnect-VIServer-confirm: $False | Out-Null
}
}
}
Else {}
Write-Host "ERROR: new root passwords do not match." Smooth... »
}

Try something like that.

First, it prompts you for the password for root servers ESX (i).

And then the account name, followed by the 2 times the new password

#
# This script changes the password of an account on all ESX hosts in the esxservers.txt textfile#
 # Add VI-toolkit # Add-PSsnapin VMware.VimAutomation.CoreInitialize-VIToolkitEnvironment.ps1

# Get root password$rootPassword = Read-Host "Enter root password" -AsSecureString$rootCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist "root",$rootPassword
# Get account to change$account = Read-Host "Enter account"# Get new account credential$newaccountPassword = Read-Host "Enter new password" -AsSecureString$newaccountCredential = new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$newaccountPassword$newaccountPassword2 = Read-Host "Retype new password" -AsSecureString$newaccountCredential2 = new-object -typename System.Management.Automation.PSCredential -argumentlist $account,$newaccountPassword2$WarningPreference = "SilentlyContinue"
# Compare passwordsIf ($newaccountCredential.GetNetworkCredential().Password -ceq $newaccountCredential2.GetNetworkCredential().Password) {

    # Create new root account object    $accountSpec = New-Object VMware.Vim.HostPosixAccountSpec    $accountSpec.id = $account    $accountSpec.password = $newaccountCredential.GetNetworkCredential().Password
    $accountSpec.shellAccess = "/bin/bash"
    # Get list of Host servers from textfile to change account password on    Get-Content esxservers.txt | %{
        Connect-VIServer $_ -User root -Password $rootCredential.GetNetworkCredential().Password -ErrorAction SilentlyContinue -ErrorVariable ConnectError | Out-Null        If ($ConnectError -ne $Null) {
            Write-Host "ERROR: Failed to connect to ESX server:" $_        }
        Else {
            $si = Get-View ServiceInstance            $acctMgr = Get-View -Id $si.content.accountManager
            $acctMgr.UpdateUser($accountSpec)
            Write-Host "$account password successfully changed on" $_            Disconnect-VIServer -Confirm:$False | Out-Null        }
    }
}
Else {
Write-Host "ERROR: New $account passwords do not match. Exiting..."}

Tags: VMware

Similar Questions

  • How can I disable the popup control in the user account that appears on my desktop to allow or reject the changes when I open a program without changing my user account settings.

    Original title: uac

    How can I disable the popup control in the user account that appears on my desktop to allow or reject the changes when I open a program without changing my user account settings.

    You want should not do that. These pop-up UAC is there to ensure the interaction of the user before executing a command or program. Disabling, allows even unwanted programs (= malware, viruses, Trojans) go ahead and implement themselves on your system without being noticed.

  • How can I change the user account control?

    How can I change my user account control.  Admin password!  My ex-wife had an and changed.  She no longer lives with me.  She gave me a password, but it does not work. I tried "several times".  I'm frustrated and I get updates from Adobe, etc. and here to keep my computer up to date with new things.  Please help me change my user account.  Thank you.

    Hello

     
    Check out the link and follow the steps.
     
    HOW to: Enable the build-in the administrator account in Windows Vista
     
    To create a new user account, you must have at least one administrator account. Microsoft has a password policy, I suggest that visit you the link.
    Microsoft's strategy concerning lost or forgotten passwords
    http://support.Microsoft.com/kb/189126
  • How to change the user name in windows 7 Professional?

    I recently installed windows 7 Professional and by chance I typed my user name and the computer when it prompted me to type it in. When I had typed the wrong characters in and click on 'Next', he wouldn't let me go back and change it, so I was stuck with an unwanted user/computer name. I managed to change the name of the computer for the word you want, but I didn't always know how to change my username.

    I went to user accounts, and there was an option to change the name of the account, so I did.
    However, none of my directories has changed its name, and all processes in the Task Manager were still running under the same previous user name, which I did not want it to be.

    Is there a way to change the username of an account so it affects all the directories, files, folders, etc. without creating a new account with that name? Or, if possible, copy all the files and preferences of the current account to another account with this name?

    Any help is appreciated.

    You cannot change a user account by changing just the name. Simply by changing the name will do a cosmetic change only and does not affect the underlying files/folders in the profile.

    1. from an account with administrator privileges, go to control panel > user accounts and to create the new user account named Standard the way you want to and at least one additional administrator account. Call the last 'CompAdmin' or 'Tech' or similar.
    2 log in to the new Standard user account once if the profile of the files/folders are created and then connect to CompAdmin.
    3. now go to control panel > system > advanced > user profile > settings
    4. you will see where you can copy user accounts. Copy the old account to the new from there. Use her browse to select your new account (C:\Users\newaccount).
    5 log in to the new account correctly named and make sure all your stuff is here and it works as you want. When you are satisfied, you can log on and CompAdmin and remove the old account from the control panel > user accounts.

    If you want to access your account again, it is corrected automatically, follow these steps:

    Start Orb > Search box > type: netplwiz [Enter]
    Click continue (or provide an administrator password) when you are prompted by UAC

    Uncheck "users must enter a user name and password to use this computer". Select a user account to connect automatically by clicking on the account you want to highlight and press OK. Enter the password for this user account (when it exists) when you are prompted. Leave blank if there is no password (null).

    General recommendations for the establishment of user accounts

    You absolutely don't want to have only one user account. Like XP, Vista and all the other modern operating systems, Windows 7 is an OS multi-user with integrated system of accounts such as administrator, by default, all users invited. These accounts should be left alone because they are part of the structure of the operating system.

    In particular, you do not want account only one user with administrative privileges on Windows 7 because the administrator account integrated (normally only used in emergencies) is disabled by default. If you use as an administrator for your daily work, and this account is corrupt, things will be difficult. It is not impossible to activate the built-in administrator to rescue things, but it will take third-party tools and work outside the operating system.

    The user account that is for your daily work must be a Standard user, with the extra administrative user (call it something like 'CompAdmin' or 'Tech' or similar) only it for elevation purposes. After you have created "CompAdmin", connect to it and change your normal user account Standard. Then log on to your regular account.

    If you want to go directly to the desktop and ignore the Welcome screen with the icons of the user accounts, you can do this by following the instructions written in the first part of this post.
    MS - MVP - Elephant Boy computers - don't panic!

  • How to unlock my user account. or, how to unlock a document on a read-only mode?

    How to unlock my user account. or, how to unlock a document on a read-only mode?

    Hi TerriBuckley,

    1. what operating system do you use?
    2. what happens when you try to connect to the computer?
    3. have you made changes on the computer recently?

    Method 1
    If you forgot the password of the computer, then I suggest you to see the following articles.

    What to do if you forget your Windows password
    http://Windows.Microsoft.com/en-us/Windows7/what-to-do-if-you-forget-your-Windows-password
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-to-do-if-you-forget-your-Windows-password

    The Windows password problems
    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-Windows-password-problems

    Method 2
    I suggest you try the steps from the following link to open the file or folder.

    What are the permissions?
    http://Windows.Microsoft.com/en-us/Windows7/what-are-permissions
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-are-permissions

  • Somehow, I blocked my user account (login) and I tried to help but can't find any info. How to UNLOCK the user account. Than k you

    The user has clicked on Vista, the little lock at the bottom of the START window.

    Somehow, I blocked my user account (login) and I tried to help but can't find any info. How to UNLOCK the user account. Thank you

    Hello

    Click the account icon that was locked and enter the password IF you know and otherwise:

    Try Safe Mode - several times, press F8 that you start. The Admin account there is no default password
    so unless someone has changed, you should have access there. Then Control Panel - accounts - users
    Manage another account - use this down your user account (to the lowest level) APPLY/OK
    then go back and reset it to the Admin APPLY/OK - this clearly allows corruption. Do this several times.
    Then fix the password in your usual account. Do not forget to leave your account administrator if you
    wish.

    If no joy Mode without failure:

    Try this - use the hidden administrator account to lower your user account (to the lowest level) APPLY/OK
    then go back and reset it to the Admin APPLY/OK - this clearly allows corruption. Do this several times.
    Then fix the password in your usual account. Do not forget to leave your account administrator if you
    wish.

    Make another Admin account with your password and use it to fix the others if necessary. (just for
    repair, don't use regular account, not a safety valve) always keep a spare ADMIN account.

    DO NOT LEAVE THE ENABLED LSA OR USE DAILY. If it corrupts you are toast!

    How to enable or disable the real built-in Administrator account in Vista
    http://www.Vistax64.com/tutorials/67567-administrator-account.html

    You can run the Admin account hidden from the prompt by if necessary.

    This tells you how to access the System Recovery Options and/or a Vista DVD
    http://windowshelp.Microsoft.com/Windows/en-us/help/326b756b-1601-435e-99D0-1585439470351033.mspx

    If you cannot access your old account, you can still use an Admin to migrate to another (do not forget to always
    not that an Admin account that is not used except for testing and difficulty).

    Difficulty of a corrupted user profile
    http://windowshelp.Microsoft.com/Windows/en-AU/help/769495bf-035C-4764-A538-c9b05c22001e1033.mspx

    ---------------------------------------------------------

    If necessary:

    Ophcrack is a free Windows password cracker based on rainbow tables.
    http://Ophcrack.sourceforge.NET/

    How to reset a Windows Vista - Trinity Rescue Kit method - password password reset disc - burn the ISO
    http://www.WikiHow.com/reset-a-Windows-Vista-password
    YouTube video on the use of the Trinity rescue Kit
    http://www.YouTube.com/results?search_query=Trinity+rescue+Kit&search_type=&AQ=f

    Reset your forgotten password the easy way using the Ultimate Boot CD for Windows
    http://www.howtogeek.com/HOWTO/Windows-Vista/reset-your-forgotten-password-the-easy-way-using-the-ultimate-boot-CD-for-Windows/

    Offline NT Password & Reset Editor
    http://home.eunet.no/~pnordahl/ntpasswd/

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • How to change standard user to user adminstator

    How can we change from standard user to adminstator user?

    Hi maggiezonnman,

    Thanks for posting in the Microsoft community!

    I understand that you want to change from standard user to administrator user. I will try to help you with this question.

    (1) you have any administrator account on your computer?

    I have provided the link that will help you change the account type.

    Change the type of user account
    http://Windows.Microsoft.com/en-us/Windows-Vista/change-a-users-account-type

    Let us know the status of the issue. I will be happy to provide you with the additional options that you can use to get the problem resolved.

  • How to fix the user accounts in windows 8

    How to correct the user account in windows 8 on new g7 2246nr, I put to your laptop using the Microsoft account then switched to a local account.  I found myself with i admin working the rest of my files are broken up between 3 other user accounts.  I spoke with Microsoft to try to consolidate the accounts and they used a command line in the command, but he has not done. I always work with the system, but it has problems. I reloaded the software so for 3 times. All know how to correct the problem without reload all the software again?  also, after configuring sharepoint in Office Pro Plus, he created another administrator account.  I do not think this would happen?

    Hi BJ2124,

    Although I regret the inconvenience that you had with your experience of Microsoft Windows 8, you can better receive the technical expertise you need by contacting Microsoft about the issue of multiple account creation.

    You can call Microsoft Customer Service at 1-800-642-7676
    Mon - Fri: 05:00 - 21:00; Sat - Sun: 06:00-15:00 (PST)

    As a reference, I included the link to the technical support of Microsoft Windows 8 page:

    http://support.Microsoft.com/contactus/?ws=support

    Also, here is a reference link to change logins to Microsoft for local accounts:

    Microsoft how to switch from one account to a Local account in Windows 8

    And finally, here is a quick reference to solve the problem that you encounter while using an account download troubleshooting tool from Microsoft:

    The problems of account Microsoft Windows 8 with convenience store "Microsoft accounts"

    In this forum support is available for support hardware/software HP. I will provide better supported with your hardware/software of HP. If you need help with a software which is another provider, so I can re - direct you to reference appropriate at this time.

    I hope that you can mark these messages as solved, so that you can inspire others to follow your example with success. You never know who you can inspire.

    -How can I give Kudos? | How to mark a post as solved? --------------------------------------------------------

  • How to combine 2 user accounts

    I migrated my hard drive from my PC to Mac, but now I have two user accounts on it, which is a nuisance to switch whenever I want to access the documents and pictures years. How to merge the user account PC with the news that I created on Mac? If not, how can I migrate my PC to my existing Mac user account?

    You can not merge accounts, merge them manually (move all documents from one to the other)

  • How to change the user name - peer-to-peer network

    I recently installed shareaza, is a peer-to-peer network as you know. the problem is that all of my folders have my name on it: that is to say, he will say sharedfiles/Jose/my documents. I tried to change my username on useraccount, but the name of Jose remains on everything. is there anyway I can change this? Thanks for any help

    Hello

    The fact is that the username will be created at the beginning of the installation of the OS.
    It comes to you account on the laptop.
    Each user account includes the folder my documents.
    In this case, you cannot change the user account if you have a single user profile on the laptop. The title of the user accounts, you can create additional user with different names.

    The other possibility would be to change the download source. But that you change somewhere in the program settings. Unfortunately, this program is unclear to me. In this case, I can give t you information where you will find this option.

  • How to change your Microsoft account recovery phone numbers

    Original title: microsoft account

    How to change your Microsoft account recovery phone numbers

    Hello

    Please see this link for more on this topic.

    http://Windows.Microsoft.com/en-us/Windows/account-security-password-information

  • How to remove a user account from my computer

    When setting up my computer, I added several user accounts with the same name.  How to remove a user account from my computer.

    Hi RuthGeardino,

    Thanks for posting in the Microsoft Community.

    As you try to delete the user accounts, it would be useful if you can answer this question to help you further.

    Windows operating system you are using?

    You must be logged in using an administrator account to delete other accounts.

    To remove an account user-Windows XP

    Delete a Windows 7 user account

    Note: This article also applies to Windows Vista.

    If you need further assistance, please answer and we will be happy to help you.

  • XP has changed the user accounts is now impossible to access the administrator account

    Something has gone wrong when changing my user accounts. I don't have an administrator account can create a. I can't even restore my system. It doesn't let me do anything! What to do Help!

    You use the built-in account named "Administrator"?  If so, the behavior you describe is "a feature, not a bug."

    Windows XP hidden administrator account when a user account is created (because it's a good idea not to use administrator systematically; it should be saved for emergencies).

    You access the administrator account integrated differently depending on whether you have XP Home or XP Pro.

    For XP Home:

    You must restart in Mode without failure.  Restart the computer and start typing the F8 key as soon as the initial startup process is finished.  If you see the Windows logo, you waited too long and you have to restart again.   If you do it right, you will see the white Advance Boot Options menu on black (image).  Use the up/down arrows and the Enter key to select Mode safe because your mouse does not work on this screen.  Once the computer starts in Mode safe mode, the administrator account will appear on the Welcome screen.  If you have not changed the password, the password is blank (no password).

    For XP Pro:

    Follow the signs for XP Home Edition, or in the Welcome screen, with no logged-in user, press CTRL + ALT + DELETE twice.  The 'classic' logon box will appear.  Type "Administrator" (without the quotes).  Once again, the default password is empty.

    Once you enter the administrator account, create an account with "computer administrator" privileges for occasions when you need (for example, to run the system restore or create accounts).  You can use any name you want (other than Administrator), such as MyAdmin.

  • How to set a user account to have the same settings as the administrator account

    How to configure a user account to have the same settings as the administrator account. using windows xp pro with service pack 3

    Set the "parameters of same.

    If you want that the user has administrator privileges, then all you need to do is to add the user to the group "Administrators".  To do this, right-click on 'My computer', select 'Manage' and open the "local users and groups" section.  Click on 'Groups', double click on "Administrators" and add the user to the administrator group.

    If you set 'settings' and things like wallpaper and other preferences, there isn't a way to do that easily other than to simply set these parameters.

    Hope this helps,
    JW

  • How to remove a user account on the HP 2000. I created two by mistake

    How to remove a user account on the laptop HP 2000.  I created two by mistake

    Sure...

    http://www.technoon.com/how-to-delete-user-account-in-Windows-8.html

Maybe you are looking for