# How to pass on credentials to windows security pop up for signing in

**URL:** <https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025>\
**Category:** PowerShell Help\
**Created:** [February 9, 2017, 1:07pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025 "2017-02-09T13:07:35Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandeep333](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sandeep333](https://forums.powershell.org/u/sandeep333)\
**Post date:** [February 9, 2017, 1:07pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/1 "2017-02-09T13:07:35Z")

</div>

Basically there is a requirement, where i need to login to a web portal by passing on credentials through windows security pop up (like what we have to login for tomcat admin service console) & then click on a reload button on the next screen.

The script for clicking on the Reload button works fine but the problem is i have to manually login through the windows pop up & keep one active session open all the time & this is not possible when i want to add this script to a task scheduler.

The moment it tries to open [http://localhost:9001/test/Admin/RuntimeParameters.jsp](http://localhost:9001/test/Admin/RuntimeParameters.jsp) this is where it pops up with the windows security box & there is no way known to me to pass on the creds to this section. I need help for this piece.

```
$ie = New-Object -com InternetExplorer.Application 
	$ie.visible=$false
	$ie.navigate("http://localhost:9001/test/Admin/RuntimeParameters.jsp")
	start-sleep 4
	while($ie.ReadyState -ne 4) {start-sleep -m 100} 
	$ie.document.getElementById("Reload").Click()
	if ($? -eq "True")
		{
		Write-host "Reload of the Admin page completed successfully" -ForegroundColor green
		Write-output "Reload of the Admin page completed successfully"
		exit
		}
		else
		{
		Write-host "Reload of the Admin page Failed" -ForegroundColor red
		Write-output "Error: Reload of the Admin page Failed"
		exit
		}
```

So i need help to know as how can we pass on credentials through PS script to login through a windows security pop up window not sure how PS can interact with this pop up window.

Thanks for checking & providing expert advise.

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [February 11, 2017, 11:58am UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/2 "2017-02-11T11:58:13Z")

</div>

You can try to pass username and password in the URL.

Example:

```
http://monitoruser:Pa55w0rd@localhost:9001/test/Admin/RuntimeParameters.jsp
```

Just make sure the username and password don’t include the following single characters

: @ /

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [February 11, 2017, 12:01pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/3 "2017-02-11T12:01:59Z")

</div>

The other alternative would be to use the Invoke-WebRequest cmdlet if you don’t need to display the page on a screen.

```
$creds = Get-Credential
$response = Invoke-WebRequest -UseBasicParsing -Uri http://localhost:9001/test/Admin/RuntimeParameters.jsp -Credential $creds
# do something with the response
```

---

<div class="post-metadata">

**Author:** ![sandeep333](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sandeep333](https://forums.powershell.org/u/sandeep333)\
**Post date:** [February 14, 2017, 2:56pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/4 "2017-02-14T14:56:41Z")

</div>

Thanks Daniel for the response but it seems, current version of IE doesn’t support this method of passing on the creds through URL anymore ☹

---

<div class="post-metadata">

**Author:** ![sandeep333](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sandeep333](https://forums.powershell.org/u/sandeep333)\
**Post date:** [February 14, 2017, 3:35pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/5 "2017-02-14T15:35:47Z")

</div>

Hi Daniel, instead of Invoke-WebRequest i tried this which allows to login & allows to fetch the web page code details instead of popping up the web page itself.

```
$url = "http://localhost:9001/test/Admin/RuntimeParameters.jsp"
$user = "username"
$pass = "pass"
$secPass = convertTo-secureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user,$secPass)

$data = Invoke-RestMethod $url -Credential $cred
```

However, is there way to open the web page after it logs in like i had $url.visible=$true using $ie = New-Object -com InternetExplorer.Application & the navigating to this URL. I guess we cannot merge two invoke requests in the same method.

Please advise.

---

<div class="post-metadata">

**Author:** ![sandeep333](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sandeep333](https://forums.powershell.org/u/sandeep333)\
**Post date:** [February 15, 2017, 3:04pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/6 "2017-02-15T15:04:28Z")

</div>

I can use both the invoke methods & assume am able to login fine but that’s all happening in the background.

The requirement is to click on a particular button on this web page after i am logged in into this webpage.

Tried both & get runtime error

```
$url = "http://localhost:9001/test/Admin/RuntimeParameters.jsp"
$user = "username"
$pass = "pass"
$secPass = convertTo-secureString $pass -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user,$secPass)

$response = Invoke-WebRequest -UseBasicParsing -Uri $url -Credential $cred

Write-host $response.StatusCode
$Link=$response.Document.getElementByID("Reload").Click
```

Also tried -

```
$Link=$response.Document.getElementsByTagName("input") | where-object {$_.type -eq "submit"}
$Link.click()
```

I am trying to click The actual button from the html code from the web page is

```
form action = "#" method="POST"
input type="submit" value="Reload" name="Reload"
```

---

<div class="post-metadata">

**Author:** ![daniel-krebs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/daniel-krebs/32/484_2.png) [@daniel-krebs](https://forums.powershell.org/u/daniel-krebs)\
**Post date:** [February 16, 2017, 5:09am UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/7 "2017-02-16T05:09:45Z")

</div>

Thanks for the update. I think you’ll need to look at Selenium which is web browser automation framework ([http://www.seleniumhq.org/](http://www.seleniumhq.org/)) and it is free as far as I know.

---

<div class="post-metadata">

**Author:** ![awpbettsgmail-com](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@awpbettsgmail-com](https://forums.powershell.org/u/awpbettsgmail-com)\
**Post date:** [February 17, 2017, 5:02am UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/8 "2017-02-17T05:02:32Z")

</div>

Have you tried

```
Get-Credential | Export-Clixml -Path
```

This will bring up the UN/PW windows dialogue box. When you enter your credentials, this will write the UN and PW to an encrypted text file (as stipulated by your given path). For instance

Get-Credential | Export-Clixml -Path C:\Cred\EncryptedCredentials.txt

You can then add the content of this file to a variable in your script.

```
$MyCredential = Import-Clixml -Path C:\Cred\EncryptedCredentials.txt
```

Which can later be refeferenced by a -credentials parameter in your script.

This works fine for me when running scripts that need to authenticate against an externeal FTP server.

Caveat: The acount you are logged in within when you create the encrypted credentials will need to be the same account you want to run the scripts under.

---

<div class="post-metadata">

**Author:** ![awpbettsgmail-com](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@awpbettsgmail-com](https://forums.powershell.org/u/awpbettsgmail-com)\
**Post date:** [February 17, 2017, 6:22am UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/9 "2017-02-17T06:22:02Z")

</div>

\*need to run the scripts under.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:39pm UTC](https://forums.powershell.org/t/how-to-pass-on-credentials-to-windows-security-pop-up-for-signing-in/8025/10 "2024-05-16T20:39:29Z")

</div>


