Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation AD powershell #11

Open
ggill27 opened this issue Oct 1, 2018 · 2 comments
Open

Automation AD powershell #11

ggill27 opened this issue Oct 1, 2018 · 2 comments
Assignees

Comments

@ggill27
Copy link

ggill27 commented Oct 1, 2018

Hi,

I'm after a powershell script to reset domain account password and update in IT glue.
I already have the script just need the guidance to update the password in IT glue.
I'm got the API Keys.

@CalebAlbers
Copy link
Collaborator

Hey @ggill27,

Are you using the IT Glue PowerShell module? If so, below is some sample code that I used when testing the New-ITGluePasswords and Set-ITGluePasswords functions.

The first step is to form a $data variable that holds the relevant password information, as so:

$data = @{
    'type' = 'passwords'
    'attributes' = @{
        'name' = 'Domain Admin'
        'username' = 'contoso\administrator'
        'password' = $myPassword
        'notes' = "Admin credentials for the domain admin account"
        'password-category-id' = '<<<fill this in>>>'
        'password-category-name' = '<<<fill this in>>>'
        'organization_id' = $org_id
    }
}

Note the password categories pertain to things like "Web/FTP" or "Application." You can get a list of the current password categories in your IT Glue account by running Get-ITGluePasswordCategories.

If you are creating a new password, simply pass the new variable to the New-ITGluePasswords function. You should get a response in the $output variable that holds the id of the new password.

$output = New-ITGluePasswords -data $data

With the password id now in hand, you can have your script easily update the existing password. Just modify the $data contents for the new password, and pass along the password id as so:

Set-ITGluePasswords -id $password_id -data $data

@CalebAlbers CalebAlbers self-assigned this Oct 1, 2018
@ggill27
Copy link
Author

ggill27 commented Oct 2, 2018

ConvertTo-Json : Cannot validate argument on parameter 'Depth'. The argument is null, empty, or an element of the argument
collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
At C:\Ad password.ps1:33 char:54

  • ... onvertTo-Json -InputObject $body -Depth $ITGlue_JSON_Conversion_Depth
  •                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [ConvertTo-Json], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ConvertToJsonCommand

Set-ITGluePasswords : The remote server returned an error: (400) Bad Request.
At line:1 char:1

  • Set-ITGluePasswords -id $password_id -data $data
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Set-ITGluePasswords
    
    

This is the error message I'm getting and below is the code
$data = @{
'type' = 'passwords'
'attributes' = @{

    'name' = 'test'
    'username' = 'test'
    'password' = $newpwd
    'notes' = "Admin credentials for the domain admin account"
    'password-category-id' = '9999' 
    'password-category-name' = 'Active Directory'
    'organization_id' = $org_id

}

}
$password_id ="99999"
Set-ITGluePasswords -id $password_id -data $data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants