Jump to content

Password Generator Policies


sbt
 Share

Recommended Posts

Hi there,

 

I have created passwordlists via API providing a password list template. The new lists work fine, but I realized that the Password Generator Policy is not being taken from the template. Instead the "Default Password Generator" policy is being used.

Is this a general problem?

 

Cheers

Sebastian

Link to comment
Share on other sites

Never mind, the script worked in the customer's environment, so you can close the topic.

Here's my powershell function.

 

Function Add-PasswordList {
    param(
        [parameter(Mandatory=$true)]
        [string]$PasswordstateURL,
        [parameter(Mandatory=$true)]
        [string]$Passwordlistname,
        [parameter(Mandatory=$true)]
        [int]$PasswordlistTemplateID,
        [parameter(Mandatory=$true)]
        [int]$PasswordlistAdminGroupID,
        [parameter(Mandatory=$true)]
        [int]$PasswordGeneratorID
    )

    if ($PasswordstateURL.EndsWith('/')) {
        $PasswordstateURL.Remove($PasswordstateURL.Length-1,1)
    }

    if ($Passwordlist = Get-PasswordList -PasswordstateURL $PasswordstateURL -Passwordlistname $Passwordlistname) {
        Write-Error "Passwordlist with the name '$($Passwordlistname)' already exists"
        return $false
    }

    $jsonData = @"
        {
        "PasswordList":"$($Passwordlistname)",
        "Description":"$($Passwordlistname)'s Passwords",
        "ApplyPermissionsForSecurityGroupID":"$($PasswordlistAdminGroupID)",
        "Permission":"A",
        "CopySettingsFromTemplateID":"$PasswordlistTemplateID",
        "LinkToTemplate":true,
        "PasswordGeneratorID":"$PasswordGeneratorID",
        "NestUnderFolderID":"0"
        }
"@

    $PasswordstateUrl = "$($PasswordstateURL)/winapi/passwordlists"
    $PasswordList = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials -UseBasicParsing
    return $PasswordList
}

 

$List = Add-PasswordList -PasswordstateURL $PasswordstateURL -Passwordlistname $PasswordStateUser.SamAccountName -PasswordlistTemplateID 13 -PasswordlistAdminGroupID 2 -PasswordGeneratorID 2

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...