Closed sebastiaan-levix closed 4 years ago
Got a bit further by reading the doco :)
$data = @{ type = 'passwords' id = 1738405732450458 attributes = @{ username = 'admin' } }
Set-ITGluePasswords -organization_id 1694461951918297 -data $data
But this code returns: Set-ITGluePasswords : {"errors":[{"status":403,"title":"Cannot PATCH Password in bulk","source":{"pointer":null}}]}
Solved:
Don't forget to authorise your API key for passwords :)
`Import-Module ITGlueAPI
function formatAPIData {
# Update the password changing the category-id
$body = @{
type = 'passwords'
attributes = @{
organization_id = $orgID
id = $pwID
'password-category-id' = $NewCategoryID
'password-category-name' = $NewCategoryName
}
}
return $body
}
$NewCategoryName = "New category name" $outputID = Get-ITGluePasswordCategories -filter_name $NewCategoryName $NewCategoryID = $outputID.data.id
$OldCategoryName = "Old category name" $outputID = Get-ITGluePasswordCategories -filter_name $OldCategoryName $OldCategoryID = $outputID.data.id
$output = Get-ITGluePasswords -filter_password_category_id $OldCategoryID
foreach ($password in $output.data) { Write-host "name : " $password.attributes.name Write-host "organization-id : " $password.attributes.'organization-id' Write-host "category-name : " $password.attributes.'password-category-name' Write-host "password-id : " $password.id Write-host "----------------------------------------------------------------------------"
$orgID = $password.attributes.'organization-id'
$pwID = $password.id
$body = formatAPIData # format data for API call
$result = Set-ITGluePasswords -data $body
# View results
$result.data | Format-List
}
<# cheers Sebastiaan :)
Hi,
I've imported some passwords with a category which is false. Now I'd like to bulk change to pw category. This is what I got sofar but how to update the pw category only?
$output = Get-ITGluePasswords -filter_password_category_id 1696235240882384
foreach ($password in $output.data.attributes) { Write-host $password.name Write-host $password."resource-url"
}