Protect what matters – even after you're gone. Make a plan for your digital legacy today.
Forum Discussion
Anonymous
4 years agoPowershell , CLIv2: Need to automate login with hard coded password
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 ...
Anonymous
4 years agoOk. 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.