TommyB Posted November 4, 2015 #1 Share Posted November 4, 2015 Hi, I'm trying to use Powershell to manipulate speed dial keys. Obviously, quite a lot of things changed since the first versions of the powershell module as some of the cmdlets that are mentioned in code examples I found in the old swyx forum are gone. So due to the lack of a comprehensive conceptional introduction I'm working my way through the get-help pages for each cmdlet, trying to get an overview. Now that I found out how to log in and how to retrieve the speed dial keys for each user, I could not set the number on the speed dial, this is what happened: PS C:\Users\Administrator> $KeyList = Get-IpPbxSpeedDialKey -UserName "xxx" PS C:\Users\Administrator> $KeyList[60] Id Label Number DialImmediately DeleteBeforeDial Intercom UserBitmap -- ----- ------ --------------- ---------------- -------- ---------- 60 True True False Automatic PS C:\Users\Administrator> $KeyList[60].Label = "Bob" PS C:\Users\Administrator> $KeyList[60].Number = "100" Die Eigenschaft "Number" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass es die Eigenschaft gibt und dass sie festgelegt werden kann. In Zeile:1 Zeichen:1 + $KeyList[60].Number = "100" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: ( [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentExceptionYou can clearly see that $keylist[60] *displays* a "number" property, but when I try to assing it a value, it tells me that "number" is not a property of the speed dial entry?!?! Also, when I use $Keylist[5].Number (which already has a number assigned), I get no return value, but also no error message Get-member reveals that there is no number property, but there is "DialNumber", which works as expected and sets the number. PS C:\Users\Administrator> $KeyList |get-member Name MemberType ---- ---------- PropertyChanged Event Equals Method GetHashCode Method GetType Method ToString Method ValidateMaxLength Method Command Property DeleteForDial Property DialImmediately Property DialNumber Property DirectCall Property ExtensionData Property ...So there must be some kind of bug... apparently the property was renamed sometimes in the past, but was not changed for the list output Thomas Link to comment Share on other sites More sharing options...
Most Valued User Martin Posted November 10, 2015 Most Valued User #2 Share Posted November 10, 2015 Hi,you're right. The table format header for the "DialNumber" property is "Number". All PowerShell cmdlets returns objects, Get-IpPbxSpeedDialKey returns NameKeyListEntry objects which have a lot of properties. It is possible, and our modules uses that capability, to define how an object should be displayed per default on the shell. These format definitions can be found in C:\Program Files (x86)\SwyxWare Administration\Modules\IpPbx\FormatData We mostly use this capability to exclude certain properties from the default display, because they're not important, so that for a table-style output everything fits into one line in most cases. That probably the reason why we decided to use a shorter column heading for the number. You can see the same if you call standard cmdlets. Try get-process You get a table like this: Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id SI ProcessName ------- ------ ----- ----- ----- ------ -- -- ----------- 291 12 1200 3640 ...99 372 0 csrss 280 15 2492 5620 ...15 5972 2 csrss 413 20 5376 13384 ...07 2572 0 dasHost 125 8 1528 6948 ...91 1840 0 dllhost 1963 72 29100 72000 ...46 5,30 6396 2 explorer Many column headings are different from the actual property names to get more information into the table. So this is not a bug, but a feature. If you would argue that in the speed dial key object case the omitted "Dial" from the column heading doesn't make a big difference, I would probably have to agree, though ;-) Link to comment Share on other sites More sharing options...
TommyB Posted November 11, 2015 Author #3 Share Posted November 11, 2015 Hi Martin, thank you very much for taking the time for this clarification - that explains it perfectly, case closed! I'm not using powershell that much (but I know I should as I'm a software developer :-), so I was not aware of that specific capability. Thomas Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.