1159
Views
5
Helpful
1
Replies
Cisco Unity Connection API - Powershell
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2021 12:17 PM
I'm working on a script to connect to the Cisco Unity Connection API via PowerShell to reset a user's VM pin. I can get the ObjectID just fine but for whatever reason I can't get it to work to reset the VM pin.
$Username = ''
$Password = ''
$PIN = '1234'
$EncodedAuthorization = [System.Text.Encoding]::UTF8.GetBytes($Username + ':' + $Password)
$EncodedPassword = [System.Convert]::ToBase64String($EncodedAuthorization)
$Headers = @{
Authorization = "BASIC $($EncodedPassword)"
Accept = 'application/json'
}
$r = Invoke-RestMethod -Uri 'https://IP/vmrest/users/?query=(alias is ALIAS)' -Headers $Headers
$objectid = $r.User.ObjectId
$response = Invoke-RestMethod 'https://IP/vmrest/users/OBJECTID/credential/pin
' -Method 'Put' -Headers $headers
$response
I've also tried:
$response = Invoke-RestMethod 'https://IP/vmrest/users/OBJECTID/credential/pin?PIN=1234' -Method 'PUT' -Headers $headers
I'd appreciate any guidance here.
TIA
Labels:
1 Reply 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2021 12:53 PM
AFAIK the new pin needs to be in a JSON body. Got it to work for me like this:
$pwd = ConvertTo-SecureString "ciscopsdt" -AsPlainText -Force $cred = New-Object Management.Automation.PSCredential ('Administrator', $pwd) $body = '{"Credentials": "123456"}' $response = Invoke-WebRequest ` -Method PUT ` -ContentType 'application/json' ` -Body $body ` -Credential $cred ` -Uri https://ds-cuc115.cisco.com/vmrest/users/72fdd871-aed5-435c-bde4-836659da4461/credential/pin ` -UseBasicParsing $response
