# Script to validate credentials then start a program

**URL:** <https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983>\
**Category:** PowerShell Help\
**Created:** [March 18, 2020, 10:04am UTC](https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983 "2020-03-18T10:04:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![barios](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@barios](https://forums.powershell.org/u/barios)\
**Post date:** [March 18, 2020, 10:04am UTC](https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983/1 "2020-03-18T10:04:40Z")

</div>

Hello, I am trying to run a script to validate users credentials via a.d and then once validated it proceeds to run a program. At the moment, the credentials are being validated but the credentials are not being passed to run the program. The program launches with my userid rather than the entered domain user credentials.

&nbsp;

```
"$($_.Exception.Message)
```

---

<div class="post-metadata">

**Author:** ![wasif\_hasan](https://avatars.discourse-cdn.com/v4/letter/w/7ba0ec/32.png) [@wasif\_hasan](https://forums.powershell.org/u/wasif_hasan)\
**Post date:** [March 18, 2020, 10:31am UTC](https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983/2 "2020-03-18T10:31:12Z")

</div>

Your fault is you are not passing the credential using the variable $credential.

Fix the line starting powershell like this:

Start-Process “powershell.exe” -Credential $Credentials …

&nbsp;

---

<div class="post-metadata">

**Author:** ![barios](https://avatars.discourse-cdn.com/v4/letter/b/6bbea6/32.png) [@barios](https://forums.powershell.org/u/barios)\
**Post date:** [March 18, 2020, 10:58am UTC](https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983/3 "2020-03-18T10:58:24Z")

</div>

Hi,

Thank you for the update. I just tried that, and here is the error message:

Start-Process : This command cannot be run due to the error: The user name or password is incorrect.  
At C:\Users\myuserid\Documents\Confirm-Credentials.ps1:75 char:2

- Start-Process “powershell.exe” -Credential $Credentials -Argument …
- 

```auto

```

- CategoryInfo : InvalidOperation: (🙂 [Start-Process], InvalidOperationException
- FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

Although, i did enter the right username and password

---

<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:30pm UTC](https://forums.powershell.org/t/script-to-validate-credentials-then-start-a-program/13983/4 "2024-05-16T20:30:16Z")

</div>

Closed on May 16, 2024, 8:30pm UTC


