powershell - Powershell脚本将文件导入文件选择文件按钮
问题描述
我正在尝试自动化我需要从网站执行的日常导入。一台服务器正在向网络驱动器生成文件,我想使用特定凭据访问网站日志,然后单击按钮从该网络驱动器输出文件。
我可以登录网站进入正确的页面等。但是当我需要单击“选择文件”并在脚本中选择它时我很挣扎。有没有办法用 PowerShell 做到这一点?
路径将始终相同,因此脚本中没有输入。网络路径将类似于
S:\Projects\Link\Uploads\Scheduled_Extracts
该网站的代码是:网站代码
我不确定什么对你有帮助,我正在考虑使用:typedef enum ShellSpecialFolderConstants
但不确定如何。
到目前为止,我的代码如下所示:
$username = Read-Host " Please Enter your email address "
$password = Read-Host -AsSecureString " Please Enter your pasword "
$password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) # translate encrypt password
$ie.Navigate("Website.com")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3;}
$usernamefield = $ie.document.getElementByID('username')
$usernamefield.value = "$username"
$passwordfield = $ie.document.getElementByID('password')
$passwordfield.value = "$password"
$Link = $ie.document.getElementByID('_submit')
$Link.click()
Start-Sleep -Seconds 3
$ie.Navigate("Website.com\revelantpPage")
Start-Sleep -Seconds 3
$typefield = $ie.document.getElementByID('import_form_type')
$typefield.value = "2"
# selection of the file
对不起,我真的是PowerShell的初学者
解决方案
推荐阅读
- java - 速度 split() 和数组显示,连接语法
- python - 如何对 Elasticsearch 的返回结果进行排序
- r - 在 R 中添加许多具有给定斜率和截距的直线(lmer 包的输出)
- javascript - 如何从其他类别中随机选择一个类别的考试 2 项?
- flutter - VSCode、Flutter SDK 版本错误?
- python - 熊猫漂浮在扩展窗口中不能被强制
- java - 恶意代码漏洞 - 可能通过返回对 int[] 的可变对象的引用来暴露内部表示
- java - 尝试设置颜色的 alpha 值会改变颜色
- r - 多面板网络图使用循环?
- python - 无法在 Bep20 代币上获取准确的代币数量