vmware-powercli 用户命令管理手册

合集下载

PowerCLI命令使用方法

PowerCLI命令使用方法

PowerCLI使用方法1.通过Connect-VIServer 连接vCenter 或则主机例如:Connect-VIServer 192.168.1.20也可以同时连接多台机器例如:Connect-VIServer “192.168.1.11”, “192.168.1.12”2.连接服务器的时候会跳出对话框,需要输入用户名和密码。

输入用户和密码以后就可以连接到相应的服务器上。

3.如果每次都这样输入用户名和密码的话,对于管理员来说是比较麻烦的。

那可以通过命令来去记录用户名和密码,命令如下:$cred = Get-Credential在以上图片中出现的对话框里输入用户名和密码,就可以记录用户名和密码到文件中。

可以通过命令去查看记录的密钥信息:$Cred如下图:4.通过密钥文件进行连接服务器,命令如下:Connect-VIServer “192.168.1.11” , “192.168.1.12”–Credential $cred5.显示默认连接的服务器,命令如下:$global:DefaultVIServer6.在连接的服务器中有vCenter和主机,从连接的服务器中获得数据中心的信息;命令如下:Get-Datacenter7.通过命令来去获得数据中心虚拟机信息,命令如下:get-vm8.断开服务器的连接,命令如下:Disconnect-VIServer *命令分类1.显示清单和报告通过Get 命令来去获得结果例如:Get-VM;Get-Cluster2.部署与配置3.Maintenance and operations(维护与操作)4.Troubleshooting and Problem Resolution(问题解决)命令Demo1.显示VC的信息,命令如下:Cvi $vc2.显示所有命令的信息,命令如下Get-VICommand3.查某一个命令的信息的命令:Get-command *vmGet-VM 的使用1.Get-VM | set-vm –Description “this is a vm”2.获得集中一个虚拟机的具体信息命令:Get-vm 虚拟机名称| format-list3.可以通过设置命令来去简化查询:命令如下$vm = get-vm webCls命令清除界面的命令Get-Cluster Get-vmhost Get-vm的使用方式:通过get-cluster | get-vmhost 主机IP | get-vm 查看集中某一台主机的虚拟机的信息:通过命令导出虚拟机的信息数据,命令如下:Get-vm | Export-CSV –Path <filename.csv>通过命令调出Execl工具打开file.csv,命令如下Invoke-Item file.csv也可以通过命令导出虚拟机的某一些参数信息,如机器名,CPU个数,以及内存量,命令如下:通过命令查看虚拟机具体对象名称:CPU个数,内存,这些参数的指令名称,命令如下:Get-vm | Get-Member –MemberType property通过命令将虚拟机的信息导出为HTML的文档。

VMware脚本与命令管理手册

VMware脚本与命令管理手册

VMware脚本与命令(PowerCLI)管理手册VMware脚本与命令(PowerCLI)管理手册由于VMware是个成熟的虚拟化平台,所以它拥有几个自带的和第三方的管理选项。

图形用户界面GUI提供了直观的、概念上的管理VMware环境的方式,但这些对于大型或者重复的任务来说就略有不足。

如大量贮藏和虚拟机配置这些任务最好使用VMware脚本和命令套件。

在本期虚拟化技术手册中,我们将详细介绍VMware脚本和命令工具,如PowerShell与PowerCLI,以便有效监控VMware环境。

PowerCLI入门VMware管理任务是一项耗时和易出错的工作。

但是vSphere PowerCLI的扩展,可以帮助管理员完成一些控制工作。

本部分将探究VMware脚本工具PowerCLI的概念以及其中五个比较重要的脚本。

如何使用VMware vSphere PowerCLI?五大必备vSphere PowerCLI脚本PowerCLI使用与管理如果您刚刚开始应用PowerCLI管理VMware环境,需要学习的内容很多。

首先,最常见和最重要的cmdlets是Get-VM。

那么它该如何使用?如何设置能自动化主机服务器任务呢?要创建host profiles,PowerCLI能做些什么?这部分中,我们TecgTarget中国的特约作者Hal Rottenberg将详细介绍PowerCLI的使用与管理技巧。

掌控PowerCLI:使用Get-VM来管理虚拟机使用PowerShell与PowerCLI自动化主机服务器任务跳出框外巧解PowerShell与PowerCLI难题如何使用vSphere PowerCLI创建host profiles?在vSphere PowerCLI PowerShell界面使用host profilesPowerCLI技巧如何把VMware PowerCLI脚本功能应用到VMware SRM(Site Recovery Manager)恢复计划中?如何借助PowerCLI配置标准交换机?本部分将给出解决方法与步骤。

PowerCLI安装及使用

PowerCLI安装及使用

PowerCLI安装及使用vSphere PowerCLI试用(一):安装PowerCLIPowerCLI是VMware中的一款命令行管理工具。

一般管理VMware都使用vSphrere Client或者vSphere Web Client,vSphere PowerCLI则可以通过命令行来管理VMware vSphere主机或者是VMware vCenter。

(PowerCLI各版本下载,百度云、360云盘(提取码:46ab)),下载清单:1、VMware-PowerCLI-5.0.0-435426.exe2、VMware-PowerCLI-5.0.1-1992769.exe3、VMware-PowerCLI-5.1.0-793510.exe4、VMware-PowerCLI-5.1.0-1926866.exe5、VMware-PowerCLI-5.5.0-1295336.exe6、VMware-PowerCLI-5.5.0-1931983.exe7、VMware-PowerCLI-5.8.0-2057893.exe从官方主页上查看,目前的最新版本为5.8R1,下载VMware-PowerCLI-5.8.0-2057893.exe 后将其复制到需要安装的服务器上。

PowerCLI可以安装在vCenter上,也可以是其它服务器,这里选择第二种。

双击安装文件后开始安装,会先安装VIX和相关插件,如下图接着开始安装PowerCLI,如下图。

安装完成后,桌面上会多出两个图标,运行VMware vSphere PowerCLI在首次运行时可能会出错,如下图,使用get-executionpolicy查看状态确实为Restricted使用set-executionpolicy将属性从Restricted更改为remotesigned,如下图,完成后,将此窗口关闭再次启动后,就可以看到正常的界面了,如下图。

PowerCLI命令使用方法

PowerCLI命令使用方法

PowerCLI使用方法1.通过Connect-VIServer 连接vCenter 或则主机例如:Connect-VIServer 192.168.1.20也可以同时连接多台机器例如:Connect-VIServer “192.168.1.11”, “192.168.1.12”2.连接服务器的时候会跳出对话框,需要输入用户名和密码。

输入用户和密码以后就可以连接到相应的服务器上。

3.如果每次都这样输入用户名和密码的话,对于管理员来说是比较麻烦的。

那可以通过命令来去记录用户名和密码,命令如下:$cred = Get-Credential在以上图片中出现的对话框里输入用户名和密码,就可以记录用户名和密码到文件中。

可以通过命令去查看记录的密钥信息:$Cred如下图:4.通过密钥文件进行连接服务器,命令如下:Connect-VIServer “192.168.1.11” , “192.168.1.12”–Credential $cred5.显示默认连接的服务器,命令如下:$global:DefaultVIServer6.在连接的服务器中有vCenter和主机,从连接的服务器中获得数据中心的信息;命令如下:Get-Datacenter7.通过命令来去获得数据中心虚拟机信息,命令如下:get-vm8.断开服务器的连接,命令如下:Disconnect-VIServer *命令分类1.显示清单和报告通过Get 命令来去获得结果例如:Get-VM;Get-Cluster2.部署与配置3.Maintenance and operations(维护与操作)4.Troubleshooting and Problem Resolution(问题解决)命令Demo1.显示VC的信息,命令如下:Cvi $vc2.显示所有命令的信息,命令如下Get-VICommand3.查某一个命令的信息的命令:Get-command *vmGet-VM 的使用1.Get-VM | set-vm –Description “this is a vm”2.获得集中一个虚拟机的具体信息命令:Get-vm 虚拟机名称| format-list3.可以通过设置命令来去简化查询:命令如下$vm = get-vm webCls命令清除界面的命令Get-Cluster Get-vmhost Get-vm的使用方式:通过get-cluster | get-vmhost 主机IP | get-vm 查看集中某一台主机的虚拟机的信息:通过命令导出虚拟机的信息数据,命令如下:Get-vm | Export-CSV –Path <filename.csv>通过命令调出Execl工具打开file.csv,命令如下Invoke-Item file.csv也可以通过命令导出虚拟机的某一些参数信息,如机器名,CPU个数,以及内存量,命令如下:通过命令查看虚拟机具体对象名称:CPU个数,内存,这些参数的指令名称,命令如下:Get-vm | Get-Member –MemberType property通过命令将虚拟机的信息导出为HTML的文档。

vmware命令行

vmware命令行

vmware命令⾏VMware vSphere PowerCLI 是⼀款功能强⼤的命令⾏⼯具,可⾃动执⾏ vSphere 的各⽅⾯管理,包括主机、⽹络、存储、虚拟机、客户操作系统等等打开打开的⽅法第⼀种1.直接在ESXi控制台界⾯上按住ALT+F1也能进⼊2.把ESXi的SSH功能开开,然后⽤⼯具连接⾏了,root/password。

选择esxi主机----配置--(软件)安全配置-----(安全配置⽂件)属性---(ssh)选项打开后远程root 密码链接即可。

常⽤命令主机信息查询vmware -v 查询系统版本esxcli system version get 查询系统信息esxcli system time get 查询时间esxcli system time set -y=2016 -M=9 -d=13 -H=10 -m=9esxcli system maintenanceMode set --enable true/false 进⼊/退出维护模式esxcli system maintenanceMode get 查询维护模式esxcli system shutdown reboot/poweroff 关机/重启/断电⽹络信息查询esxcli network ip interface ipv4 get 查询ipesxcli network ip route ipv4 list 查询路由表esxcli network nic list 查询⽹卡 up/down 信息esxcli network nic down/up -n=vmnic1 关闭/打开⼀个⽹卡 -n=指定⽹卡磁盘信息esxcli storage core device list 查看磁盘列表利⽤vshpere powercli 管理vcenter安装powe rcli ( windows)安装过程:1、下载VMWare.PowerCLI Save-Module -Name VMware.PowerCLI #执⾏后,会提⽰要输⼊path,它的⽬的是询问你将powercli软件下载到哪2、安装install-module VMware.PowerCLI3、导⼊模块Import-Module VMware.VimAutomation.Core4 设置powercli的证书机制为ignore。

【转】VMwareCLI命令参考

【转】VMwareCLI命令参考

