Error using Export-Excel since updating to latest release of module
I've been using your module since May and it's been working fine. I noticed that there had been a lot of recent updates so I downloaded and installed the latest version of the module and now Export-Excel is not working at all. Whenever I try to use the module I get the following error. For example:
PS F:\PowerShellScripts> Get-Service | Export-Excel services.xlsx
invoke member w/ expression name
At line:1 char:1
+ Get-Service | Export-Excel services.xlsx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], NotImplementedExceptio
+ FullyQualifiedErrorId : System.NotImplementedException
I cannot figure this out and don't understand what is happening. The previous version (from 27th May '15) worked fine. It seems to be an issue with the Export-Excel.ps1 file, which didn't even exist in the previous version. I also noticed that parameter completion is no longer working for the Export-Excel cmdlet.
I am using PowerShell 3.0 on Windows 2008 R2. I also tested on Windows 7 with PowerShell 3 - same issue. Reverting back to the previous version works fine.
Hope you can help!
Just to add that I tried downloading a previous version from commit https://github.com/dfinke/ImportExcel/commit/84e273387ca023def5c9541828c96f53caf9de42 on 21st August 2015 and it works fine. So something happened/changed after that date to break the module - at least for me.
Thanks for the clues. I don't have a box with PS 3. It's going to be a challenge.
The error that is shown is this?
invoke member w/ expression name
Hi Doug. Yes, that's the error:
invoke member w/ expression name
It doesn't give much away. I tried to specify -Debug but that didn't provide any further info. If there's anything I can do to help identify the root cause please let me know. I tried reviewing the Export-Excel.ps1 module but I don't really see where or what line of the script is causing the issue. There's nothing at line 1 char 1.
Unfortunately it all works in v5 including the parameter completion. I do have PSReadline installed though.
Could you try gsv | select status | export-excel services.xlsx
Hi. Same error as above. No matter what you try to do with the Export-Excel cmdlet, you always get the above error.
Thanks for trying. If you want, create a ps1 file with that line in it, open it in ISE and set a break point and then you can step through into Export-Excel.ps1 and see if that gives more clues.
I need to figure out how to spin up PS V3
Hi Doug. Sorry I am not very experienced using Debug. I did as you suggested but the example script just errors-out with the same error again, it does't seem to step-into the actual code in the module, it just errors immediately when calling Export-Excel cmdlet:
PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> C:\Users\stu\Desktop\test.ps1
Hit Line breakpoint on 'C:\Users\Stu\Desktop\test.ps1:1'
[DBG]: PS C:\WINDOWS\system32\WindowsPowerShell\v1.0>>
invoke member w/ expression name At C:\Users\Stu\Desktop\test.ps1:1 char:1
+ gsv | select status | export-excel services.xlsx
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], NotImplementedException
+ FullyQualifiedErrorId : System.NotImplementedException
That's fine. I think the $PSScriptRoot is the problem in the PSM1. It may work if you replace it and hard code the actual location in the module folder where the export-excel.ps1 is
Hi Doug. Unfortunately that wasn't the issue. I believe PowerShell 3.0 and later fully support $PSScriptRoot. Anyway I replaced it with the hard-coded location of the module and I still get exactly the same error. Googling the error a few posts on technet about similar issues in scripts mention "The ability to store a method name in a variable and invoke it with the dot operator is new to PowerShell 4.0 and later". Does that mean anything to you? Could something have changed in the code to do that in the latest version of the module?
Just also FYI - all of the other functions in the module work fine, e.g. Import-Excel works without issue. It's just Export-Excel (which is the only function we really use) that doesn't work.
Thanks for drilling down on this.
This does make sense. I'll take a look at the code. This might have been introduced when I added conditional formatting.
Hi Doug,
Have you been able to pinpoint his issue? If there's anything more I can do to help, please let me know. We'd like to be able to update to the latest version.
Stuart
On 8 Oct 2015, at 14:28, Doug Finke [email protected] wrote:
Thanks for drilling down on this.
This does make sense. I'll take a look at the code. This might have been introduced when I added conditional formatting.
— Reply to this email directly or view it on GitHub https://github.com/dfinke/ImportExcel/issues/44#issuecomment-146545136.
Unfortunately, I have not found what is causing this and I may need to load up v3 of PowerShell to figure it out.
OK. Thanks. Again please let me know if there's anything I can do to assist.
OK, adding _invoke_ seems to work. Please, could you verify? Then I'll check it in.
$rule = ($ws.ConditionalFormatting).$target($format.Address, $format.IconType)
_To_:
$rule = ($ws.ConditionalFormatting).$target.invoke($format.Address, $format.IconType)
Hi Doug. Yes changing that line in Export-Excel.ps1 fixes the issue. I wish I understood why it fixes the problem!
Many thanks for looking into this.
I checked in the change and will push it to the gallery soon.
I don't know the explanation as to why this changed in v4.
$Method = "SubString"
"Hello".$Method.Invoke(2,1) # => Needed for -lt v4
"Hello".$Method(2,1) # => Less noise for -ge v4
Thanks Doug!
Hi Doug,
Many thanks on your great module, which now I use for quite some time. I have one server with PowerShell 3.0, which because of some dependencies, I cannot upgrade to PowerShell 4. I've tried the fix you suggested here, but adding Invoke to Export-Excel cmdlet won't help me. Is there any other solution to this one? I'm using the latest version, just added this here because of the same issue stukey had.
Thanks!
Thanks for the comment @marinkovicpetar. There might be one more way. I need to check some older code. If I don't respond in the next couple days, please remind me.
Thanks a lot Doug, looking forward to it
On Tuesday, 21 June 2016, Doug Finke [email protected] wrote:
Thanks for the comment @marinkovicpetar https://github.com/marinkovicpetar. There might be one more way. I need to check some older code. If I don't respond in the next couple days, please remind me.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dfinke/ImportExcel/issues/44#issuecomment-227470148, or mute the thread https://github.com/notifications/unsubscribe/AMxG0u2aEd5NHA_EvKKDhwrCLlTpC3vRks5qN_43gaJpZM4GKdip .