Remember Password Checkbox

Welcome Forums General PowerShell Q&A Remember Password Checkbox

This topic contains 2 replies, has 3 voices, and was last updated by

3 years, 5 months ago.

  • Author
  • #32549

    Topics: 2
    Replies: 1
    Points: 0
    Rank: Member

    A colleague of mine has written a powershell script to automate 10+ SQL SMS scripts she needs to run every Monday. The script works fine, but there is no code in the script to remember the username and password. It's not a big deal in terms of the script as the username and password are hardcoded in and never change. Later on in the week when SMS is launched it again prompts for a username and password because the script did not "remember" the credentials. Once it's been launched the first time, and the tick box rechecked, it works fine until the following Monday.
    To be fair, this really isn't a big deal in terms of workflow but we've both been looking around on the web and have come up empty handed, and it's become more an issue of curiosity.
    Is there a way to programmatically check the box to remember username and password?

  • #32551

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    PowerShell itself doesn't have a "remember password" feature because there's no place for it to safely store the password. This is assuming that you're collecting the credential using PowerShell's Get-Credential command.

    However, from your description, I have a vague sense that the credential isn't being used by PowerShell per se, but is being used by whatever is launching PowerShell. In that case, it's not really a PowerShell question. Thing is, I'm not sure what you're actually using to run the script. You said SQL SMS – but SQL Management Studio doesn't run scripts on a schedule. Do you mean SQL Server Agent? It depends a lot on how this is set up – but I'm pretty certain you're not actually running into a PowerShell problem.

  • #32560

    Topics: 47
    Replies: 156
    Points: 42
    Rank: Member
    $Username = "Domain\Username"
    $Password = ConvertTo-SecureString "PasswordGoesHere" -AsPlainText -Force
    $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
    invoke-command -computername LOCALHOST  -Authentication credssp -Credential $Cred {
    Put /run script here

    As above not really sure what / how your running, but if your running PS to launch the script you could try the above, just change local host to server name if its not ran locally

    A horrid way to do it but........

The topic ‘Remember Password Checkbox’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort