我正在尝试自动化Outlook Web Access网站,填写一些文本框并单击按钮,
我可以在第一页(登录)和提交按钮中找到相关元素,所以我通过了登录阶段,我的问题是找到带有蒙版文本框的某个页面内的元素,我附上了3个步骤的快照,以及对象的DOM图像.
$IE = New-Object -ComObject InternetExplorer.Application
$URL = 'https://somewebsite/ecp/?rfr=owa&p=PersonalSettings/Password.aspx'
$IE.Visible = $true
$IE.Navigate($URL)
While ($IE.Busy -eq $true) {Start-Sleep -Milliseconds 2000}
$ie.Document.getElementById('username').value = "username"
$ie.Document.getElementById('password').value = "password"
$Submit = $ie.Document.getElementsByTagName('Input') | ? {$_.Type -eq "Submit"}
$Submit.click()
Run Code Online (Sandbox Code Playgroud)
到目前为止这么好,我的问题从里面的页面开始,我只是找不到密码字段的textboxes元素,
这里还有这些元素的DOM快照:
我真的很感激任何帮助
public static void launchProcess(string processName, string arguments, out string output)
{
Process p = new Process
{
StartInfo = { UseShellExecute = false, RedirectStandardOutput = true, FileName = processName, Arguments = arguments }
};
p.Start();
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
Run Code Online (Sandbox Code Playgroud)
如果我的参数包含文件名,例如:
D:\Visual Studio Projects\ProjectOnTFS\ProjectOnTFS
Run Code Online (Sandbox Code Playgroud)
然后我得到错误:
根据此博客,我已经美化了Powershell ,但是Operator和Parameter如下所示为灰色:
所以我通过Set-PSReadlineOption以下方式更改它们的颜色:
Set-PSReadlineOption -TokenKind Operator -ForegroundColor Yellow
Run Code Online (Sandbox Code Playgroud)
但出现以下错误:
Set-PSReadLineOption:找不到与参数名称“ TokenKind”匹配的参数?
???? ?:1 ??:22
- Set-PSReadlineOption -TokenKind运算符-ForegroundColor黄色
- CategoryInfo:InvalidArgument:(:) [Set-PSReadLineOption]?ParameterBindingException
- FullyQualifiedErrorId:NamedParameterNotFound,Microsoft.PowerShell.SetPSReadLineOption
但是显示的帮助文件Set-PSReadlineOption显示它具有一个TokenKind参数,Operator而该参数又可以作为其参数。
我很困惑为什么会发生此错误。
我的powershell版本是
感谢您的任何建议!
我正在尝试使用PowerShell将触发器添加到现有的计划任务中。我正在使用Windows 10和PowerShell 5
当我跑步时:
Get-Scheduled-Job -Name TASK_NAME
Run Code Online (Sandbox Code Playgroud)
我收到错误:
>Get-ScheduledJob : A scheduled job definition with Name sanityInstaller could not be found.
At line:1 char:1
+ Get-ScheduledJob sanityInstaller
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-ScheduledJob], RuntimeException
+ FullyQualifiedErrorId : ScheduledJobDefinitionNotFoundByName,Microsoft.PowerShell.ScheduledJob.GetScheduledJobCommand
Run Code Online (Sandbox Code Playgroud)
看起来,即使我运行不带参数的相同命令,也可以返回所有作业,但返回的结果为空。
在Task Scheduler中,没有这样的文件夹/Microsoft/Windows/PowerShell/ScheduledJobs,即使在我创建它之后,它里面的新任务也不会返回它。
我在这里想念什么?
目标:当用户输入不在列表中的颜色时,它应默认为灰色.如果用户在列表中选择应该使用颜色的颜色.
实际发生的事情:颜色总是默认为灰色.
纯文本示例1:选择颜色:黄色,绿色,红色,紫色或灰色.用户:蓝色.输出:颜色为灰色.
纯文本示例2:选择颜色:黄色,绿色,红色,紫色或灰色.用户:绿色.输出:颜色为绿色.
[CmdletBinding()]
param (
[Parameter(Mandatory=$True, HelpMessage="Choose yellow, green, red, purple or gray")]
[string]$color_select
)
$colors_list = "yellow", "green", "red", "purple", "gray", "random"
if ($color_select -notcontains $colors_list) {
$color_select = "gray"
}
Write-host "The color is: $color_select"
Run Code Online (Sandbox Code Playgroud) powershell ×4
.net ×1
automation ×1
c# ×1
comobject ×1
file-io ×1
html ×1
if-statement ×1
psreadline ×1
windows ×1