VI Toolkit/ PowerShell for VMware

Post on 22-Feb-2016

62 views 2 download

description

VI Toolkit/ PowerShell for VMware. Randy Snyder. Microsoft PowerShell. Command line shell and scripting language Download Windows PowerShell 1.0 and install http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx Open a command prompt . - PowerPoint PPT Presentation

Transcript of VI Toolkit/ PowerShell for VMware

VI Toolkit/PowerShell for VMware

Randy Snyder

Microsoft PowerShell

Command line shell and scripting languageDownload Windows PowerShell 1.0 and install http://www.microsoft.com/windowsserver2003/

technologies/management/powershell/default.mspx

Open a command prompt

Microsoft PowerShell

Next steps

Get-HelpCan use tabbing to finish commandsCommands like ls, pwd, dir etc… work Files are saved as a .PS1Not only for Windows, (VMware, Quest, F5, Full

Armor etc..)

Microsoft PowerShell

Get-Help “command” -detailed

Getting Started

What can I do?

PowerGUI

Connecting

Viewing information

Viewing the Source

The Problem

• Need to get data from a number of servers• Data is not in a script that I could find• Field is not somewhere I would normally look

Finding Data

Get-VM vm_name | get-view | format-custom >c:\out.txt  Summary =     class VirtualMachineSummary    {      Vm =         class ManagedObjectReference        {          Type = VirtualMachine          Value = vm-149535        }

($vm | get-view) | get-member

($vm | get-view).summary | get-member

($vm | get-view).summary.vm | get-member

($vm | get-view).summary.vm

Writing the Script

Step 1 Connect

#Set variables $vcserver = “insert VC Server Name“#Connect to VC$VC = Connect-VIServer $VCServer

Loop the command

#Tell it to loop through the namesforeach ($object in $vmname){

#Provide the command to increase the RAM $vm = Get-VM $object ($vm | Get-View).summary.vm.value + " " +

$vm.name

}

Results

Vmotion IP’s