This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using a custom password generation script

Hi,

I would like to use a custom password generation script written using powershell.

The custom script is essential just a copy of the default, but I swapped the "New-Password" function with my own and then deleted some of the other checks the default script does.

The password generation piece is another script I found online that I tweaked slightly to meet my requirements.

The new script also needs to reference a CSV file.

I have two questions regarding this:

  • Can you reference a CSV file stored locally on the C: drive of the ARS server from within a script module? Or is it possible to store the file inside ARS itself? If the file can be stored inside ARS, how is it referenced?
  • How can I test this new password generation script in ARS? It appears that we have already blocked the builtin "Built-in Policy - Password Generation" and created our own policy that appears to just be a copy of the default. I tried changing the script that the custom policy runs, but it still generates the same passwords.

function Create-Password
{ 
    
    $rand = New-Object System.Random

    # read-in very large file creating smaller list of random words
    $words = Get-Content "C:\Scripts\Generation\clean_words.csv" | Sort-Object {Get-Random} -unique | select -first 100

    # query the smaller list of words for single entry (2 times)
    $word1 = $words | Sort-Object {Get-Random} -unique | select -first 1  
    $word2 = $words | Sort-Object {Get-Random} -unique | select -first 1
    $word3 = $words | Sort-Object {Get-Random} -unique | select -first 1
  
    # create random digits
    $number1 = Get-Random -Minimum 10 -Maximum 99
  
    # get random special character
    $special = Get-Random -InputObject "!","@","#","$","%","&","*"

    # Recreate word 2
    $word2 = $word2.Substring(0,1).toupper() + $special + $word2.Substring(1,$word2.Length-1)

    # concatenante and return new random password
    return (Get-Culture).TextInfo.ToTitleCase($word1) + $word2 + (Get-Culture).TextInfo.ToTitleCase($word3) + $number1

}

Thank you,

Cheers

Parents
  • Hi,

    This was resolved. The process goes something like this....

    1. Create your password script
      • I personally copied the builtin Powershell one and then just replaced the "New-Password" function with my own
    2. Create a new policy and give it a meaningful name
    3. To test, attach the policy to an OU in your structure
      • Be sure to block the default password generation policy.
    4. Right click on a user and select "Reset Password", then hit the generate button. If your script is working, then you should get a password generated for the user.

    Initially, I had created a copy of the builtin policy. I am not sure why, but the system seemed to not like this as it continued to use the builtin/default password generation policy, even after blocking it.

Reply
  • Hi,

    This was resolved. The process goes something like this....

    1. Create your password script
      • I personally copied the builtin Powershell one and then just replaced the "New-Password" function with my own
    2. Create a new policy and give it a meaningful name
    3. To test, attach the policy to an OU in your structure
      • Be sure to block the default password generation policy.
    4. Right click on a user and select "Reset Password", then hit the generate button. If your script is working, then you should get a password generated for the user.

    Initially, I had created a copy of the builtin policy. I am not sure why, but the system seemed to not like this as it continued to use the builtin/default password generation policy, even after blocking it.

Children
No Data