I'm working on Powershell script. I want when I execute script to do: 1. Open webpage 2. Bypass warning screen on page 3. Click to Login button 4. Select first certificate & enter PIN & login
Code:
$pin = "666666"
$web = Get-Random -Input https://xxx.sk, https://yyy.sk, https://zzz.sk
$ie = New-Object -ComObject 'internetExplorer.Application'
$ie.Visible= $true
$ie.Navigate("$web")
while ($ie.Busy -eq $true){Start-Sleep -seconds 1;}
#bypass warning
$warning = $ie.Document.getElementByID("overridelink")
$warning.click()
while ($ie.Busy -eq $true){Start-Sleep -seconds 2;}
$login=$ie.Document.getElementByID("LoginButton")
$login.click()
while ($ie.Busy -eq $true){Start-Sleep -seconds 2;}
if($(Get-Process | Where {$_.MainWindowTitle -match "https*" -AND $_.Name -match "iexplore"}))
{
#Select first certificate and enter OK
[void] [System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
Start-Sleep -seconds 5
#Enter a PIN and enter OK
[System.Windows.Forms.SendKeys]::SendWait("$pin")
Start-Sleep -seconds 5
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")#
}
else
{
Write-Host "*** Internet Explorer is not running. ***"
}
Everything works fine until selecting certificate and enter pin. There is a problem. Script can't select certificate. I want execute script on background while I will do another things... Title of pop up window is Windows Security
Thanks for help.
Aucun commentaire:
Enregistrer un commentaire