1. Install the system patch of power shell V2.0 on the client. The patch number is KB968930, which includes winrm and powershell 2.0.
2. Set the view connection server to a trusted host of winrm:
Ps c: \ set-item wsman: \ localhost \ Client \ TrustedHosts-value 'IP'
3. Create a connection and assign it to the variable:
Ps c: \> $ remote = new-pssession-computername 'IP'-credential administrator
4. view the module of the view connection server:
Ps c: \> Invoke-Command $ remote {get-pssnapin}
5. Add the Vmware view module to the power shell:
Ps c: \> Invoke-Command $ remote {add-pssnapin vmware. view. broker}
6. Add the user to the authorization list of the pool:
Ps c: \> Invoke-Command $ remote {get-user-name 'username' | add-poolEntitlement-pool_id 'poolid'
7. Delete the user from the pool authorization list:
Ps c: \> Invoke-Command $ remote {get-user-name 'username' | remove-poolEntitlement-pool_id 'poolid'
8. Delete the connection MPs queue from the remote server.
Ps c: \> remove-pssession $ remote
-------------------------------------------------------------------------------
To save the password to a file, use the following method:
1. Save the entered password to the file:
Ps c: \> read-host-assecurestring | convertfrom-securestring | out-file C: \ pass.txt
2. Retrieve password:
Ps c :\> $ password = get-content C: \ pass.txt | converconverter-securestring
3. Create a credential object:
Ps c: \> $ credentials = new-object-typename System. Management. Automation. PSCredential-argumentlist "myusername", $ password
This article is from the "Memorandum" blog