Difference between revisions of "PowerCLI: Scriptkit"

From VI-Toolkit
Jump to: navigation, search
(Created page with "=== ScriptKit === author: Rynardt Spies ==== Description ==== Rynardt has started working with Powershell and PowerCLI and as a seasoned C++ developer he's already being pret...")
 
 
Line 2: Line 2:
 
author: Rynardt Spies
 
author: Rynardt Spies
 
==== Description ====
 
==== Description ====
Rynardt has started working with Powershell and PowerCLI and as a seasoned C++ developer he's already being pretty productive with this. He has been kind enough to start sharing his work in a library that he calls "ScriptKit".
+
Rynardt has started working with Powershell and PowerCLI and as a seasoned C++ developer he's already being pretty productive with this.  
 +
 
 +
He has been kind enough to start sharing his work in a library that he calls "ScriptKit".
 +
 
 
You are welcome to send him scripts to add to the library so that it becomes an easy bases to start looking for scripts for more people.
 
You are welcome to send him scripts to add to the library so that it becomes an easy bases to start looking for scripts for more people.
  
Line 10: Line 13:
 
   create_vmotion_vmk.ps1
 
   create_vmotion_vmk.ps1
 
Creates up to two vMotion interfaces and configures them with details specified in a CSV file. For a single interface, comment out the entire vmk2 section.
 
Creates up to two vMotion interfaces and configures them with details specified in a CSV file. For a single interface, comment out the entire vmk2 section.
 +
 
   host_auth_addto_ad_domain.ps1
 
   host_auth_addto_ad_domain.ps1
 
Add hosts in cluster to a specified AD Domain.
 
Add hosts in cluster to a specified AD Domain.
 +
 
   set_vm_max_console_sessions.ps1
 
   set_vm_max_console_sessions.ps1
 
This script is used to set the maximum remote console sessions allowed on all virtual machines found in the servers.txt file. This is required by many financial industry to prevent more than one concurrent remote console session to a virtual machine in order to an administrator of a VM being shadowed remotely.
 
This script is used to set the maximum remote console sessions allowed on all virtual machines found in the servers.txt file. This is required by many financial industry to prevent more than one concurrent remote console session to a virtual machine in order to an administrator of a VM being shadowed remotely.
 +
 
   set_vmhost_shell_timeout.ps1
 
   set_vmhost_shell_timeout.ps1
 
Set the ShellTimeOut Setting for all hosts in the specified cluster(s) and restarts the ESXiShell Service. Changes require the SSHShell TSM service to be restarted
 
Set the ShellTimeOut Setting for all hosts in the specified cluster(s) and restarts the ESXiShell Service. Changes require the SSHShell TSM service to be restarted
 +
 
   set_vmk_mtu.ps1
 
   set_vmk_mtu.ps1
 
Updates the MTU size for specified VMKERNEL virtual nics (vmk0, vmk1, vmk2, etc.)
 
Updates the MTU size for specified VMKERNEL virtual nics (vmk0, vmk1, vmk2, etc.)
Line 24: Line 31:
 
Run this script on the View Connection Server
 
Run this script on the View Connection Server
 
===== Reporting =====
 
===== Reporting =====
 +
 
   report_HBAConfig.ps1
 
   report_HBAConfig.ps1
 
Report on the HBA Link Speed, HBA Queue Depth, HBA Topology of each ESXi host.
 
Report on the HBA Link Speed, HBA Queue Depth, HBA Topology of each ESXi host.
 +
 
   report_MgmtvMotionIPs.ps1
 
   report_MgmtvMotionIPs.ps1
 
Report on the Management and vMotion IP Addresses (vmk)
 
Report on the Management and vMotion IP Addresses (vmk)
 +
 
   report_ShellTimeOut.ps1
 
   report_ShellTimeOut.ps1
 
Report on the ShellTimeOut Setting for all hosts in specified clusters/DC objects
 
Report on the ShellTimeOut Setting for all hosts in specified clusters/DC objects
 +
 
   report_datastore_space.ps1
 
   report_datastore_space.ps1
 
Script to return all datastores seen in vCenter as well as their capacity, used space and free space.
 
Script to return all datastores seen in vCenter as well as their capacity, used space and free space.
 +
 
   report_host_wwn.ps1
 
   report_host_wwn.ps1
 
Report WWN Numbers for hosts specified in $clusters
 
Report WWN Numbers for hosts specified in $clusters
 +
 
   report_netConf_CDP.ps1
 
   report_netConf_CDP.ps1
 
Report the current port group configuration as well as the discovered CDP information.
 
Report the current port group configuration as well as the discovered CDP information.
  
 
Handy for comparing actual portgroup config with physical upstream switch config
 
Handy for comparing actual portgroup config with physical upstream switch config
 +
 
   report_ntp_syslog.ps1
 
   report_ntp_syslog.ps1
 
Report the configured NTP Servers as well as the Configured Syslog server
 
Report the configured NTP Servers as well as the Configured Syslog server
 +
 
   report_vm_attached_media.ps1
 
   report_vm_attached_media.ps1
 
