I'm working on a PowerShell script with the 1Password CLIv2. I need it to login automatically.

The command I'm using is:

Invoke-Expression $(op signin)

Right now it stops here:

PS C:\Users\MyDirectory\Downloads> .\Test.ps1
Enter the password for [email protected] at domain.1password.com:

I need to throw in the password automatically and let the script continue.

1

There are 1 best solutions below

1
On

Ok. I came across something that cleared this up. Make one script file (test.ps1) containing this:

$wshell = New-Object -ComObject wscript.shell;

$wshell.AppActivate('Your Title')

Sleep 4

$wshell.SendKeys('password1234')

$wshell.SendKeys('~')

Then make another script file(test2.ps1) containing whatever you need the password for and whatever you want to accomplish:

Invoke-Expression $(op signin)

Then put this into the PS prompt:

.\Test.ps1; .\Test2.ps1

And Bob's your uncle, you're done.