【转】VMwareCLI命令参考VMwareCLI命令参考基本命令范例123 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41vmware -v# 看你的esx版本VMware ESXi 5.0.0 build-469512esxcfg-info -a # 显⽰所有ESX相关信息esxcfg-info -w # 显⽰esx上硬件信息service mgmt-vmware restart # 重新启动vmware服务esxcfg-vmknic -l # 查看宿主机IP地址esxcli hardware cpu list # cpu信息 Brand,Core Speed,esxcli hardware cpu global get # cpu信息(CPU Cores)esxcli hardware memory get # 内存信息内存 Physical Memoryesxcli hardware platform get # 硬件型号,供应商等信息,主机型号,Product Name 供应商,Vendor Nameesxcli hardware clock get # 当前时间esxcli system version get # 查看ESXi主机版本号和build号esxcli system maintenanceMode set--enable yes# 将ESXi主机进⼊到维护模式esxcli system maintenanceMode set--enable no # 将ESXi主机退出维护模式esxcli system settings advanced list -d # 列出ESXi主机上被改动过的⾼级设定选项esxcli system settings kernel list -d # 列出ESXi主机上被变动过的kernel设定部分esxcli system snmp get | hash| set| test# 列出、测试和更改SNMP设定esxcli vm process list # 利⽤esxcli列出ESXi服务器上VMs的World I(运⾏状态的)esxcli vm process kill-t soft -w WorldI # 利⽤esxcli命令杀掉VMvim-cmd hostsvc/hostsummary# 查看宿主机摘要信息vim-cmd vmsvc/get.datastores # 查看宿主存储空间信息vim-cmd vmsvc/getallvms# 列出所有虚拟机vim-cmd vmsvc/power.getstate VMI # 查看指定VMI虚拟状态vim-cmd vmsvc/power.shutdown VMI # 关闭虚拟机vim-cmd vmsvc/power.off VMI # 如果虚拟机没有关闭,使⽤poweroff命令vim-cmd vmsvc/get.config VMI # 查看虚拟机配置信息esxcli software vib install-d /vmfs/volumes/datastore/patches/xxx.zip # 为ESXi主机安装更新补丁和驱动esxcli network nic list # 列出当前ESXi主机上所有NICs的状态esxcli network vm list # 列出虚拟机的⽹路信息esxcli storage nmp device list # 理出当前NMP管理下的设备satp和psp信息esxcli storage core device vaai status get # 列出注册到PS设备的VI状态esxcli storage nmp satp set--default-psp VMW_PSP_RR --satp xxxx # 利⽤esxcli命令将缺省psp改成Round Robinesxcli信息查询esxcli命令帮助信息ssh登录VMware ESX server控制台,⽤esxcli命令查询虚拟机信息,输出格式⽀持普通、xml、csv、keyvalue。

PowerVM常用命令手册

PowerVM常用命令手册

PowerVM常用命令手册目录目录 (1)1. 基本操作 (3)2. 创建VIOS分区 (3)3. VIOS配置 (7)3.1 创建共享以太网卡SEA(Shared Ethernet Adapter) (7)3.2 创建VSCSI虚拟磁盘 (7)3.3 NPIV配置 (12)3.4 参数调整 (16)3.5 VIO测试 (18)3.6 设置VIO Server分区自动启动 (19)4. VIOS巡检工作 (21)5. 虚拟资源的调整 (22)6. VIOS、VIOC配置实例 (25)7. WPAR技术 (32)7.1 创建Application WPAR (33)7.2 创建System WPAR (34)7.3 如何确定当前是在Global Environment中还是在WPAR中 (36)7.4如何关闭WPAR (36)7.5 如何重启WPAR (37)7.6修改WPAR的名字 (39)7.7 WPAR的状态 (39)7.8 删除WPAR (40)7.9 WPAR中的文件系统管理 (41)7.10 同步WPAR配置 (45)7.11备份、恢复、克隆WPAR (45)7.12 WPAR用户和组管理 (46)7.13 恢复WPAR中的用户口令 (46)7.14修改MPIO磁盘的hcheck_interval属性 (47)8. 存在多个VLAN ID的TCP/IP网络 (47)9. Active Memory Expansion(AME)技术 (50)10. 备份和恢复VIO Server (53)10.1 备份VIO Server (53)10.2 恢复VIO Server (55)11. 故障处理 (56)11.1 收集虚拟资源配置信息 (56)11.2更换VIO Server的SEA物理网卡 (56)12. topas性能监控 (58)1. 基本操作默认用户:padmin默认无密码默认用户环境为受限的Korn Shell切换到AIX root用户环境命令:oem_setup_env安装VIOS系统installios接受VIOS License文件命令:license -accept升级VIOS版本命令:updateios -commitupdateios -accept -install -dev /dev/cd0ioslevelshutdown -restart备份VIOS的配置:viosbr -backup -file /home/padmin/<backupfile_name>恢复VIOS的配置:viosbr -restore -file <backupfile_name>.tar.gz备份VIOS系统backupiosroot用户环境下输入VIOS配置命令:/usr/ios/cli/ioscli lsmap -all查看分区的CPU、内存配置lparstat -i2. 创建VIOS分区一个shared、uncapped Processor分区作为VIOS分区即可,在同一台服务器上可以部署多个VIOS分区,例如在网络IO和磁盘IO都很繁忙的应用环境,可以部署四个VIOS分区,其中两个VIOS负责处理Virtual Ethernet,另外两个VIOS负责处理Virtual Disk。

VMWare虚拟化管理员平台管理手册

VMWare虚拟化管理员平台管理手册

VMWare虚拟化管理员平台管理手册目录1管理平台登录介绍 (3)1.1管理平台客户端登陆 (3)2创建虚拟机模板 (7)2.1新建虚拟机 (7)2.2虚拟机创建完毕后为虚拟机安装操作系统。

(19)2.3优化模板 (39)2.4XP系统的优化 (68)2.5优化工具优化 (79)2.6语音室管理员需要执行的特殊操作 (79)2.7执行快照 (84)2.8生成模板 (86)3发布虚拟机 (92)3.1发布虚拟机 (92)3.2重构和刷新虚拟机 (112)4管理员部分安装文件获取和系统登陆 (118)1管理平台登录介绍1.1 管理平台客户端登陆1、下载管理客户端vsphere client使用网页输入以下地址:https://如下图1所示点击“继续访问”。

注:如果本地计算机【指您现在操作的计算机,以下称本地计算机】。

图1登陆结果为:图2 ,点击图中的下载vsphere client ,即可下载您想要的客户端。

图2选择您需要保存的路径,此处不同的下载工具设置保存路径的方法不同,此处视自己的情况而定。

图3下载完成后如图4 ,双击运行安装。

图4安装完成后的如图:双击运行2、登陆平台及管理以下是实训室管理员拥有的账户:sxsadmin 、sxsadmin2 、sxsadmin3 ,密码为admin2014 Ip地址或者名称栏内填写vcenter的名称:或者ip地址:10.0.7.123弹出证书问题时点击安装证书并忽略。

实训室的管理员账户登陆后所见的管理控制台的界面如图,只显示了超级管理员授权的桌面资源池等。

在该资源池中,管理员具有全部的权限,包括创建虚拟机等。

切换到虚拟机和模板视图:图中的管理员只能看见授权的教室的文件夹的内容。

在该文件夹下具有管理员的权限。

切换视图为存储和网络视图:管理员只能看见shixun4的存储,并且只有简单的文件处理及浏览分配空间的权限。

网络的视图中:管理员只能看见属于自己授权范围内的网络,并且不能更改,只能使用。

VMware脚本(PowerCLI)管理手册

VMware脚本(PowerCLI)管理手册

VMware脚本与命令(PowerCLI)管理手册VMware脚本与命令(PowerCLI)管理手册由于VMware是个成熟的虚拟化平台,所以它拥有几个自带的和第三方的管理选项。

图形用户界面GUI提供了直观的、概念上的管理VMware环境的方式,但这些对于大型或者重复的任务来说就略有不足。

如大量贮藏和虚拟机配置这些任务最好使用VMware脚本和命令套件。

在本期虚拟化技术手册中,我们将详细介绍VMware脚本和命令工具,如PowerShell与PowerCLI,以便有效监控VMware环境。

PowerCLI入门VMware管理任务是一项耗时和易出错的工作。

但是vSphere PowerCLI的扩展,可以帮助管理员完成一些控制工作。

本部分将探究VMware脚本工具PowerCLI的概念以及其中五个比较重要的脚本。

如何使用VMware vSphere PowerCLI?五大必备vSphere PowerCLI脚本PowerCLI使用与管理如果您刚刚开始应用PowerCLI管理VMware环境,需要学习的内容很多。

首先,最常见和最重要的cmdlets是Get-VM。

那么它该如何使用?如何设置能自动化主机服务器任务呢?要创建host profiles,PowerCLI能做些什么?这部分中,我们TecgTarget中国的特约作者Hal Rottenberg将详细介绍PowerCLI的使用与管理技巧。

掌控PowerCLI:使用Get-VM来管理虚拟机使用PowerShell与PowerCLI自动化主机服务器任务跳出框外巧解PowerShell与PowerCLI难题如何使用vSphere PowerCLI创建host profiles?在vSphere PowerCLI PowerShell界面使用host profilesPowerCLI技巧如何把VMware PowerCLI脚本功能应用到VMware SRM(Site Recovery Manager)恢复计划中?如何借助PowerCLI配置标准交换机?本部分将给出解决方法与步骤。

VMware脚本(PowerCLI)管理手册

VMware脚本(PowerCLI)管理手册

VMware脚本与命令(PowerCLI)管理手册VMware脚本与命令(PowerCLI)管理手册由于VMware是个成熟的虚拟化平台,所以它拥有几个自带的和第三方的管理选项。

图形用户界面GUI提供了直观的、概念上的管理VMware环境的方式,但这些对于大型或者重复的任务来说就略有不足。

如大量贮藏和虚拟机配置这些任务最好使用VMware脚本和命令套件。

在本期虚拟化技术手册中,我们将详细介绍VMware脚本和命令工具,如PowerShell与PowerCLI,以便有效监控VMware环境。

PowerCLI入门VMware管理任务是一项耗时和易出错的工作。

但是vSphere PowerCLI的扩展,可以帮助管理员完成一些控制工作。

本部分将探究VMware脚本工具PowerCLI的概念以及其中五个比较重要的脚本。

如何使用VMware vSphere PowerCLI?五大必备vSphere PowerCLI脚本PowerCLI使用与管理如果您刚刚开始应用PowerCLI管理VMware环境,需要学习的内容很多。

首先,最常见和最重要的cmdlets是Get-VM。

那么它该如何使用?如何设置能自动化主机服务器任务呢?要创建host profiles,PowerCLI能做些什么?这部分中,我们TecgTarget中国的特约作者Hal Rottenberg将详细介绍PowerCLI的使用与管理技巧。

掌控PowerCLI:使用Get-VM来管理虚拟机使用PowerShell与PowerCLI自动化主机服务器任务跳出框外巧解PowerShell与PowerCLI难题如何使用vSphere PowerCLI创建host profiles?在vSphere PowerCLI PowerShell界面使用host profilesPowerCLI技巧如何把VMware PowerCLI脚本功能应用到VMware SRM(Site Recovery Manager)恢复计划中?如何借助PowerCLI配置标准交换机?本部分将给出解决方法与步骤。