Return all CD and Floppy Devices for each VM, including connection state
 
Return all CD and Floppy Devices for each VM, including connection state
 +
 
   report_vm_list.ps1
 
   report_vm_list.ps1
 
Reports the Name, vCenter, Datacenter, Cluster, Host and Folder for every virtual machine visible within the PowerCLI session. Also works when connected to multiple VI servers.
 
Reports the Name, vCenter, Datacenter, Cluster, Host and Folder for every virtual machine visible within the PowerCLI session. Also works when connected to multiple VI servers.
Line 49: Line 65:
 
Helpful in large environments with many vCenter servers.
 
Helpful in large environments with many vCenter servers.
 
==== Usage ====
 
==== Usage ====
 +
Change the variables at the start of the script, you can easily identify them as they start with $
 +
 +
For example, in the Horizon View script you would change
 +
 +
# Name of the Security Server
 +
$SecurityServer = "VIEWSecurityServerNameHere"
 +
and for the log:
 +
 +
$LogFile = "C:\Temp\set_viewSecurity_extIP.log"
 +
  
 
==== Location ====
 
==== Location ====
 
Rynardt's blog article introducing the scriptkit and asking for help.
 
Rynardt's blog article introducing the scriptkit and asking for help.
 +
 
http://www.virtualvcp.com/news/197-contribute-to-my-powercli-script-repository-and-help-the-community
 
http://www.virtualvcp.com/news/197-contribute-to-my-powercli-script-repository-and-help-the-community
  
 
Repository:
 
Repository:
 +
 
https://github.com/rynardtspies/ScriptKit
 
https://github.com/rynardtspies/ScriptKit
  
  
 
[[Category: PowerCLI]] [[Category: Powershell]]
 
[[Category: PowerCLI]] [[Category: Powershell]]

Latest revision as of 10:23, 6 March 2014

ScriptKit

author: Rynardt Spies

Description

Rynardt has started working with Powershell and PowerCLI and as a seasoned C++ developer he's already being pretty productive with this.

He has been kind enough to start sharing his work in a library that he calls "ScriptKit".

You are welcome to send him scripts to add to the library so that it becomes an easy bases to start looking for scripts for more people.

Currently he has divided up his library in the following two categories, at the time of writing it already contains the following scripts.

Configuring
 create_vmotion_vmk.ps1 	

Creates up to two vMotion interfaces and configures them with details specified in a CSV file. For a single interface, comment out the entire vmk2 section.

 host_auth_addto_ad_domain.ps1 	

Add hosts in cluster to a specified AD Domain.

 set_vm_max_console_sessions.ps1 	

This script is used to set the maximum remote console sessions allowed on all virtual machines found in the servers.txt file. This is required by many financial industry to prevent more than one concurrent remote console session to a virtual machine in order to an administrator of a VM being shadowed remotely.

 set_vmhost_shell_timeout.ps1 	

Set the ShellTimeOut Setting for all hosts in the specified cluster(s) and restarts the ESXiShell Service. Changes require the SSHShell TSM service to be restarted

 set_vmk_mtu.ps1 	

Updates the MTU size for specified VMKERNEL virtual nics (vmk0, vmk1, vmk2, etc.)

Horizon View
      set_viewSecurity_extIP.ps1

Updates the External IP address refernece in VMware Horizon View to match the current public IP address of the security server.

Run this script on the View Connection Server

Reporting
 report_HBAConfig.ps1 	

Report on the HBA Link Speed, HBA Queue Depth, HBA Topology of each ESXi host.

 report_MgmtvMotionIPs.ps1 	

Report on the Management and vMotion IP Addresses (vmk)

 report_ShellTimeOut.ps1 	

Report on the ShellTimeOut Setting for all hosts in specified clusters/DC objects

 report_datastore_space.ps1 	

Script to return all datastores seen in vCenter as well as their capacity, used space and free space.

 report_host_wwn.ps1 	

Report WWN Numbers for hosts specified in $clusters

 report_netConf_CDP.ps1 	

Report the current port group configuration as well as the discovered CDP information.

Handy for comparing actual portgroup config with physical upstream switch config

 report_ntp_syslog.ps1 	

Report the configured NTP Servers as well as the Configured Syslog server

 report_vm_attached_media.ps1 	

Return all CD and Floppy Devices for each VM, including connection state

 report_vm_list.ps1

Reports the Name, vCenter, Datacenter, Cluster, Host and Folder for every virtual machine visible within the PowerCLI session. Also works when connected to multiple VI servers.

Output is saved to a CSV file as specified in $ReportFile

Helpful in large environments with many vCenter servers.

Usage

Change the variables at the start of the script, you can easily identify them as they start with $

For example, in the Horizon View script you would change

# Name of the Security Server
$SecurityServer = "VIEWSecurityServerNameHere"

and for the log:

$LogFile = "C:\Temp\set_viewSecurity_extIP.log"


Location

Rynardt's blog article introducing the scriptkit and asking for help.

http://www.virtualvcp.com/news/197-contribute-to-my-powercli-script-repository-and-help-the-community

Repository:

https://github.com/rynardtspies/ScriptKit