PowerCLI脚本批量和一些常用自动化操作脚本
发表于:2025-02-12 作者:千家信息网编辑
千家信息网最后更新 2025年02月12日,一、使用指定模板批量创建虚拟机#定义参数param([string]$VMname,[string]$vmhostname,[string]$datastore,[string]$template)#
千家信息网最后更新 2025年02月12日PowerCLI脚本批量和一些常用自动化操作脚本
一、使用指定模板批量创建虚拟机
#定义参数param([string]$VMname,[string]$vmhostname,[string]$datastore,[string]$template)#在命令窗口中添加powercli模块try{add-pssnapin vmware.vimautomation.core -ErrorAction SilentlyContinue}catch{}#连接VsphereConnect-VIServer -server Vsphere -Protocol https -User user -Password passwordforeach ($i in 1..5){$fullname = $VMname +"-"+ $inew-vm -name $fullname -template $template -host $vmhostname -datastore $datastore}disconnect-viserver -confirm:$false执行文件时.\scriptfile.ps1 VMname vmhost datastore template#不声明参数时,必须按照param指定的顺序输入参数or.\screptfile.ps1 -VMname vmname -template template -vmhostname vmhost -datastore datastore#对参数声明时,参数顺序可随意变动
二、批量重启正在运行具有名字相似可以进行匹配的的虚拟机
#在命令窗口中添加powercli模块try{add-pssnapin vmware.vimautomation.core -ErrorAction SilentlyContinue}catch{}#连接VsphereConnect-VIServer -server Vsphere -Protocol https -User user -Password password#定义正则表达式$matchname="^[a-zA-Z]+\d{5}([a-zA-Z]{1,4})?(\w)?([a-zA-Z]{3})?(\d+)?"#重启匹配的虚拟机Get-Cluster -Name cluster |Get-VM |where {$_.Name -match $matchname -and $_.PowerState -eq "PoweredOn"} | Restart-VM -RunAsyncdisconnect-viserver -confirm:$false
参数
命令
模块
顺序
脚本
相似
名字
文件
模板
正则
正在
表达式
变动
输入
运行
常用
自动化
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
四川大学招聘软件开发工程师
济南嵌入式软件开发哪家好
信通院数据库发展研究报告
海南德溢网络技术有限公司
数据库中不存在顶级区划
平谷区正规软件开发设置
2 常见的软件开发模型有哪些
追剧达人 服务器
网络安全swot
2022年网络安全比赛
数据库本地文件是什么
爆炸性参数数据库
数据库服务名称打不开
密云区信息网络技术推广哪里来
丝绸之路网络安全技能
宁夏软件开发公司价格
工业互联网与博彦科技
校园网网络安全分析与防范
为什么有人喜欢计算机网络技术
服务器语言介绍
网络安全法 日志
软件开发的别名叫什么
安徽网络技术转让询问报价
不能绕过服务器端的mime检测
独立设置自动连接服务器
数据库市场是一次信息市场对吗
广州蜀山网络技术 上班
如何防范服务器安全
深圳市旺旺互联网科技
数据中心服务器供电拆解