Powershell , CLIv2: Need to automate login with hard coded password

TimmyFangs
TimmyFangs
Community Member

Hello!
I'm working on a project where I am using PowerShell running a PowerShell script on Windows 11. I need to use the CLI to automatically login with the password with no user interaction. This is just a simple cron job to run in the background. I have found another post about this here, but it is outdated and simply does not work. Please help!


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided

Comments

  • TimmyFangs
    TimmyFangs
    Community Member

    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.

This discussion has been closed.