RICOH Address Book

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 9 months, 2 weeks ago.

  • Author
    Posts
  • #59836

    Damon
    Participant

    Good evening everyone,

    I am new to PowerShell and am trying to create/use a script to add users to the RICOH Address Book. I am about 90% completed, but am stuck on this one part. The function that I am calling out to is:

    
    function Add-MFPAB
    {
    param($Hostname,$Authentication="BASIC",$Username="admin",$Password,$SecurePassword,$EntryType="user",$Index,$Name,$LongName,$title,$UserCode,$Destination="true",$Sender="false",$Mail="true",$MailAddress,$FolderPath)
    Connect-MFP $Hostname $Authentication $Username $Password $SecurePassword
    $url = "http://$Hostname/DH/udirectory"
    $add = [xml]@'
    
    
     
      
       
       entry
       
       
        
         
          entryType
          
         
         
          name
          
         
         
          longName
          Ÿ
         
         
          tagID
          
         
         
          isDestination
          
         
         
          isSender
          
         
         
          mail:
          
         
         
          mail:address
          
         
         
          remoteFolder:path
          
        
        
       
      
     
    
    '@
    $add.Envelope.Body.putObjects.sessionId = $script:session
    $add.Envelope.Body.putObjects.propListList.item.item[0].propVal = $EntryType
    if($Index -ne $NULL){
    $a = $add.CreateElement("item")
    $a.set_InnerText("")
    $b = $add.CreateElement("propName")
    $b.set_InnerText("index")
    $o = $a.AppendChild($b)
    $c = $add.CreateElement("propVal")
    $c.set_InnerText($Index)
    $o = $a.AppendChild($c)
    $o = $add.Envelope.Body.putObjects.propListList.item.AppendChild($a)
    }
    $add.Envelope.Body.putObjects.propListList.item.item[1].propVal = $Name
    $add.Envelope.Body.putObjects.propListList.item.item[2].propVal = $LongName
    if($UserCode -ne $NULL){
    $a = $add.CreateElement("item")
    $a.set_InnerText("")
    $b = $add.CreateElement("propName")
    $b.set_InnerText("auth:name")
    $o = $a.AppendChild($b)
    $c = $add.CreateElement("propVal")
    $c.set_InnerText($UserCode)
    $o = $a.AppendChild($c)
    $o = $add.Envelope.Body.putObjects.propListList.item.AppendChild($a)
    }
    $add.Envelope.Body.putObjects.propListList.item.item[3].propVal = $title
    $add.Envelope.Body.putObjects.propListList.item.item[3].propVal = $Destination
    $add.Envelope.Body.putObjects.propListList.item.item[4].propVal = $Sender
    $add.Envelope.Body.putObjects.propListList.item.item[5].propVal = $Mail
    $add.Envelope.Body.putObjects.propListList.item.item[6].propVal = $MailAddress
    $add.Envelope.Body.putObjects.propListList.item.item[7].propVal = $FolderPath
    $add.Envelope.Body.putObjects.propListList.arrayType = "itt:string[]["+$add.Envelope.Body.putObjects.propListList.item.item.count+"]"
    [xml]$xml = iwr $url -Method Post -ContentType "text/xml" -Headers @{SOAPAction="http://www.ricoh.co.jp/xmlns/soap/rdh/udirectory#putObjects"} -Body $add
    Disconnect-MFP $Hostname
    }
    
    
    

    And the code that I am using is:

    DO{
    Import-Module C:\Users\DGentile\Downloads\RICOH-MFP-Test4.psm1
        $RAM5002 = 'IP_ADDRESS'
        $RAM6001 = 'IP_ADDRESS'
        $RAM2551 = 'IP_ADDRESS'
        $RAM6501 = 'IP_ADDRESS'
        $RAM3601 = 'IP_ADDRESS'
        $CYCLE = ('IP_ADDRESS','IP_ADDRESS,'IP_ADDRESS','IP_ADDRESS','IP_ADDRESS')
        $First = read-host "First Name"
        $Last = read-host "Last Name"
        $FI = $First[0]
        $Name = "$First $Last"
        $Path = "FOLDERLOCATION"
        switch -regex ($FI)
            {
              "[A-B]" {$Title = "1"}
              "[C-D]" {$Title = "2"}
              "[E-F]" {$Title = "3"}
              "[G-H]" {$Title = "4"}
              "[I-K]" {$Title = "5"}
              "[L-N]" {$Title = "6"}
              "[O-Q]" {$Title = "7"}
              "[R-T]" {$Title = "8"}
              "[U-W]" {$Title = "9"}
              "[X-Z]" {$Title = "10"}#>
            }
        Write-Host "Path is $Path"
          Add-MFPAB -Hostname $RAM5002 -Username "ENTERUSERNAME" -Password "ENTERPASSWORD" -Name "$Name" -LongName "$First$Last" -TagID "$Title" -Destination "true" -Sender "false" -Mail "true" -MailAddress "$FI$Last@schimenti.com" -FolderPath "$Path"
         
        $Title
        $MoreUsers = Read-Host "Add More Users? (Y/N)"
        $MoreUsers
       } while ($MoreUsers -eq 'Y' -or $MoreUsers -eq 'y' -or $MoreUsers -eq 'yes' -or $MoreUsers -eq 'YES' -or $MoreUsers -eq 'Yes')
       Write-Host "Have a Great Day"
    

    I keep receiving an error that states:

    Exception setting "propVal": "The property 'propVal' cannot be found on this object. Verify that the property
    exists and can be set."
    At C:\Users\DGentile\Downloads\RICOH-MFP-Test4.psm1:231 char:1
    + $add.Envelope.Body.putObjects.propListList.item.item[3].propVal = $ti ...

    I found that if I add "Title = [int](%{$_.item} | ?{$_.propName -eq "tagId"}).propVal" somewhere in the code, it will resolve that error, but for the life of me, I can't figure out where. I tried in the function. I tried in my script. In the function, I tried in the declaration, in the

    tagID
    Title = [int](%{$_.item} | ?{$_.propName -eq "tagId"}).propVal

    —————————————–

    tagID
    $Title = [int](%{$_.item} | ?{$_.propName -eq "tagId"}).propVal

    ———————————————-

    tagID
    Title = [int](%{$_.item} | ?{$_.propName -eq "tagId"}).propVal

    And among many other variations. Any help would be greatly appreciated. Thank you in advance.

    After I posted, I realized it is not posting correctly. Here is a link to the code:

    https://gallery.technet.microsoft.com/scriptcenter/Ricoh-Multi-Function-27aeea71/view/Discussions#content

    I take no credit for the source of the code.

  • #60003

    Don Jones
    Keymaster

    Personally, I've no familiarity whatsoever with the RICOH product so it's tough to offer advice. Does the vendor have any kind of forum or resource that you could look at? You're not doing anything wrong in PowerShell per se; what you're running into is happening on the vendor's product, so it's tough – from a PowerShell perspective – to offer a fix.

You must be logged in to reply to this topic.