Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel未使用powershell脚本中的refreshall方法进行刷新_Excel_Powershell - Fatal编程技术网

Excel未使用powershell脚本中的refreshall方法进行刷新

Excel未使用powershell脚本中的refreshall方法进行刷新,excel,powershell,Excel,Powershell,我有一个PowerShell脚本,它将excel从SharePoint刷新到共享驱动器位置。我正在通过.bat文件传递凭据,但当我使用$excelworkbook.RefreshAll()方法并提示再次输入凭据时,凭据未传递到excel。如果从refreshall中删除括号,则脚本将运行,但不会刷新图纸数据 我们将感谢您的帮助。 问候, 拉朱 我已通过将连接详细信息放在internet explorer的“本地连接”选项卡中解决了问题。请在此处发布您的脚本$excel=new object-co

我有一个PowerShell脚本,它将excel从SharePoint刷新到共享驱动器位置。我正在通过
.bat
文件传递凭据,但当我使用
$excelworkbook.RefreshAll()
方法并提示再次输入凭据时,凭据未传递到excel。如果从refreshall中删除括号,则脚本将运行,但不会刷新图纸数据

我们将感谢您的帮助。
问候,
拉朱


我已通过将连接详细信息放在internet explorer的“本地连接”选项卡中解决了问题。

请在此处发布您的脚本$excel=new object-comobject-excel.Application$excel.visible=$true$fname=拆分路径$workbookpath-Leaf storedp“$destpath”“刷新工作簿”$tempPath=“c:Temp\Autosys”复制项目“$workbookpath”“$tempPath”$excelworkbook=$excel.workbooks.Open($tempPath\$fname”)#数据连接$excelworkbook$excelworkbook.RefreshAll()而($excelworkbook.ODBCConnection.Refreshing){开始睡眠-秒1}$excelworkbook.save()$excelworkbook.close()$excel.quit()Hi Manu,添加了代码。请帮助编辑您的第一篇文章,因为在评论中,代码无法阅读,因为没有再次格式化,请发布您的脚本以向其他有相同问题的人提供答案。上面发布了脚本,没有更改
$excel = new-object -comobject Excel.Application

$excel.visible = $true

$fname = Split-Path $workbookpath -Leaf

storedp "$destpath" "Refreshing workbook"

$tempPath = "c:Temp\Autosys"
Copy-Item "$workbookpath" "$tempPath"
$excelworkbook = $excel.workbooks.Open("$tempPath\$fname")   
$excelworkbook.RefreshAll()  


while ($excelworkbook.ODBCConnection.Refreshing)
{
  Start-Sleep -Seconds 1
}

$excelworkbook.save()
$excelworkbook.close()
$excel.quit()
$DSN = $args[0]
$DB = $args[1]
$DB_User = $args[2]
$DB_Password = $args[3]
$SQLServerPwd = $args[4]
$NetworkPwd = $args[5]
$SingleOrBulk = $args[6]
$Filename = $args[7]
$OutFilename = $args[8]
$Dated = $args[9]
$DateFormat = $args[10]
write-host "DSN = $DSN"
write-host "DB = $DB"
write-host "DB_User = $DB_User"
write-host "DB_Password = $DB_Password"
write-host "SQLServerPwd = $SQLServerPwd"
write-host "NetworkPwd = $NetworkPwd"
write-host "SingleOrBulk = $SingleOrBulk"
write-host "Filename = $Filename"
write-host "OutFilename = $OutFilename"
$pass= $NetworkPwd | ConvertTo-SecureString -AsPlainText -Force   
$cred=New-Object System.Management.Automation.PSCredential('test@prod',$pass)
New-PSDrive -Name P -PSProvider FileSystem -Root "\\testprod.md.net\GroupShares\Global\PA" -Credential $cred

$cred=New-Object System.Management.Automation.PSCredential('test@dev',$pass)