请帮忙看看这么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”
}
}
你只说报错,能把你的错误贴出吗?
先 >> exportlog-vds.log去掉
再把“.\vDSbak.ps1”用全路径。