实战powercli管理虚拟机

实战powercli管理虚拟机

什么是PowerCLI[应用程到它,建议在[开始务栏]之应该会出图1 查询特定命令范例命令,便会构下所有可用的命令清单,每一个命令都有相对应的类型与所属模块名称。

接着让我们执行第一个Get-Help 命令的协助,来随时告诉我们任一个命令完整介绍。

例如您只要执行Get-Help Get-VMHost,便可以立看到关于Get-VMHost 命令的完整说明,但是如果您只是想查看该命令的使用范例,则可以像如图1所示一样搭配-Examples 参数的使用即可。

提到Get-VMHost,它可管理员最常使用的命令之一,单独的执行下可以知址、连接状态、电源状态、数量、CPU 总资源、CPU 使用率、总内存大小、内存使率以及ESXi 系统板本。

一个常见的用法则是将定的独立ESXi 主机纳vCenter 的管理,您只要行Add-VMHost -Name Host -Location (Get-Datacenter Datacenter) -User root -Password password 命格式即可,其中来源的主机名(Host)、root 账号、密Get-Command -Module令参数,来名词以及与的命令列表。

如果有显示出像范例中肯定会远Web Client得有效率,准备好下列命令范例,于把它存储成一个主机之中。

-N a m e L o c a t i o n | Move-n a t i o n转换成名的虚拟机行Set-VM上述的范例并没有设置过滤特定的条件,而以下命则是添加了述,来唯一VMware Tools图2 取得选定存放区的虚拟硬盘清单-Datastore -D a t a s t Storage]"确实掌握了每一个虚拟机硬盘的位置、个虚拟机批量移除掉选定的虚拟硬盘。

每一个虚拟硬盘的移除皆会出现确认提示,如果想要直接一次完成全部的删除操作,只要输入A 即可。

Get-HardDisk –VM $vm | Remove-HardDisk至于如果想要批量复制定的数据存放区路径下,可以参考这个Get-HardDisk -VM $vm | Copy-HardDisk "[ VM-Storage]/"命令范例的使用。

VMware View 4.5虚拟桌面需PowerCLI管理

VMware View 4.5虚拟桌面需PowerCLI管理

VMware在Infrastructure 3中加入对微软PowerShell的支持对于提高其产品的兼容性是非常有意义的,因为基于PowerShell的PowerCLI已经成为命令行管理模式中约定俗成的标准,而且新的cmdlets每年都在不断地被加入。

很多原因促使在VMware View中使用PowerCLI,包括速度、可移植性和易用性。

例如,PowerShell cmdlets可以保存为。

ps1文件,易于编辑和修改。

如果您要创建多个虚拟桌面池,借助cmdlets和脚本可以为View环境创建统一的界面布局。

PowerShell cmdlets命令同时也便于进行调整以满足其它安装环境和站点。

另外,如果您需要经常对环境进行破坏和重建,使用PowerShell脚本进行重置也要比基于Web的管理工具快捷地多。

如果您刚开始使用View cmdlets,必须首先在View Server系统中安装(或在Windows 2008 R2中是直接启用)Microsoft PowerShell。

最新的View 4.5 cmdlets仅能在View Connection Server本地运行,这有些失望。

多数管理员期望可以在管理系统中也安装和使用这些cmdlets。

选中Windows PowerShell用于View的cmdlets是以插件的形式加载到PowerCLI环境中。

当前目录位于:C:\Program Files\VMware\VMware View\Server\extras\PowerShell在运行名为add-snapin.ps1的。

PS1文件时插件被安装,同时向开始菜单中添加快捷方式,所以当View PowerCLI会话开始后,相关的插件被自动加载到应用环境中。

安装PowerCLI 插件下面是一些在VMware介绍PowerCLI的“VMware View Integration Guide”指南中介绍的View PowerCLI cmdlets实例。

VMware使用手册

VMware使用手册

VMware使用手册VMware使用手册1、概述1.1 介绍VMware软件的作用和功能 1.2 支持的操作系统和硬件要求1.3 VMware产品版本和许可证选项2、安装与配置2.1 和安装VMware软件2.2 创建虚拟机2.3 配置虚拟机硬件2.4 安装操作系统2.5 配置虚拟网络和网络适配器2.6 设置共享文件夹3、虚拟机管理3.1 启动、暂停和关闭虚拟机3.2 快照功能的使用3.3 虚拟机克隆和迁移3.4 虚拟硬件设备的管理3.5 虚拟机性能调整4、网络和安全性4.1 设置虚拟网络4.2 配置网络连接类型4.3 防火墙和网络安全设置4.4 虚拟机间的网络通信5、高级功能5.1 虚拟机共享和访问控制 5.3 自动化和脚本操作5.4 存储和快速克隆5.5 故障转移和故障恢复6、故障排除和维护6.1 虚拟机无法启动6.2 网络连接问题6.3 性能问题和资源调整6.4 管理员密码重置6.5 数据存储管理7、VMware支持和社区资源7.1 获取技术支持7.2 官方文档和知识库7.3 参与社区讨论和论坛7.4 建议和反馈附件:附件1:VMware安装指南附件3:网络连接设置示例法律名词及注释:1、许可证 - 一项法律文件,规定了软件供应商授予用户使用其软件的权利和条款。

2、快照 - 通过保存虚拟机的状态和数据来实现的一种功能,可用于在出现故障或错误后恢复虚拟机到早期状态。

3、克隆 - 复制一个虚拟机以创建一个与原始虚拟机相同的副本。

4、脚本操作 - 使用脚本语言编写的一系列指令,可用于自动执行一些常规任务。

5、存储 - 用于存储虚拟机文件和数据的物理设备或存储介质。

6、故障转移 - 当一个物理主机或虚拟机出现故障时,将其上运行的虚拟机转移到其他可用的主机上以保持业务连续性。

7、技术支持 - 提供给用户的技术和咨询服务,以解决软件使用过程中遇到的问题。

powercli命令管理总结

powercli命令管理总结

powercli命令管理总结PowerCLI是一种基于vSphere管理平台的命令行界面工具,它提供了针对VMware虚拟化环境的自动化管理功能。

通过PowerCLI命令,管理员可以快速、高效地管理和配置虚拟机、主机、数据存储和网络等资源。

以下是一些常用的PowerCLI命令及其功能总结:1. 连接到vCenter服务器:可以使用Connect-VIServer命令来连接到vCenter服务器,从而进行后续的管理操作。

2. 获取虚拟机列表:使用Get-VM命令可以获取虚拟机的列表,并可以通过参数来指定需要获取的属性,如名称、电源状态、操作系统等。

3. 创建新虚拟机:使用New-VM命令可以创建新的虚拟机,并可以通过参数来指定虚拟机的名称、主机、存储和操作系统等属性。

4. 配置虚拟机属性:使用Set-VM命令可以配置虚拟机的各种属性,如内存大小、CPU数量、网络适配器和磁盘等。

5. 开启或关闭虚拟机:使用Start-VM和Stop-VM命令可以分别启动和关闭虚拟机,可以通过参数来指定关闭虚拟机时的操作,如强制关闭或优雅关闭。

6. 管理主机:可以使用Get-VMHost和Set-VMHost命令来管理主机的各种属性,如网络配置、存储配置和软件包安装等。

7. 管理存储:使用Get-Datastore和New-Datastore命令可以管理数据存储,可以获取存储列表、创建新的存储和配置存储属性等。

8. 网络管理:使用Get-VirtualSwitch和Set-VirtualSwitch命令可以管理虚拟交换机,可以获取交换机列表、创建新的交换机和配置交换机属性等。

9. 执行脚本:PowerCLI支持执行脚本文件,可以使用.\脚本文件名.ps1的方式执行本地存储的PowerCLI脚本。

以上是一些常用的PowerCLI命令的管理总结。

通过这些命令,管理员可以轻松地管理和配置VMware虚拟化环境,提高工作效率并简化管理任务。

vSphere PowerCLI

vSphere PowerCLI

/go/powercli
You need automation to survive the virtual world.
Virtual assets are extremely easy to create. Some people call it “virtual sprawl”. But virtualization lets us do so much more – more complexity is inevitable. Tools and skill sets must be upgraded to match this rise in complexity.
The top 9 most used operators.
Name -eq -gt -and -match -ne -contains -not -lt -or Description Test to see if two objects are equal. True if object 1 is greater than object 2. True if two Boolean conditions are both true. Perform string matching. True if two objects are not equal. True if a list of objects contains a specified object. Negate a Boolean condition. True if object 1 is less than object 2. True if at least on Boolean condition is true.
Description Execute code for each object in a collection. Place an object on the pipeline (or display on the screen if the pipeline is ending).

vSphere PowerCLI 用户指南

vSphere PowerCLI 用户指南

