请问下 windows下cmd调用ps脚本报错 2


QQ截图20160816200407

请帮忙看看这么cmd调用有问题么,该如何调用

cmd 调用命令为

del exportlog-vds.log
powershell -psc “e:\scripts\vim.psc1” “.\vDSbak.ps1” >> exportlog-vds.log

 

powershell脚本为

Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
Import-Module VMware.VimAutomation.Vds

$vcenter = “172.17.232.112”
$vcenteruser = “work”
$vcenterpw = “1420”
# Connect to vCenter Server
connect-viserver $vcenter -User $vcenteruser -Password $vcenterpw

# Get the vNetwork Distributed switches
$switches=get-vdswitch
#
# Perform the backups
foreach ($switch in $switches)
{
#
# Backup each vNetwork Distributed Switch not including the port groups
export-vdswitch $switches -Withoutportgroups -Description “Backup of $switch without port groups” -Destination “e:\scripts\$switch.without_portgroups.$date.zip”
#
# Backup each vNetwork Distributed Switch including the port groups
export-vdswitch $switches -Description “Backup of $switch with port groups” -Destination “e:\scripts\$switch.with_portgroups.$date.zip”
#
# Backup each port group individually
get-vdswitch $switches | Get-VDPortgroup | foreach { export-vdportgroup -vdportgroup $_ -Description “Backup of port group $($_.name)” -destination “e:\scripts\$($_.name).portgroup.$date.zip”
}
}

 

 

 

 

 

 

 

 

scripts

本文链接: https://www.pstips.net/%e8%af%b7%e9%97%ae%e4%b8%8b-windows%e4%b8%8bcmd%e8%b0%83%e7%94%a8ps%e8%84%9a%e6%9c%ac%e6%8a%a5%e9%94%99.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

回复 Mooser Lee 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

2 条评论 “请问下 windows下cmd调用ps脚本报错