Powercli随笔 - PowerCLI script to sequentially Storage vMotion VMs from a CSV File
PowerCLI script to sequentially Storage vMotion VMs from a CSV File
This is a PowerCLI script that I use to Storage vMotion (s/vmotion) VMs from an input file (CSV File). This helps me evacuate VMs from a datastore that will be decommissioned and this serves like an automation. With this, I do not have to log back to vCenter and manually do storage migrations. This also have a lesser performance impact compared to simultaneously queuing storage migrations manually in case this will be done on non-peak hours.
1
2
3
4
5
6
7
8
|
$VMsToRelocate = Import-Csv "ListOfVMsToRelocate.csv" $Datastore = Get-Datastore -Name "datastore_name" foreach ( $VM in $VMsToRelocate ) { Write-Host "Relocating VM:" $VM .Name "to" $Datastore Get-VM -Name $VM .Name | Move-VM -datastore $Datastore > $null } Write-Host "Completed!" |
Note that the CSV file must have a Header called Name, below is an example.
1
2
3
4
|
Name VM1 VM2 VM3 |
If you want to export the list of VMs that you want to migrate, you can use RV Tools to generate a VM Inventory, export the list to MS Excel, do your filtering there (such as filter by the storage path), and I personally like to sort them by used size (in MB), then simply copy-paste to the CSV file. You do not need to create the CSV file in Excel, I use Notepad++.
最新文章
- 用docker toolBox 搭建 nginx + flask + redis 环境
- [转]实体类(VO,DO,DTO)的划分
- How to change drive in cygwin
- Eclipse连接到My sql数据库的操作总结/配置数据库驱动
- 高性能JavaScript-JS脚本加载与执行对性能的影响
- 《FPGA零基础入门到精通视频教程》-第001b讲软件的破解
- 【Oracle】安装
- cc1plus: fatal error: emeralddb-pmdMain.d: No such file or directory
- Excel 提供数据 更新或者插入数据 通过函数 自动生成SQL语句
- 转:stringstream的用法
- Jquery常用操作:checkbox、select取值,radio、checkbox、select选中及其相关
- Python进阶5---StringIO和BytesIO、路径操作、OS模块、shutil模块
- asp.net MVC 上传文件 System.Web.HttpException: 超过了最大请求长度
- linux 分区方案
- Jsoup的学习
- 【代码笔记】iOS-自定义switch
- jpbm工作流框架
- iOS开发-编译出错 duplicate symbols for architecture x86_64
- POJ 2253
- Linux系统(X32)安装Oracle11g完整安装图文教程另附基本操作