VMware vSphere PowerCLI User's GuidevSphere PowerCLI 5.0.1This document supports the version of each product listed andsupports all subsequent versions until the document is replacedby a new edition. To check for more recent editions of thisdocument, see /support/pubs.EN-000707-00VMware vSphere PowerCLI User's Guide2 VMware, Inc.You can find the most up-to-date technical documentation on the VMware Web site at:/support/The VMware Web site also provides the latest product updates.If you have comments about this documentation, submit your feedback to:docfeedback@Copyright © 2009 – 2012 VMware, Inc. All rights reserved. This product is protected by U.S. and international copyright and intellectual property laws. VMware products are covered by one or more patents listed at /go/patents .VMware is a registered trademark or trademark of VMware, Inc. in the United States and/or other jurisdictions. All other marks and names mentioned herein may be trademarks of their respective companies.VMware, Inc.3401 Hillview Ave.Palo Alto, CA ContentsVMware vSphere PowerCLI User's Guide51Introduction to VMware vSphere PowerCLI7Microsoft PowerShell Basics7VMware vSphere PowerCLI Concepts82Installing VMware vSphere PowerCLI15Supported Operating Systems15Supported VMware Environments16Installation Prerequisites for PowerCLI16Perform a Complete Installation of VMware vSphere PowerCLI16Perform a Custom Installation of VMware vSphere PowerCLI17Set the Properties to Support Remote Signing17Uninstall VMware vSphere PowerCLI183Using PowerCLI Views from .NET19PowerCLI Views19Set Up the Environment to Develop PowerCLI .NET Applications20Updating the Properties of PowerCLI Views20Creating and Using Filters with VimClient.FindEntityView() or VimClient.FindEntityViews()21Saving and Using Server Sessions with PowerCLI Views22Handling Server Errors with PowerCLI Views224Sample Scripts for Managing vSphere with PowerCLI23Connect to a vSphere Server26Manage Virtual Machines on vSphere26Add a Standalone Host to a vSphere Server27Activate Maintenance Mode for a Host on vSphere27Create vSphere Inventory Objects28Create Virtual Machines on vSphere Using an XML Specification File28Manage Virtual Machine Templates on vSphere29Create and Use Snapshots on vSphere29Update the Resource Configuration Settings of a Virtual Machine on vSphere30Get a List of Hosts on vSphere and View Their Properties30Change the Host Advanced Configuration Settings on vSphere31Move a Virtual Machine to a Different Host Using VMware vMotion31Move a Virtual Machine to a Different Datastore Using VMware Storage vMotion32Create a Host Profile on vSphere32Apply a Host Profile to a Host on vSphere32Manage Statistics and Statistics Intervals on vSphere33Modify the Settings of the NIC Teaming Policy for a Virtual Switch33VMware, Inc. 3VMware vSphere PowerCLI User's GuideCreate a Virtual Appliance on vSphere34Modify the Properties of a Virtual Appliance34Export or Import Virtual Appliances34Configure a Network Interface35Add and Configure a Guest Route35Create an iSCSI Host Storage36Add Passthrough Devices to a Host and Virtual Machine36Create a Custom Property Based on an Extension Data Property37Create a Script-Based Custom Property for a vSphere Object37Apply a Customization Object to a Cloned Virtual Machine37Modify the Default NIC Mapping Object of a Customization Specification38Modify Multiple NIC Mapping Objects of a Customization Specification38Create a vSphere Role and Assign Permissions to a User39View the Action Triggers for an Alarm on vSphere40Create and Modify Alarm Actions and Alarm Triggers on vSphere40Remove Alarm Actions and Triggers41Create and Modify Advanced Settings for a Cluster41Modify the vCenter Server Email Configuration42Modify the vCenter Server SNMP Configuration42Use Esxtop to Get Information on the Virtual CPUs of a Virtual Machine42Filter vSphere Objects with Get-View43Populate a View Object with Get-View43Update the State of a Server-Side Object44Reboot a Host with Get-View45Modify the CPU Levels of a Virtual Machine with Get–View and Get–VIObjectByVIView45Browse the Default Inventory Drive46Create a New Custom Inventory Drive46Manage Inventory Objects Through Inventory Drives46Browse the Default Datastore Drives47Create a New Custom Datastore Drive47Manage Datastores Through Datastore Drives48Index494 VMware, Inc.VMware vSphere PowerCLI User's GuideThe VMware vSphere PowerCLI User's Guide provides information about installing and using the VMwarevSphere PowerCLI cmdlets (pronounced “commandlets”) for managing, monitoring, automating, andhandling life-cycle operations for VMware® vSphere and vCloud components.To help you start with VMware vSphere PowerCLI, this information includes descriptions of specific PowerCLI concepts and features. In addition, this information provides a set of usage examples and sample scripts.Intended AudienceThis book is intended for anyone who needs to install and use VMware vSphere PowerCLI. The information in this book is written for administrators and developers who are familiar with virtual machine technology and Windows PowerShell:n Basic administrators can use cmdlets included in VMware vSphere PowerCLI to manage their vSphere and vCloud infrastructure from the command line.n Advanced administrators can develop PowerShell scripts that can be reused by other administrators or integrated into other applications.n Developers can use vSphere PowerCLI views to create .NET applications for managing vSphere objects. VMware, Inc. 5VMware vSphere PowerCLI User's Guide6 VMware, Inc.Introduction to VMware vSphere PowerCLI1 VMware vSphere PowerCLI contains snapins of cmdlets based on Microsoft PowerShell for automatingvSphere and vCloud administration. It provides C# and PowerShell interfaces to VMware vSphere and vCloud APIs.n Microsoft PowerShell Basics on page 7VMware vSphere PowerCLI is based on Microsoft PowerShell and uses the PowerShell basic syntax andconcepts.n VMware vSphere PowerCLI Concepts on page 8VMware vSphere PowerCLI cmdlets are created to automate VMware environments administration andintroduce some specifics in addition to the PowerShell concepts.Microsoft PowerShell BasicsVMware vSphere PowerCLI is based on Microsoft PowerShell and uses the PowerShell basic syntax andconcepts.Microsoft PowerShell is both a command-line and scripting environment, designed for Windows. It usesthe .NET object model and provides administrators with system administration and automation capabilities.To work with PowerShell, you run commands, called cmdlets.n PowerShell Command-Line Syntax on page 7PowerShell cmdlets use a consistent verb-noun structure, where the verb specifies the action and thenoun specifies the object to operate on.n PowerShell Pipelines on page 8A pipeline is a series of commands separated by the pipe operator |.n PowerShell Wildcards on page 8PowerShell has a number of pattern-matching operators called wildcards, which work on strings.n PowerShell Common Parameters on page 8The Windows PowerShell engine implements a set of reserved parameter names, referred to as commonparameters. All PowerShell cmdlets, including the PowerCLI cmdlets, support them.PowerShell Command-Line SyntaxPowerShell cmdlets use a consistent verb-noun structure, where the verb specifies the action and the noun specifies the object to operate on.PowerShell cmdlets follow consistent naming patterns, which makes it easy to figure out how to construct a command if you know the object you want to work with.VMware, Inc. 7VMware vSphere PowerCLI User's GuideAll command categories take parameters and arguments. A parameter starts with a hyphen and is used to control the behavior of the command. An argument is a data value consumed by the command.A simple PowerShell command has the following syntax: command -parameter1 -parameter2 argument1 -argument2.PowerShell PipelinesA pipeline is a series of commands separated by the pipe operator |.Each command in the pipeline receives an object from the previous command, performs some operation on it, and then passes it to the next command in the pipeline. Objects are output from the pipeline as soon as they become available. You can cycle backwards through command history using the up arrow, and can repeat pipelines if you type them on a single line.PowerShell WildcardsPowerShell has a number of pattern-matching operators called wildcards, which work on strings.All wildcard expressions can be used with the VMware vSphere PowerCLI cmdlets. For example, you canview a list of all files with a .txt extension by running dir *.txt. In this case, the asterisk * operator matches any combination of characters.Wildcard patterns allow you to specify character ranges as well. For example, to view all files that start with the letter S or T and have a .txt extension, run dir [st]*.txt.You can use the question mark ? wildcard to match any single character within a sequence of characters. For example, to view all .txt files with names that consist of string and one more character at the end, run dir string?.txt.PowerShell Common ParametersThe Windows PowerShell engine implements a set of reserved parameter names, referred to as commonparameters. All PowerShell cmdlets, including the PowerCLI cmdlets, support them.Some of the PowerShell common parameters are Verbose, Debug, ErrorAction, ErrorVariable, OutVariable, and OutBuffer. For full list of the common parameters and more details on their usage, runGet-Help about_CommonParameters.PowerShell offers two risk mitigation parameters: WhatIf and Confirm.WhatIf Allows you to see the effects of a command without running it.Confirm Prompts for your confirmation before running a command that stops aprogram or service or deletes data.VMware vSphere PowerCLI ConceptsVMware vSphere PowerCLI cmdlets are created to automate VMware environments administration andintroduce some specifics in addition to the PowerShell concepts.n VMware vSphere PowerCLI Components And Versioning on page 9VMware vSphere PowerCLI 5.0.1 consists of two components that users can install and use according totheir needs and environments.n Loading the Script Configuration File of VMware vSphere PowerCLI on page 10Starting VMware vSphere PowerCLI automatically loads the script configuration file Initialize-PowerCLIEnvironment.ps1.8 VMware, Inc.n Specifying Objects in PowerCLI on page 10In PowerCLI, all parameters that take inventory objects, datastores, OSCustomizationSpec objects, andVIServer objects as arguments can be specified by strings and wildcards. This PowerCLI approach iscalled Object-by-Name (OBN) selection.n Running PowerCLI Cmdlets Asynchronously on page 11By default, PowerCLI cmdlets return an output only after completion of the requested tasks. If you wanta cmdlet to return to the command line immediately, without waiting for the tasks to complete, you canspecify the RunAsync parameter.n Using Custom Scripts to Extend the Operating System Support for PowerCLI Cmdlets on page 11 Some PowerCLI features support only Windows 7, Windows Server 2008, Windows XP, Windows Server2003, and Red Hat Enterprise Linux 5. To add support for other guest operating systems, you can usethe scripts that are located in the Script folder of the PowerCLI installation directory or can add yourown custom scripts.n Managing Default vSphere Server Connections with PowerCLI on page 11By default, PowerCLI cmdlets run on the vSphere servers you are connected to, if no target servers canbe determined from the provided parameters.n Customization Specification Objects in PowerCLI on page 12PowerCLI provides two types of objects for customization specification: persistent and nonpersistent.n PowerCLI Views Cmdlets on page 12The PowerCLI list of cmdlets includes the Get-View and Get-VIObjectByVIView cmdlets, which enableaccess to PowerCLI views from .NET.n Using ESXCLI with PowerCLI on page 12PowerCLI provides you the capability to use ESXCLI through its console.n PowerCLI Inventory Provider on page 12The Inventory Provider is designed to expose an unfiltered inventory view of the inventory items froma server.n PowerCLI Datastore Provider on page 13The Datastore Provider is designed to provide access to the contents of one or more datastores. VMware vSphere PowerCLI Components And VersioningVMware vSphere PowerCLI 5.0.1 consists of two components that users can install and use according to their needs and environments.n vSphere PowerCLI 5.0 is the core component of the PowerCLI package. It contains four snapins with cmdlets for managing vSphere 5.0 features:VMware.VimAutomatio n.Core VMware vSphere PowerCLI 5.0 provides cmdlets for automated administration of the vSphere environment.VMware.VimAutomatio n.License VMware License PowerCLI 5.0 provides the Get-LicenseDataManager cmdlet for managing VMware License components.VMware.ImageBuilder VMware ImageBuilder PowerCLI 5.0 provides cmdlets for managingdepots, image profiles, and VIBs.VMware.DeployAutoma tion VMware Auto Deploy PowerCLI 5.0 provides cmdlets that provide an interface to VMware Auto Deploy for provisioning physical hosts with ESXi software.Chapter 1 Introduction to VMware vSphere PowerCLIVMware, Inc. 9n vCloud Director PowerCLI 1.5 is an optional component that you can install during the vSphere PowerCLI installation. It provides the following snapin:VMware.VimAutomatio n.Cloud VMware vCloud Director PowerCLI 1.5 provides cmdlets for automating vCloud Director 1.5 features.Loading the Script Configuration File of VMware vSphere PowerCLI Starting VMware vSphere PowerCLI automatically loads the script configuration file Initialize-PowerCLIEnvironment.ps1.This file is located in the Scripts folder in the VMware vSphere PowerCLI installation directory. Loading the file provides access to PowerCLI cmdlets aliases, like Get-VC, Get-ESX, and to other configuration settings.Administrators can edit and extend the script to define cmdlets aliases, configure the environment, or setPowerCLI startup actions.N OTE After editing the Initialize-PowerCLIEnvironment.ps1 script, you might need to sign it.If you access the PowerCLI snapins from other tools, such as PowerShell Plus or PowerGUI, the Initialize-PowerCLIEnvironment.ps1 script configuration file is not started automatically and you must load it by typing its name in the console window:Initialize-PowerCLIEnvironment.ps1.Specifying Objects in PowerCLIIn PowerCLI, all parameters that take inventory objects, datastores, OSCustomizationSpec objects, andVIServer objects as arguments can be specified by strings and wildcards. This PowerCLI approach is called Object-by-Name (OBN) selection.Instead of assigning an object name to a cmdlet parameter, users can pass the object through a pipeline or a variable. For example, the following three commands are interchangeable:n Remove-VM -VM "Win XP SP2"n Get-VM -Name "Win XP SP2" | Remove-VMn Remove-VM -VM (Get-VM -Name "Win XP SP2")N OTE In VMware vSphere PowerCLI, passing strings as pipeline input is not supported.If you provide a non-existing object name, an OBN failure occurs. In such cases, PowerCLI generates a non-terminating error and runs the cmdlet ignoring the invalid name.For more details about OBN, run help about_OBN.Example: An OBN FailureThis example illustrates the occurrence of an OBN failure.Set-VM –VM “VM1”, “VM2”, “VM3” –Server $server1, $server2 –MemoryMB 512If the VM2 virtual machine does not exist on either of the specified servers, PowerCLI generates a non-terminating error and applies the command only on the VM1 and VM2 virtual machines.VMware vSphere PowerCLI User's Guide10 VMware, Inc.Chapter 1 Introduction to VMware vSphere PowerCLIRunning PowerCLI Cmdlets AsynchronouslyBy default, PowerCLI cmdlets return an output only after completion of the requested tasks. If you want a cmdlet to return to the command line immediately, without waiting for the tasks to complete, you can specify the RunAsync parameter.When you specify the RunAsync parameter, the cmdlet returns Task objects instead of its usual output.The Status property of a returned Task object contains a snapshot of the task’s initial state. This state is not updated automatically and has the values Error, Queued, Running, or Success. You can refresh a task state byretrieving the task object with the Get-Task cmdlet. If you want to observe the progress of a running task and wait for its completion before running other commands, use the Wait-Task cmdlet.N OTE In VMware vSphere PowerCLI, the RunAsync parameter affects only a cmdlet's invocation and does not control whether the initiated tasks run consecutively or in parallel. For example, the Remove-VM cmdlet might remove the specified virtual machines simultaneously or consecutively depending on the PowerCLI internal design. To make sure that tasks initiated by a cmdlet run consecutively, run the cmdlet in a loop, each time applying it to a single object.Example: Running Remove-VM with and without the RunAsync ParameterRemove-VM $vmListThe command returns no output when all virtual machines stored in the $vmList variable are removed,irrespective of whether they are removed simultaneously.Remove-VM $vmList -RunAsyncThe command returns immediately an output that consists of one or more Task objects.Using Custom Scripts to Extend the Operating System Support for PowerCLI CmdletsSome PowerCLI features support only Windows 7, Windows Server 2008, Windows XP, Windows Server 2003, and Red Hat Enterprise Linux 5. To add support for other guest operating systems, you can use the scripts that are located in the Script folder of the PowerCLI installation directory or can add your own custom scripts.When adding new scripts, use the following file naming guidelines:n Scripts that extend the operating system support for Get-VMGuestNetworkInterface, Set-VMGuestNetworkInterface, Get-VMGuestRoute, New-VMGuestRoute, Remove-VMGuestRoute, and Set-VMGuestRoute must follow the file-naming convention CmdletName_OSIdentifier, where OSIdentifier is the guest family or the guest ID as returned by Get-VMGuest, and CmdletName is the cmdlet name writtenwithout a hyphen, for example GetVMGuestRoute.n Scripts that extend the operating system support for resizing the hard disk by using Set-HardDisk must follow the file naming convention GuestDiskExpansion_OSIdentifier, where OSIdentifier is the guest family or the guest ID (as returned by Get-VMGuest).Managing Default vSphere Server Connections with PowerCLIBy default, PowerCLI cmdlets run on the vSphere servers you are connected to, if no target servers can be determined from the provided parameters.When you connect to a vSphere server by using Connect-VIServer, the server connection is stored in the $DefaultVIServers array variable. This variable contains all connected servers for the current PowerCLI session.To remove a server from the $DefaultVIServers variable, you can either use Disconnect-VIServer to close all active connections to this server, or modify the value of $DefaultVIServers manually.VMware vSphere PowerCLI User's GuideCustomization Specification Objects in PowerCLIPowerCLI provides two types of objects for customization specification: persistent and nonpersistent.Persistent customizationPersistent customization specification objects are stored on the vSphere server. All persistent customization specifications created by using vSphere Client or PowerCLI 4.1 or later are encrypted. Encrypted customization specifications can be applied only by the server that has encrypted them.Nonpersistent customizationNonpersistent customization specification objects exist only inside the current PowerShell process.Nonpersistent customization specification objects are not encrypted, but cloning them to a vSphere serverencrypts them.PowerCLI Views CmdletsThe PowerCLI list of cmdlets includes the Get-View and Get-VIObjectByVIView cmdlets, which enable access to PowerCLI views from .NET.To find more information about PowerCLI views, see “PowerCLI Views,” on page 19.Using the PowerCLI views cmdlets for low-level VMware vSphere management requires some knowledge of both PowerShell scripting and the VMware vSphere APIs.Using ESXCLI with PowerCLIPowerCLI provides you the capability to use ESXCLI through its console.PowerCLI provides two approaches for working with ESXCLI:n Through the Get-ESXCli cmdlet, which provides direct access to the ESXCLI namespaces, applications, and commands.n Through .NET methods, which you use to create managed objects that correspond to specific ESXCLI applications. To access the ESXCLI, you can call methods on these managed objects. .N OTE To call a method of an ESXCLI object, you must provide values for all parameters. If you want toomit a given parameter, specify $null for it.PowerCLI Inventory ProviderThe Inventory Provider is designed to expose an unfiltered inventory view of the inventory items from a server.It enables navigation and file-style management of the VMware vSphere inventory. By creating a PowerShell drive based on a managed object (such as a datacenter), you can obtain a view of its contents and therelationships between the items. In addition, you can move, rename, or delete objects by running commands from the PowerCLI console.When you connect to a server with Connect-VIServer, the cmdlet builds two default inventory drives: vi and vis. The vi inventory drive shows the inventory on the last connected server. The vis drive contains theinventory of all vSphere servers connected within the current PowerCLI session.You can use the default inventory drives or create custom drives based on the default ones.Chapter 1 Introduction to VMware vSphere PowerCLIPowerCLI Datastore ProviderThe Datastore Provider is designed to provide access to the contents of one or more datastores.The items in a datastore are files that contain configuration, virtual disk, and the other data associated with a virtual machine.When you connect to a server with Connect-VIServer, the cmdlet builds two default datastore drives:vmstores and vmstore. The vmstore drive provides a list of the datastores available on the vSphere server that you last connected to. The vmstores drive contains all datastores available on all vSphere servers that you connected to within the current PowerCLI session.You can use the default inventory drives or create custom drives based on the default ones.VMware vSphere PowerCLI User's GuideInstalling VMware vSphere PowerCLI2 You can install VMware vSphere PowerCLI components on all supported Windows operating systems.After you have installed the package on your machine, you can run PowerCLI cmldets to connect to yourvSphere or vCloud system by specifying the appropriate connection parameters.n Supported Operating Systems on page 15You can install VMware vSphere PowerCLI only on Windows operating systems.n Supported VMware Environments on page 16You can use the VMware vSphere PowerCLI 5.0.1 components to manage all supported vSphere andvCloud environments.n Installation Prerequisites for PowerCLI on page 16Before installing VMware vSphere PowerCLI, verify that you have installed the required software onthe same machine.n Perform a Complete Installation of VMware vSphere PowerCLI on page 16By performing a complete PowerCLI installation, you install all PowerCLI components available in theinstallation package. This installation setup type requires the most disk space.n Perform a Custom Installation of VMware vSphere PowerCLI on page 17By performing a custom PowerCLI installation, you can choose the PowerCLI components that you wantto install.n Set the Properties to Support Remote Signing on page 17For security reasons, Windows PowerShell supports an execution policy feature. It determines whetherscripts are allowed to run and whether they must be digitally signed. By default, the execution policy isset to Restricted, which is the most secure policy.n Uninstall VMware vSphere PowerCLI on page 18You can uninstall VMware vSphere PowerCLI components from your Windows system by using Addor Remove Programs.Supported Operating SystemsYou can install VMware vSphere PowerCLI only on Windows operating systems.VMware vSphere PowerCLI 5.0.1 is supported on the following operating systems:n Windows 7 Service Pack 1 (32-bit and 64-bit)n Windows Server 2008 R2 Service Pack 1 (32-bit and 64-bit)n Windows XP Service Pack 2 (32-bit and 64-bit) and Service Pack 3 (32-bit)VMware vSphere PowerCLI User's Guiden Windows Server 2003 R2 (32-bit and 64-bit)N OTE The list of supported operating systems might not apply to some PowerCLI cmdlets for managing guest systems.Supported VMware EnvironmentsYou can use the VMware vSphere PowerCLI 5.0.1 components to manage all supported vSphere and vCloud environments.vSphere PowerCLI 5.0.1 is compatible with the following vSphere environments:n VMware ESXi 5.0n vCenter Server 5.0n VMware ESX 4.1 Update 2 and vCenter Server 4.1 Update 2n VMware ESXi 4.1 Update 2n VMware ESX 4.0 Update 4 and vCenter Server 4.0 Update 4n VMware ESX 4.0i Update 4n VMware ESX 3.5 Update 5n VMware ESXi 3.5 Update 5n VMware VirtualCenter 2.5 Update 6vCloud Director PowerCLI 1.5 is compatible with VMware vCloud Director 1.5.Installation Prerequisites for PowerCLIBefore installing VMware vSphere PowerCLI, verify that you have installed the required software on the same machine.To install VMware vSphere PowerCLI 5.0.1, you must first install: 2.0, 3.0, or 3.5 with Service Pack 1n Windows PowerShell 2.0Perform a Complete Installation of VMware vSphere PowerCLI By performing a complete PowerCLI installation, you install all PowerCLI components available in theinstallation package. This installation setup type requires the most disk space.PrerequisitesBefore installing PowerCLI, see “Installation Prerequisites for PowerCLI,” on page 16.Procedure1Download the latest version of VMware vSphere PowerCLI from VMware Web site.2Navigate to the Web folder that contains the PowerCLI installer file you downloaded and double-click the executable file.3On the Welcome page, click Next.4Accept the license agreement terms and click Next.5On the Destination Folder page, select the location to install VMware vSphere PowerCLI and click Next.6On the Setup Type page, select Complete and click Next.Chapter 2 Installing VMware vSphere PowerCLI7On the Ready to Install the Program page, click Install to proceed with the installation.8Click Finish to complete the installation process.What to do next“Set the Properties to Support Remote Signing,” on page 17.Perform a Custom Installation of VMware vSphere PowerCLI By performing a custom PowerCLI installation, you can choose the PowerCLI components that you want to install.PrerequisitesBefore installing PowerCLI, see “Installation Prerequisites for PowerCLI,” on page 16.Procedure1Download the latest version of VMware vSphere PowerCLI from VMware Web site.2Navigate to the Web folder that contains the PowerCLI installer file you downloaded and double-click the executable file.3On the Welcome page, click Next.4Accept the license agreement terms and click Next.5On the Destination Folder page, select the location to install VMware vSphere PowerCLI and click Next.6On the Setup Type page, select Custom and click Next.7On the Custom Setup page, select the components that you want to install and click Next.Option DescriptionvSphere PowerCLI Installs a set of cmdlets for managing vSphere features. This PowerCLIcomponent is mandatory and selected by default.vCloud Director PowerCLI Installs a set of cmdlets for managing vCloud Director features.8On the Ready to Install the Program page, click Install to proceed with the installation.9Click Finish to complete the installation process.What to do next“Set the Properties to Support Remote Signing,” on page 17.Set the Properties to Support Remote SigningFor security reasons, Windows PowerShell supports an execution policy feature. It determines whether scripts are allowed to run and whether they must be digitally signed. By default, the execution policy is set toRestricted, which is the most secure policy.If you want to run scripts or load configuration files, you can change the execution policy by using the Set-ExecutionPolicy cmdlet. For more information about the execution policy and script digital signing inWindows PowerShell, run Get-Help About_Signing.Procedure1Select Start > Programs > VMware > VMware vSphere PowerCLI.The VMware vSphere PowerCLI console window opens.2In the VMware vSphere PowerCLI console window, run Set-ExecutionPolicy RemoteSigned.。

PowerCLi命令集

PowerCLi命令集

Set-VMSet-VMResourceCongurationSet-SnapshotSet-CDDriveSet-FloppyDriveSet-HardDiskSet-NetworkAdapterStart-VMStop-VMMove-VMGet-VMSuspend-VMGet-SnapshotGet-CDDriveGet-HardDiskGet-SnapshotGet-FloppyDriveGet-UsbDeviceGet-VMQuestionInvoke-VMScriptNew-VMNew-SnapshotNew-CDDriveNew-FloppyDriveNew-HardDiskNew-NetworkAdapterRemove-SnapshotRemove-CDDriveRemove-FloppyDriveRemove-NetworkAdapterRemove-VMRemove-UsbDeviceRestart-VM针对网络设定相关的PowerCLI命令New-VMHostNetworkAdapterNew-VirtualSwitchNew-VirtualPortGroupRemove-VirtualSwitchRemove-VMHostNetworkAdapter Remove-VirtualPortGroup Remove-VMHostNtpServerSet-VirtualPortGroupSet-VirtualSwitchSet-ScsiLunSet-ScsiLunPathGet-ScsiLunGet-ScsiLunPathGet-VirtualSwitchGet-VirtualPortGroupGet-VMHostNetworkGet-VMHostNtpServerGet-VMHostSnmpGet-VMHostFirewallDefaultPolicy Get-VMHostFirewallExceptionSet-VMHostNetworkSet-VMHostFirewallDefaultPolicy Set-VMHostFirewallExceptionSet-VMHostNetworkAdapterSet-VMHostSnmpSet-ScsiLunPathTest-VMHostSnmpSet-VIToolkitCongurationGet-OSCustomizationNicMapping New-OSCustomizationNicMapping Set-OSCustomizationNicMapping Get-NicTeamingPolicySet-NicTeamingPolicyGet-VMHostHbaSet-VMHostHbaGet-iScsiHbaTargetNew-iScsiHbaTargetRemove-iScsiHbaTargetSet-iScsiHbaTargetSet-VMHostStorageGet-VMGuestNetworkInterfaceSet-VMGuestNetworkInterfaceGet-VMGuestRouteNew-VMGuestRouteRemove-VMGuestRouteSet-VMGuestRouteAdd-PassthroughDeviceGet-PassthroughDeviceRemove-PassthroughDevice针对vSphere主机的PowerCLI命令Get-ViewGet-VIObjectByVIViewGet-CustomAttributeNew-CustomAttribute Remove-CustomAttribute Set-CustomAttributeGet-AnnotationSet-AnnotationRemove-InventoryMove-Inventory Connect-VIServerAdd-VMHostGet-VMHostRemove-VMHost Disconnect-VIServerGet-DatacenterGet-VMHostStorageGet-InventoryGet-DatastoreSet-DatastoreRemove-DatastoreGet-NetworkAdapterGet-TaskWait-TaskGet-TemplateMove-TemplateNew-TemplateRemove-TemplateSet-TemplateSet-FolderMove-FolderRemove-FolderStop-TaskNew-FolderNew-DrsRuleGet-DrsRuleRemove-DrsRuleSet-DrsRuleGet-DrsRecommendation Apply-DrsRecommendation Get-VIPrivilegeGet-VIRoleNew-VIRoleRemove-VIRoleSet-VIRoleGet-VIPermissionNew-VIPermissionRemove-VIPermissionSet-VIPermissionGet-VAppExport-VAppImport-VAppNew-VAppRemove-VAppSet-VAppStart-VAppStop-VApp针对主机配置文件的PowerCLI命令Apply-VMHostProfileExport-VMHostProfileGet-VMHostProfileImport-VMHostProfileNew-VMHostProfileRemove-VMHostProfileSet-VMHostProfileTest-VMHostProfileCompliance针对系统日志的PowerCLI命令Get-StatIntervalGet-StatTypeGet-StatGet-LogGet-VIEventGet-PowerCLIDocumentationGet-PowerCLICommunityGet-PowerCLICongurationGet-PowerCLIVersionGet-LogTypeGet-VICredentialStoreItemGet-VMResourceCongurationSet-VMHostSysLogServerNew-StatIntervalNew-VICredentialStoreItem Remove-StatIntervalRemove-VICredentialStoreItemSet-StatIntervalGet-OSCustomizationSpecNew-OSCustomizationSpec Remove-OSCustomizationSpecSet-OSCustomizationSpec。

