Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #Get all the virtual machines from hyperV
  2. #And store them into an object
  3. $virt_mach = Get-VM
  4. #Try with one specific VM
  5. #..You need to start it before
  6. Start-VM -VM $virt_mach[0]
  7. #To Access to a specific Vm with credentials
  8. #You need ti define credentials like this (or with the get-credentials cmdlet)
  9. $user = "DOMAINmyuser1"
  10. $password = ConvertTo-SecureString "SuperPasswordSoHaRdToFIND" -AsPlainText -Force
  11. $creds = New-Object System.Management.Automation.PSCredential ($user,$password)
  12. #connect to the first VM of the list
  13. Enter-PSSession -VMName $virt_mach[0].Name -Credential $creds
  14. #and then write commandy you need to into the virtual machine
  15. #in here..
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement