如何通过Powershell/Selenium Chrome驱动程序验证防火墙网页?
我在Powershell中开发了几个脚本,以自动配置我工作的机器,简化并避免手动配置大量工作站的繁重工作。基本上,他们使用禁用UAC、自动登录和任务调度程序 图片: 最大的问题是使用要求通过浏览器进行身份验证的Fortinet防火墙,因为大多数应用程序使用通过SMB安装在服务器上的文件进行安装,所以有必要进行此身份验证,因为没有它,算法无法向服务器进行身份验证,导致它在课程中失败 图片: 页面URL: 然而,通过Selenium进行测试,它甚至可以进行身份验证,但在计算机重新启动并运行下一个脚本后,它会再次要求进行身份验证 按照我在Fortnet中进行身份验证的代码,在登录后,在globo.com站点中发出请求如何通过Powershell/Selenium Chrome驱动程序验证防火墙网页?,powershell,selenium,batch-file,selenium-webdriver,vbscript,Powershell,Selenium,Batch File,Selenium Webdriver,Vbscript,我在Powershell中开发了几个脚本,以自动配置我工作的机器,简化并避免手动配置大量工作站的繁重工作。基本上,他们使用禁用UAC、自动登录和任务调度程序 图片: 最大的问题是使用要求通过浏览器进行身份验证的Fortinet防火墙,因为大多数应用程序使用通过SMB安装在服务器上的文件进行安装,所以有必要进行此身份验证,因为没有它,算法无法向服务器进行身份验证,导致它在课程中失败 图片: 页面URL: 然而,通过Selenium进行测试,它甚至可以进行身份验证,但在计算机重新启动并运行下一个脚本
############################################
######## Enable Fortinet Firewall ##########
############################################
$YourURL = "https://authenticator.mpms.mp.br/"
# Adds the path for ChromeDriver.exe to the environmental variable
$env:PATH += ";C:\Util\PSL\"
# Adding Selenium's .NET assembly (dll) to access it's classes in this PowerShell session
Add-Type -Path "C:\Util\PSL\WebDriver.dll"
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)
$ChromeDriver.Capabilities.BrowserName
# Browse to the specified website
$ChromeDriver.Navigate().GoToURL($YourURL)
# Methods to find the input textbox for google search and then to type something in it
$ChromeDriver.FindElementByName("username").SendKeys("username")
$ChromeDriver.FindElementByName("password").SendKeys("password")
$ChromeDriver.FindElementsByClassName("submit").Submit()
#### New page #####
$YourURL = "https://www.globo.com/"
$ChromeDriver.Navigate().GoToURL($YourURL)
Function Stop-ChromeDriver {Get-Process -Name chromedriver -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue}
# Close selenium browser session method
$ChromeDriver.Close()
# End ChromeDriver process method
$ChromeDriver.Quit()
# Function to make double sure the Chromedriver process is finito (double-tap!)
Stop-ChromeDriver
当我们手动执行此操作时,接下来的步骤将正常运行,根据我的结论,这使得Selenium驱动程序实际上不是Google Chrome浏览器,而是它自己的浏览器,这意味着它无法识别身份验证
剩下的问题是:是否可以在脚本中添加此选项,以便我们可以通过Fortinet Web验证,从而避免手动步骤并自动化我们的工作?我希望我可以为Powershell执行此任务,但我还有其他选择
谢谢大家! 为什么不在PowerShell`中使用vbs发送所需授权
$wshell=新对象-ComObject wscript.shell$obj=newobject-comwscript.Shell;
$wshell.AppActivate('Chrome');
路径127.0.0.1-n-q 1-p 300>$null
$obj.SendKeys('paulogoncalves');
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys(“{TAB}”)
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys('senhasecreta')
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys({ENTER}')```
为什么不在PowerShell`中使用vbs发送所需的授权
$wshell=新对象-ComObject wscript.shell$obj=newobject-comwscript.Shell;
$wshell.AppActivate('Chrome');
路径127.0.0.1-n-q 1-p 300>$null
$obj.SendKeys('paulogoncalves');
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys(“{TAB}”)
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys('senhasecreta')
路径127.0.0.1-n-q 1-p 150>$null
$obj.SendKeys({ENTER}')```