2
I developed several Powershell scripts to automate the configuration of machines I work on, speeding up and avoiding the heavy work of manually setting up a giant number of stations. Basically they use UAC disable, autologon and Task Scheduler.
The biggest problem is the use of the Fortinet Firewall that asks for authentication via browser, as most of the application uses files to install the server via SMB, it is necessary to do this authentication. However, when testing this by Selenium it even performs authentication, but after the computer restarts and runs the next script, it asks again for authentication.
It follows the code I made to authenticate in Fortnet, which after login, makes a request on the website globe.com
############################################
######## 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
When we do it manually, the next steps run normally, which by my conclusion makes the Selenium driver not actually Google Chrome, but one of its own, which makes it not recognize the authentication...
The question that remains is: It is possible to add this option in the script so that we can authenticate in Fortinet Web and thus avoid manual steps and run our work even more automated?
Thank you!
Bye, good night, if you do not answer, is not in the desired scope, comment, I see no problem in deleting the answer.
– It Wasn't Me
Opa my friend. Actually meets yes, but at the moment I am traveling within my state and can not test. When back I can implement. I didn’t think about using vbs, because I didn’t know. You can let me use.
– Paulo Rezende
Thank you so much for the comment/reply, I thought you were looking for a solution within the cited "platforms", which I do not.
– It Wasn't Me