PowerCLI: Scriptkit

From VI-Toolkit
Revision as of 10:23, 6 March 2014 by Wila (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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