VMware

VMware

VMware Sphere PowerCli批量创建虚拟机VMware Sphere PowerCli批量创建虚拟机前提条件1、安装.NET 4.5依赖组件2、安装VMware-PowerCLI-6.5.0命令⾏软件3、创建*.csv类型的模板⽂件,模板(NewVMs.csv)样本如下:批量创建虚拟机操作⼀、设置powercli⽀持执⾏远程脚本Set-ExecutionPolicy RemoteSigned⼆、批量创建虚拟机脚本#Powercli连接VCenter服务器Connect-VIServer 10.129.63.42 -User 'administrator@vsphere.local' -Password 'VMware VCenter Login_Password'#导⼊*.csv模板中虚机信息$vms = Import-CSV C:\Scripts\NewVMs.csv#执⾏foreach循环语句创建虚拟机foreach ($vm in $vms){#获取模板信息$Template = Get-Template $vm.template#获取虚机存放主机位置$VMHost = Get-VMHost $vm.host#获取数据存放存储位置$Datastore = Get-Datastore $vm.datastore#获取虚机存放⽂件夹位置$Folder = Get-Folder $vm.folder#新建虚机New-VM -Name $ -Template $Template -VMHost $VMHost -Datastore $Datastore -Location $Folder -RunAsync #开启新建虚拟机Start-VM $}三、Powercli运⾏脚本C:\>cd c:\ScriptsC:\>.\clone-vm.ps1。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

