How can I automate user input for a PowerShell command?

0
0
Asked By CuriousCoder93 On

Hey everyone! I'm looking for some help with automating a PowerShell command. I'm using `Invoke-ADSyncDiagnostics -PasswordSync`, but the script requires me to manually confirm a couple of prompts by pressing 'Y' and 'N'. Since I'm running this as a scheduled task, I'm trying to find a way to automate that input so I don't have to be there to hit those keys. I've attempted to use `Start-Job` with `System.Windows.Forms`, but I think I'm missing something or there's a more straightforward method. Appreciate any advice!

1 Answer

Answered By TechieTommy On

It looks like the script you’re dealing with may have been designed for interactive use only. They included `Read-Host` statements, which suggest they expect user input. Is there a specific reason you need to run this on a schedule? Normally, password sync should happen automatically without needing this command.

PowerPlayer88 -

You could consider pull out the necessary commands into your own script if most of it is related to interface logic.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.