{"action":"created","issue":{"url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157","repository_url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell","labels_url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157/labels{/name}","comments_url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157/comments","events_url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157/events","html_url":"https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157","id":190915915,"number":157,"title":"InvalidCastException when trying to set entityimage of systemuser entity","user":{"login":"mwolfaardt","id":11614412,"avatar_url":"https://avatars.githubusercontent.com/u/11614412?v=3","gravatar_id":"","url":"https://api.github.com/users/mwolfaardt","html_url":"https://github.com/mwolfaardt","followers_url":"https://api.github.com/users/mwolfaardt/followers","following_url":"https://api.github.com/users/mwolfaardt/following{/other_user}","gists_url":"https://api.github.com/users/mwolfaardt/gists{/gist_id}","starred_url":"https://api.github.com/users/mwolfaardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwolfaardt/subscriptions","organizations_url":"https://api.github.com/users/mwolfaardt/orgs","repos_url":"https://api.github.com/users/mwolfaardt/repos","events_url":"https://api.github.com/users/mwolfaardt/events{/privacy}","received_events_url":"https://api.github.com/users/mwolfaardt/received_events","type":"User","site_admin":false},"labels":[{"id":283343180,"url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":283343181,"url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":{"login":"seanmcne","id":2292260,"avatar_url":"https://avatars.githubusercontent.com/u/2292260?v=3","gravatar_id":"","url":"https://api.github.com/users/seanmcne","html_url":"https://github.com/seanmcne","followers_url":"https://api.github.com/users/seanmcne/followers","following_url":"https://api.github.com/users/seanmcne/following{/other_user}","gists_url":"https://api.github.com/users/seanmcne/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmcne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmcne/subscriptions","organizations_url":"https://api.github.com/users/seanmcne/orgs","repos_url":"https://api.github.com/users/seanmcne/repos","events_url":"https://api.github.com/users/seanmcne/events{/privacy}","received_events_url":"https://api.github.com/users/seanmcne/received_events","type":"User","site_admin":false},"assignees":[{"login":"seanmcne","id":2292260,"avatar_url":"https://avatars.githubusercontent.com/u/2292260?v=3","gravatar_id":"","url":"https://api.github.com/users/seanmcne","html_url":"https://github.com/seanmcne","followers_url":"https://api.github.com/users/seanmcne/followers","following_url":"https://api.github.com/users/seanmcne/following{/other_user}","gists_url":"https://api.github.com/users/seanmcne/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmcne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmcne/subscriptions","organizations_url":"https://api.github.com/users/seanmcne/orgs","repos_url":"https://api.github.com/users/seanmcne/repos","events_url":"https://api.github.com/users/seanmcne/events{/privacy}","received_events_url":"https://api.github.com/users/seanmcne/received_events","type":"User","site_admin":false},{"login":"mwolfaardt","id":11614412,"avatar_url":"https://avatars.githubusercontent.com/u/11614412?v=3","gravatar_id":"","url":"https://api.github.com/users/mwolfaardt","html_url":"https://github.com/mwolfaardt","followers_url":"https://api.github.com/users/mwolfaardt/followers","following_url":"https://api.github.com/users/mwolfaardt/following{/other_user}","gists_url":"https://api.github.com/users/mwolfaardt/gists{/gist_id}","starred_url":"https://api.github.com/users/mwolfaardt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwolfaardt/subscriptions","organizations_url":"https://api.github.com/users/mwolfaardt/orgs","repos_url":"https://api.github.com/users/mwolfaardt/repos","events_url":"https://api.github.com/users/mwolfaardt/events{/privacy}","received_events_url":"https://api.github.com/users/mwolfaardt/received_events","type":"User","site_admin":false}],"milestone":null,"comments":13,"created_at":"2016-11-22T06:12:14Z","updated_at":"2016-12-12T21:17:47Z","closed_at":null,"body":"When trying to execute the following : \r\n\r\n$users = Get-CrmRecords -EntityLogicalName systemuser -FilterAttribute domainname -FilterOperator eq -FilterValue \"LMiller@d365trial.onmicrosoft.com\" -Fields systemuserid,fullname,entityimage\r\n\r\n    $picture = [System.IO.File]::ReadAllBytes(\"c:\\img\\LMiller.jpg\")\r\n\r\n$users.CrmRecords | \r\nforeach{\r\n$user = $_\r\n$user.entityimage = $picture\r\n#$user.sample_name = \"60.jpg\"\r\nset-CrmRecord $user\r\n}\r\n\r\nI get an exception \r\n\r\nSpecified cast is not valid.\r\nAt C:\\Users\\user1\\Documents\\WindowsPowerShell\\Modules\\Microsoft.Xrm.Data.Powershell\\2.4\\Microsoft.Xrm.Data.Powershell.psm1:772 char:9\r\n+         throw $conn.LastCrmException\r\n+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : OperationStopped: (:) [], InvalidCastException\r\n    + FullyQualifiedErrorId : Specified cast is not valid.\r\n"},"comment":{"url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/comments/266555489","html_url":"https://github.com/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157#issuecomment-266555489","issue_url":"https://api.github.com/repos/seanmcne/Microsoft.Xrm.Data.PowerShell/issues/157","id":266555489,"user":{"login":"amervitz","id":10599498,"avatar_url":"https://avatars.githubusercontent.com/u/10599498?v=3","gravatar_id":"","url":"https://api.github.com/users/amervitz","html_url":"https://github.com/amervitz","followers_url":"https://api.github.com/users/amervitz/followers","following_url":"https://api.github.com/users/amervitz/following{/other_user}","gists_url":"https://api.github.com/users/amervitz/gists{/gist_id}","starred_url":"https://api.github.com/users/amervitz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amervitz/subscriptions","organizations_url":"https://api.github.com/users/amervitz/orgs","repos_url":"https://api.github.com/users/amervitz/repos","events_url":"https://api.github.com/users/amervitz/events{/privacy}","received_events_url":"https://api.github.com/users/amervitz/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T21:17:46Z","updated_at":"2016-12-12T21:17:46Z","body":"I'm able to reproduce this error when creating a new record as in @seanmcne's sample code.\r\n\r\nThe problem is the type assigned to CrmDataTypeWrapper object is CrmBoolean but it should be Raw:\r\n\r\n> PS> $newfields.entityimage.Type\r\n> PS> CrmBoolean\r\n\r\nAdding a default case to the switch statement in the code above to assign $newfield.Type to be Raw should fix it in this case.\r\n\r\nIt works for me though when updating an existing record through Set-CrmRecord -CrmRecord and when the record already has a value in the entityimage field.\r\n\r\nI can submit a PR for the case I've found if you like."}}
{"actor":{"display_login":"amervitz"}}