VMware PowerCLI User's GuideVMware PowerCLI 6.5.4VMware PowerCLI User's GuideYou can find the most up-to-date technical documentation on the VMware website at:https:///If you have comments about this documentation, submit your feedback todocfeedback@VMware, Inc.3401 Hillview Ave.Palo Alto, CA 94304Copyright © 1998–2017 VMware, Inc. All rights reserved. Copyright and trademark information.ContentsVMware PowerCLI User's Guide81Introduction to VMware PowerCLI9Microsoft PowerShell Basics9PowerShell Command-Line Syntax10PowerShell Pipelines10PowerShell Wildcards10PowerShell Common Parameters10PowerCLI Concepts11PowerCLI Modules12Interoperability Between the PowerCLI and vCloud Director PowerCLI Modules13Selecting Objects in PowerCLI14Providing Login Credentials15Running PowerCLI Cmdlets Asynchronously15Managing Default Server Connections16Customization Specification Objects in PowerCLI16Using ESXCLI with PowerCLI16PowerCLI Inventory Provider17PowerCLI Datastore Provider17PowerCLI About Articles172Installing VMware PowerCLI19Supported Operating Systems20Supported VMware Products20Supported Windows PowerShell Versions20Prerequisites for Installing and Running PowerCLI20Install PowerCLI20Allow Execution of Local Scripts21Update a PowerCLI Module21Uninstall PowerCLI223Configuring VMware PowerCLI23Scoped Settings of PowerCLI23Configuring the Scope of the PowerCLI Settings23Priority of Settings Scopes in PowerCLI24PowerCLI Configuration Files24Using Custom Scripts to Extend the Operating System Support for PowerCLI Cmdlets254Configuring Customer Experience Improvement Program26Categories of Information That VMware Receives26Join the Customer Experience Improvement Program in PowerCLI265Sample Scripts for Managing vSphere with VMware PowerCLI27 Connect to a vCenter Server System31Manage Virtual Machines on vSphere32Add a Standalone Host to a vCenter Server System33Set the License Key for a Host on vCenter Server33Activate Maintenance Mode for a Host on vCenter Server34Create vSphere Inventory Objects34Create Virtual Machines on vCenter Server Using an XML Specification File36Manage Virtual Machine Templates on vCenter Server36Create and Use Snapshots on vCenter Server37Update the Resource Configuration Settings of a Virtual Machine on vCenter Server38Get a List of Hosts on a vCenter Server System and View Their Properties38Change the Host Advanced Configuration Settings on vCenter Server39Move a Virtual Machine to a Different Host Using VMware vSphere vMotion40Move a Virtual Machine to a Different Datastore Using VMware vSphere Storage vMotion40 Create a Host Profile on a vCenter Server System41Apply a Host Profile to a Host on vCenter Server41Manage Statistics and Statistics Intervals on vCenter Server42Modify the Settings of the NIC Teaming Policy for a Virtual Switch43Create a vApp on vCenter Server43Modify the Properties of a vApp44Export or Import vApps44Create an iSCSI Host Storage45Add Passthrough Devices to a Host and Virtual Machine45Create a Custom Property Based on an Extension Data Property46Create a Script-Based Custom Property for a vSphere Object46Apply a Customization Object to a Cloned Virtual Machine47Modify the Default NIC Mapping Object of a Customization Specification48Modify Multiple NIC Mapping Objects of a Customization Specification48Create Multiple Virtual Machines that Use Static IP Addresses49Create Multiple Virtual Machines with Two Network Adapters51Create a vSphere Role and Assign Permissions to a User52View the Action Triggers for an Alarm on vCenter Server53Create and Modify Alarm Actions and Alarm Triggers on vCenter Server53Remove Alarm Actions and Triggers54Create and Modify Advanced Settings for a Cluster55Modify the vCenter Server Email Configuration55Modify the vCenter Server SNMP Configuration56Use Esxtop to Get Information on the Virtual CPUs of a Virtual Machine56Filter vSphere Objects with Get-View57Populate a View Object with Get-View58Update the State of a Server-Side Object58Reboot a Host with Get-View59Modify the CPU Levels of a Virtual Machine with Get–View and Get–VIObjectByVIView60 Browse the Default Inventory Drive60Create a New Custom Inventory Drive61Manage Inventory Objects Through Inventory Drives61Browse the Default Datastore Drives62Create a New Custom Datastore Drive63Manage Datastores Through Datastore Drives63Modify the Timeout Setting for Web Tasks64Using Tags65Retrieve a Tag and Save It into a Variable65Retrieve a Tag Category and Save It into a Variable66Create a Tag Category and a Tag66Assign a Tag to Virtual Machines66Retrieve Objects by Tag67Generate Tags Automatically by Using a Script67Add an Entity Type to a Tag Category68Retrieve Tag Assignments68Network Management with vSphere Distributed Switches69Create a Distributed Switch and Configure Networking69Configure a Distributed Switch70Migrate Virtual Machine Networking Configuration from a vSphere Standard Switch to a vSphere Distributed Switch70Migrate Physical and Virtual NICs to a vSphere Standard Switch71Migrate Physical and Virtual NICs to a vSphere Distributed Switch72Configure the Traffic Shaping Policy73Configure the Security Policy73Create a Virtual Machine from a Content Library Item73Create a vApp from a Content Library Item74Create a New VM-VM DRS Rule74Create a New VM-VMHost DRS Rule756Sample Scripts for Managing vSphere Policy-Based Storage with VMware PowerCLI77Create a Tag-Based Storage Policy77Create a Capability-Based Storage Policy78Associate a Storage Policy with a Virtual Machine and Its Hard Disk79Disassociate a Storage Policy Associated with a Virtual Machine and Its Hard Disk80Enable SPBM on a Cluster and Verify that It Is Enabled80Remove a Storage Policy81Edit a Storage Policy81Export and Import a Storage Policy82Create a Virtual Machine in a Datastore Compatible with Storage Policy82Create a vSAN Datastore84Modify a vSAN Datastore85Create a vSAN Stretched Cluster86Create an NFS 4.1 Datastore87Add a VASA Provider and Create a Policy88Invoke a Planned Failover on a Replication Group and Reverse the Replication90Attach a Flat VDisk to a Virtual Machine927Sample Scripts for Managing VMware Site Recovery Manager with VMware PowerCLI93Connect to an SRM Server93Protect a Virtual Machine94Create a Report of the Protected Virtual Machines94Create a Report of the Virtual Machines Associated with All Protection Groups958Sample Scripts for Managing the vSphere Automation SDK withVMware PowerCLI97Create a Local Content Library on an Existing Datastore979Sample Scripts for Managing vCloud Director with VMware PowerCLI99 Connect to a vCloud Director Server100Create and Manage Organizations101Create and Manage Organization Virtual Data Centers101Filter and Retrieve Organization Virtual Data Center Networks102Import a vApp Template from the Local Storage103Create a vApp Template from a vApp103Import a vApp from vSphere104Create and Modify a vApp105Manage Virtual Machines with vApps105Manage Virtual Machines and Their Guest Operating Systems106Retrieve a List of the Internal and External IP Addresses of Virtual Machines in vApps107 Create and Manage Access Control Rules108Filter and Retrieve vApp Networks108Create vApp Networks for a Selected vApp109Create an Isolated vApp Network109Create an NAT Routed vApp Network110Create a Direct vApp Network110Modify or Remove vApp Networks11110Sample Scripts for Managing vCloud Air with VMware PowerCLI113 Connect to a vCloud Air Server113Retrieve vApps from a Data Center114Retrieve vApps from a Compute Instance114Running vCloud Director Scripts Against vCloud Air11511Sample Scripts for Managing vSphere Update Manager with VMware PowerCLI116Connect to a vCenter Server System116Create Patch Baselines117Attach and Detach Baselines118Scan a Virtual Machine118Check Virtual Machine Baseline Status119Stage Patches119Remediate a Virtual Machine120Upgrade Virtual Machine Hardware120Remediate a Cluster120Remediate a Host121Download Patches and Scan Objects12112Sample Scripts for Managing vRealize Operations Manager with VMware PowerCLI123Connect to a vRealize Operations Manager Server123Check Memory Waste Levels124Get Remediation Recommendations124Change Alert Ownership125Create a Report for Problematic Hosts125VMware PowerCLI User's GuideThe VMware PowerCLI User's Guide provides information about installing and using theVMware PowerCLI cmdlets (pronounced “commandlets”) for managing, monitoring, automating, and handling operations for VMware® vSphere, VMware Site Recovery Manager, vSphere Automation SDK, vCloud Director, vCloud Air, vSphere Update Manager, vRealize Operations Manager, VMware Horizon, NSX-T, and VMware Cloud on AWS components.To help you start with PowerCLI, this documentation includes descriptions of specific PowerCLI concepts and features. In addition, this documentation provides a set of use case examples and sample scripts.Intended AudienceThis guide is intended for anyone who wants to install and use PowerCLI. This documentation is written for administrators and developers who are familiar with virtual machine technology and Windows PowerShell.n Basic administrators can use cmdlets included in PowerCLI to manage their vSphere, VMware Site Recovery Manager, vSphere Automation SDK, vCloud Director, vCloud Air,vSphere Update Manager, vRealize Operations Manager, VMware Horizon, NSX-T, andVMware Cloud on AWS infrastructure from the command line.n Advanced administrators can develop PowerShell scripts that other administrators can reuse or integrate into other applications.Introduction toVMware PowerCLI1VMware PowerCLI contains modules of cmdlets based on Microsoft PowerShell for automating vSphere, VMware Site Recovery Manager, vSphere Automation SDK, vCloud Director, vCloud Air,vSphere Update Manager, vRealize Operations Manager, VMware Horizon, NSX-T, andVMware Cloud on AWS administration. VMware PowerCLI provides a PowerShell interface to the VMware product APIs.n Microsoft PowerShell BasicsPowerCLI is based on Microsoft PowerShell and uses the PowerShell basic syntax and concepts.n PowerCLI ConceptsPowerCLI cmdlets are created to automate VMware environments administration and to introduce some specific features in addition to the PowerShell concepts.Microsoft PowerShell BasicsPowerCLI is based on Microsoft PowerShell and uses the PowerShell basic syntax and concepts. Microsoft PowerShell is both a command-line and scripting environment, designed for Windows. It uses the .NET object model and provides administrators with system administration and automation capabilities. To work with PowerShell, you run commands, named cmdlets.n PowerShell Command-Line SyntaxPowerShell cmdlets use a consistent verb-noun structure, where the verb represents the action and the noun represents the object to operate on.n PowerShell PipelinesA pipeline is a series of commands separated by the pipe operator |.n PowerShell WildcardsPowerShell has a number of pattern-matching operators named wildcards that you can use tosubstitute one or more characters in a string, or substitute the complete string.n PowerShell Common ParametersThe Windows PowerShell engine retains a set of parameter names, referred to as commonparameters. All PowerShell cmdlets, including the PowerCLI cmdlets, support them.VMware PowerCLI User's GuidePowerShell Command-Line SyntaxPowerShell cmdlets use a consistent verb-noun structure, where the verb represents the action and the noun represents the object to operate on.PowerShell cmdlets follow consistent naming patterns, ensuring that construction of a command is easy if you know the object that you want to work with.All command categories take parameters and arguments. A parameter starts with a hyphen and is used to control the behavior of the command. An argument is a data value consumed by the command.A simple PowerShell command has the following syntax:command -parameter1 -parameter2 argument1, argument2PowerShell PipelinesA pipeline is a series of commands separated by the pipe operator |.Each command in the pipeline receives an object from the previous command, performs some operation on it, and then passes it to the next command in the pipeline. Objects are output from the pipeline as soon as they become available.PowerShell WildcardsPowerShell has a number of pattern-matching operators named wildcards that you can use to substitute one or more characters in a string, or substitute the complete string.All wildcard expressions can be used with the PowerCLI cmdlets. For example, you can view a list of all files with a .txt extension by running dir *.txt. In this case, the asterisk * operator matches any combination of characters.With wildcard patterns you can indicate character ranges as well. For example, to view all files that start with the letter S or T and have a .txt extension, you can run dir [st]*.txt.You can use the question mark ? wildcard to match any single character within a sequence of characters. For example, to view all .txt files with names that consist of string and one more character at the end, run dir string?.txt.PowerShell Common ParametersThe Windows PowerShell engine retains a set of parameter names, referred to as common parameters. All PowerShell cmdlets, including the PowerCLI cmdlets, support them.Some of the PowerShell common parameters are Verbose, Debug, ErrorAction, ErrorVariable, OutVariable, and OutBuffer. For a full list of the common parameters and more details on their usage, run Get-Help about_CommonParameters.PowerShell offers two risk mitigation parameters: WhatIf and Confirm.WhatIf Displays the effects of a command without running it.Confirm Prompts for confirmation before running a command that stops a programor service, or deletes data.PowerCLI ConceptsPowerCLI cmdlets are created to automate VMware environments administration and to introduce some specific features in addition to the PowerShell concepts.n PowerCLI ModulesVMware PowerCLI 6.5.4 consists of multiple modules that you can install and use according to your needs and environments.n Interoperability Between the PowerCLI and vCloud Director PowerCLI Modules With the RelatedObject parameter of PowerCLI cmdlets, you can retrieve vSphere inventory objects from cloud resources. This interoperability between the PowerCLI andvCloud Director PowerCLI modules expands cloud administration, automation, reporting, andtroubleshooting options for provider administrators.n Selecting Objects in PowerCLIIn PowerCLI, you can pass strings and wildcards to all parameters that take inventory objects,datastores, OSCustomizationSpec objects, and VIServer objects as arguments. This PowerCLI approach is named Object-by-Name (OBN) selection.n Providing Login CredentialsWhen you provide login credentials in the command prompt or in a script file, a PowerShell limitation might prevent PowerCLI from processing non-alphanumeric characters correctly. To prevent login problems, escape the non-alphanumeric characters in your credentials.n Running PowerCLI Cmdlets AsynchronouslyBy default, PowerCLI cmdlets return an output only after completion of the requested tasks. If you want a cmdlet to return to the command line immediately, without waiting for the tasks to complete, you can use the RunAsync parameter.n Managing Default Server ConnectionsBy default, PowerCLI and PowerCLI cmdlets run on the vCenter Server systems or vCloud Director servers you are connected to, if no target servers can be determined from the provided parameters.n Customization Specification Objects in PowerCLIPowerCLI provides two types of objects for customization specification: persistent andnonpersistent.n Using ESXCLI with PowerCLIPowerCLI provides you the capability to use ESXCLI through its console.n PowerCLI Inventory ProviderThe Inventory Provider is designed to expose an unfiltered inventory view of the inventory items from a server.n PowerCLI Datastore ProviderThe Datastore Provider is designed to provide access to the contents of one or more datastores.n PowerCLI About ArticlesYou can learn more about some PowerCLI concepts and features from the built-in help articlesnamed about articles. You can access them through a running PowerCLI process.PowerCLI ModulesVMware PowerCLI 6.5.4 consists of multiple modules that you can install and use according to your needs and environments.The following table lists all official VMware PowerCLI modules.VMware.PowerCLI Provides a root module which other modules are dependent on.This module ensures the PowerCLI product can be installed,upgraded, and removed as a complete package if needed.VMware.VimAutomation.Core Provides cmdlets for automated administration of the vSphereenvironment.mon Provides functionality that is common to all PowerCLI modules.This module has no cmdlets, but is required for other modules tofunction correctly.VMware.VimAutomation.Sdk Provides SDK functionality that is needed by all PowerCLImodules. This module has no cmdlets, but is required for othermodules to function correctly.VMware.VimAutomation.Vds Provides cmdlets for managing vSphere distributed switchesand distributed port groups.VMware.VimAutomation.Cis.Core Provides cmdlets for managing vSphere Automation SDKservers.VMware.VimAutomation.Storage Provides cmdlets for managing vSphere policy-based storage. VMware.VimAutomation.StorageUtility Provides utility scripts for storage.VMware.VimAutomation.HA Provides the Get-DrmInfo cmdlet for managing High Availabilityfunctionality.VMware.VimAutomation.License Provides the Get-LicenseDataManager cmdlet for managingVMware License components.VMware.ImageBuilder Provides cmdlets for managing depots, image profiles, andVIBs.VMware.DeployAutomation Provides cmdlets that provide an interface to VMware AutoDeploy for provisioning physical hosts with ESXi software. VMware.VimAutomation.Cloud Provides cmdlets for automating vCloud Director features.VMware.VimAutomation.PCloud Provides cmdlets for automating vCloud Air features.VMware.VumAutomation Provides cmdlets for automating vSphere Update Managerfeatures.VMware.VimAutomation.vROps Provides cmdlets for automating vRealize Operations Managerfeatures.VMware.VimAutomation.Srm Provides cmdlets for managing VMware Site Recovery Managerfeatures.VMware.VimAutomation.HorizonView Provides cmdlets for automating VMware Horizon features. VMware.VimAutomation.Nsxt Provides cmdlets for managing NSX-T servers.VMware.VimAutomation.Vmc Provides cmdlets for automating VMware Cloud on AWSfeatures.Interoperability Between the PowerCLI andvCloud Director PowerCLI ModulesWith the RelatedObject parameter of PowerCLI cmdlets, you can retrieve vSphere inventory objects from cloud resources. This interoperability between the PowerCLI and vCloud Director PowerCLI modules expands cloud administration, automation, reporting, and troubleshooting options for provider administrators.Note To use the interoperability feature, you must install the PowerCLI and vCloud Director PowerCLI modules, and connect both to a vCloud Director server and a vCenter Server system.Retrieving vSphere Inventory Objects from Cloud ResourcesProvider administrators can use the RelatedObject parameter of PowerCLI cmdlets to retrieve vSphere inventory objects from vCloud Director objects. Passing the retrieved objects to the cmdlets of the VMware.VimAutomation.Core and VMware.VimAutomation.VDS modules, extends administration options.Important Use of the VMware.VimAutomation.Core and VMware.VimAutomation.VDS modules to modify the configuration of objects that are managed by vCloud Director might result in unpredictable behavior of the cloud environment.Table 1‑1. List of Supported vSphere Inventory Objects You Can Retrieve from Cloud ObjectsTable 1‑1. List of Supported vSphere Inventory Objects You Can Retrieve from Cloud Objects (Continued)ExternalNetwork VDPortgroupGet-ExternalNetwork -Name'MyExternalNetwork' | Get-VDPortGroupSelecting Objects in PowerCLIIn PowerCLI, you can pass strings and wildcards to all parameters that take inventory objects, datastores, OSCustomizationSpec objects, and VIServer objects as arguments. This PowerCLI approach is named Object-by-Name (OBN) selection.Instead of assigning an object name to a cmdlet parameter, users can pass the object through a pipeline or a variable. For example, the following three commands are interchangeable:n Remove-VM -VM "Win 7 SP1"n Get-VM -Name "Win 7 SP1" | Remove-VMn Remove-VM -VM (Get-VM -Name "Win 7 SP1")Note In PowerCLI, passing strings as pipeline input is not supported.If you provide a non-existing object name, an OBN failure occurs. In such cases, PowerCLI generates a non-terminating error and runs the cmdlet ignoring the invalid name.For more details about OBN, run help about_OBN.Example: An OBN failureThis example illustrates the occurrence of an OBN failure.Set-VM –VM “VM1”, “VM2”, “VM3” –Server $server1, $server2 –MemoryGB 4If the VM2 virtual machine does not exist on either of the selected servers, PowerCLI generates a non-terminating error and applies the command only on the VM1 and VM3 virtual machines.Providing Login CredentialsWhen you provide login credentials in the command prompt or in a script file, a PowerShell limitation might prevent PowerCLI from processing non-alphanumeric characters correctly. To prevent login problems, escape the non-alphanumeric characters in your credentials.To escape non-alphanumeric characters in PowerCLI, you need to place the expression that contains them in single quotes (').Note When you provide your login credentials in the Specify Credential dialog box, you do not need to escape non-alphanumeric characters.Example: Connecting to a vCenter Server SystemThis example illustrates how to escape non-alphanumeric characters when connecting to a selected vCenter Server instance with the Adminis!ra!or user name and the pa$$word password.Connect-VIServer -Server 10.23.112.235 -Protocol https -Username 'Adminis!ra!or' -Password 'pa$$word'Running PowerCLI Cmdlets AsynchronouslyBy default, PowerCLI cmdlets return an output only after completion of the requested tasks. If you want a cmdlet to return to the command line immediately, without waiting for the tasks to complete, you can use the RunAsync parameter.When you use the RunAsync parameter, the cmdlet returns Task objects instead of its usual output. The Status property of a returned Task object contains a snapshot of the initial state of the task. This state is not updated automatically and has the values Error, Queued, Running, or Success. You can refresh a task state by retrieving the task object with the Get-Task cmdlet. If you want to observe the progress of a running task and wait for its completion before running other commands, use the Wait-Task cmdlet.Note In PowerCLI, the RunAsync parameter affects only the invocation of a cmdlet and does not control whether the initiated tasks run consecutively or in parallel. For example, the Remove-VM cmdlet might remove the selected virtual machines simultaneously or consecutively depending on the internal design of PowerCLI. To make sure that tasks initiated by a cmdlet run consecutively, run the cmdlet in a loop, each time applying it to a single object.Example: Running Remove-VM with and without the RunAsync parameter Remove-VM $vmListThe command returns no output when all virtual machines stored in the $vmList variable are removed, irrespective of whether they are removed simultaneously.Remove-VM $vmList -RunAsyncThe command returns an output that consists of one or more Task objects immediately.Managing Default Server ConnectionsBy default, PowerCLI and PowerCLI cmdlets run on the vCenter Server systems or vCloud Director servers you are connected to, if no target servers can be determined from the provided parameters.When you connect to a vCenter Server system by using Connect-VIServer, the server connection is stored in the $DefaultVIServers array variable. This variable contains all connected servers for the current PowerCLI session. To remove a server from the $DefaultVIServers variable, you can either use Disconnect-VIServer to close all active connections to this server, or modify the value of $DefaultVIServers manually.When you connect to a vCloud Director system by using Connect-CIServer, the server connection is stored in the $DefaultCIServers array variable. This variable contains all connected servers for the current session. To remove a server from the $DefaultCIServers variable, you can either use Disconnect-CIServer to close all active connections to this server, or modify the value of $DefaultCIServers manually.Customization Specification Objects in PowerCLIPowerCLI provides two types of objects for customization specification: persistent and nonpersistent.Persistent CustomizationPersistent customization specification objects are stored on the vSphere server. All persistent customization specifications created by using vSphere Client or VMware PowerCLI 4.1 or later are encrypted. Encrypted customization specifications can be applied only by the server that has encrypted them.Nonpersistent CustomizationNonpersistent customization specification objects exist only inside the current PowerShell process. Nonpersistent customization specification objects are not encrypted, but cloning them to a vSphere server encrypts them.Using ESXCLI with PowerCLIPowerCLI provides you the capability to use ESXCLI through its console.PowerCLI provides two approaches for working with ESXCLI:n Through the Get-ESXCli cmdlet, which provides direct access to the ESXCLI namespaces, applications, and commands.n Through .NET methods, which you use to create managed objects that correspond to specific ESXCLI applications. To access the ESXCLI, you can call methods on these managed objects.Note To call a method of an ESXCLI object, you must provide values for all parameters. If you want to omit a given parameter, pass $null as its argument.PowerCLI Inventory ProviderThe Inventory Provider is designed to expose an unfiltered inventory view of the inventory items from a server.It enables navigation and file-style management of the VMware vSphere inventory. By creating a PowerShell drive based on a managed object (such as a data center), you can obtain a view of its contents and the relationships between the items. In addition, you can move, rename, or delete objects by running commands from the PowerShell console.When you connect to a server with Connect-VIServer, the cmdlet builds two default inventory drives: vi and vis. The vi inventory drive shows the inventory on the last connected server. The vis drive contains the inventory of all vSphere servers connected within the current PowerCLI session.You can use the default inventory drives or create custom drives based on the default ones.PowerCLI Datastore ProviderThe Datastore Provider is designed to provide access to the contents of one or more datastores.The items in a datastore are files that contain configuration, virtual disk, and the other data associated with a virtual machine.When you connect to a server with Connect-VIServer, the cmdlet builds two default datastore drives: vmstore and vmstores. The vmstore drive provides a list of the datastores available on the vSphere server that you last connected to.Note If you establish multiple connections to the same vSphere server, the vmstore drive is not updated.The vmstores drive contains all datastores available on all vSphere servers that you connected to within the current PowerCLI session.You can use the default datastore drives or create custom drives based on the default ones.PowerCLI About ArticlesYou can learn more about some PowerCLI concepts and features from the built-in help articles named about articles. You can access them through a running PowerCLI process.Running Help About_* lists all built-in Windows PowerShell and VMware PowerCLI about articles.。

相关文档
最新文档