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++.

最新文章

  1. 用docker toolBox 搭建 nginx + flask + redis 环境
  2. [转]实体类(VO,DO,DTO)的划分
  3. How to change drive in cygwin
  4. Eclipse连接到My sql数据库的操作总结/配置数据库驱动
  5. 高性能JavaScript-JS脚本加载与执行对性能的影响
  6. 《FPGA零基础入门到精通视频教程》-第001b讲软件的破解
  7. 【Oracle】安装
  8. cc1plus: fatal error: emeralddb-pmdMain.d: No such file or directory
  9. Excel 提供数据 更新或者插入数据 通过函数 自动生成SQL语句
  10. 转:stringstream的用法
  11. Jquery常用操作:checkbox、select取值,radio、checkbox、select选中及其相关
  12. Python进阶5---StringIO和BytesIO、路径操作、OS模块、shutil模块
  13. asp.net MVC 上传文件 System.Web.HttpException: 超过了最大请求长度
  14. linux 分区方案
  15. Jsoup的学习
  16. 【代码笔记】iOS-自定义switch
  17. jpbm工作流框架
  18. iOS开发-编译出错 duplicate symbols for architecture x86_64
  19. POJ 2253
  20. Linux系统(X32)安装Oracle11g完整安装图文教程另附基本操作

热门文章

  1. Python科学计算三维可视化(整理完结)
  2. Meet in the middle算法总结 (附模板及SPOJ ABCDEF、BZOJ4800、POJ 1186、BZOJ 2679 题解)
  3. Codeforces 1093D(染色+组合数学)
  4. 道路识别demo
  5. Springboot2.x整合SpringSecurity
  6. css中一些文本属性的用法
  7. vue 踩坑之组件传值
  8. USTC现代软件工程--summary
  9. 二、RabbitMQ操作
  10. 【学术篇】bzoj2440 [中山市选2011]完全平方数