PowerCLI

最近需要用命令行操作VMWare,现将一些经常用的命令记录一下。安装VMWare命令很简单,不再像原来需要单独下载PowerCLI安装包,直接在Powershell Gallery里在线安装即可。

# 连接

Connect-VIServer -Server prod-corp-vc

# 克隆虚拟机

New-VM -VM $source -Name $destination -VMHost ‘prod-ctc-esx-bk1.cotoso.com‘ -DiskStorageFormat Thin -Datastore ‘DATA1‘ -RunAsync

# 正常关闭VM

Shutdown-VMGuest -VM test-dc1-bk

Stop-VMGuest -VM test-dc1-bk

# 拔电源

Stop-VM -VM test-dc1-bk

# 导出虚拟磁盘大小

Get-VM -Location CTC | Get-HardDisk | select Parent, Filename, CapacityGB, StorageFormat

# 导出虚拟磁盘实际使用大小

Get-VM -Location CTC | select name,@{n=‘ProvisionedSpaceGB‘;e={[math]::Round($_.ProvisionedSpaceGB)}},@{n=‘UsedSpaceGB‘;e={[math]::Round($_.UsedSpaceGB)}}

# 获取最近的task

Get-Task

# 获取快照

Get-VM -Location vm | Get-Snapshot | select vm, name, description

# 删除快照

Get-Snapshot -VM prod-chn-abc | Remove-Snapshot

原文地址:https://www.cnblogs.com/IvanChen/p/8330188.html

时间: 2024-08-30 17:41:26

PowerCLI的相关文章

vmware PowerCLi 使用 和 示例

这几天研究PowerCLI,积累了几个例子,记下来,以便以后或者大家使用.部分例子来着网络,具体出处参考附录 1 获取vm 磁盘 和磁盘对应的datastore的信息 这个例子可以针对一台虚机有多个磁盘,但每个磁盘可能所属datastore不同,所以需要列出来查看 Get-VM | %{ $_.HardDisks | Select @{N="VM";E={$_.Parent.Name}}, Name, @{N="DS";E={$_.Filename.Split(']

Add PortGroup to all hosts in cluster with PowerCLI

http://discoposse.com/2013/02/14/powercli-add-multiple-vlan-port-groups-to-vsphere-cluster-standard-switches/ Limitations of Standard vSwitches One of the negative points of standard vSwitches is that there are as many of them as there are ESX hosts

如何使用Powercli管理主机License (vSphere 5.5)

首先当然是下载VMware vSphere PowerCli, 安装好以后就可以进行了. 1,设置执行策略 用管理员模式打开Windows Powercli, 输入命令 Set-executionpolicy remotesigned 2,管理员模式打开VMware vSphere PowerCli 连接到VC,使用命令如下: Connect-VIServer -Server IPADDRESS -User admin -Password pass 3,获取现有License get-vmhos

vsphere powerCLI

vsphere PowerCLI安装完成后,桌面上会多出两个图标,运行VMware vSphere PowerCLI 在首次运行时可能会出错,如下图, 使用get-executionpolicy查看状态确实为Restricted 使用set-executionpolicy将属性从Restricted更改为remotesigned,如下图,完成后,将此窗口关闭 再次启动后,就可以看到正常的界面了,如下图. 接着就可以通过相关命令来管理虚拟化平台,在管理之前需添加服务器,命令如下:connect-v

PowerCLI: “WARNING: There were one or more problems with the server certificate”

使用"VMware vSphere PowerCLI"连接vCenter Server,该主机加入到 域内,并且使用 默认 证书,执行" Connect-Viserver <team_vCenter_Server_system_FQDN>" 见出现如下警告! 1:57:08 AM Connecting to VI Server WARNING: There were one or more problems with the server certifi

虚拟化--056 powercli 执行remotesign失效

056 powercli 执行remotesign失效

使用powercli批量从模板克隆虚拟机

首先要安装powercli,在安装powercli之前可先把Windows Management Framework 4.0安装好,安装完成后,重启电脑,多等一会,后台起服务有点慢. 1.配置powercli可以执行远程脚本 Set-ExecutionPolicy RemoteSigned 2.连接VCENTER服务器 Connect-VIServer 172.16.15.205  会弹出一个输入用户名和密码的窗口,输入vcenter的登录名和密码.提示按"是""否"

Powercli批量创建删除虚拟机快照

注意事项: 1.客户端需要安装vmware powercli client 2.连接vcenter或esxi主机的用户需要具有连接和创建删除快照权限 1.创建虚拟机快照 #添加vmware module command Add-PSSnapin -Name *vmware* #填写连接相关信息,按要求输入vcenter/esxi 服务器ip 用户名 密码 $vcenterip = Read-Host "请输入vcenter/esxi服务器ip......" $domainname = 

PowerCLI Extend Disk

Script ------------------------------------------------------------------------------------------ # PowerCLI-Extend-Disks.ps1# Must be run in VMware PowerCLI# Written by Jason Pearce, www.jasonpearce.com, (2015 June)# Inspiration from Brian Wuchner,

vSphere PowerCLI安装使用

安装vSphere PowerCLI过程中提示如下: The PowerShell execution policy of this computer is not set to "RemoteSigned".This prevents execution of PowerShell scripts on your computer and will result in errors when VMware vSphere PowerCLI is invoked.It is recom