Another day, another issue one may say. Today I wanted to install one of my modules to a new server and was greeted with a well-known message (it may seem on first look):
A command with name ” is already available on this system. This module ‘PSEventViewer' may override the existing commands. If you still want to install this module ‘PSEventViewer', use -AllowClobber parameter.
What is important here to notice is that command name was left blank. Usually, the command name would be filled in, and that's something to be expected that there may be some other module using the same name for one of the commands. But this was an almost clean system so it seemed impossible to me that my small module would hit a clash with some other module. I also have seen this error on Azure DevOps during Pester Testing of some of my modules where I've merely overridden the settings with AllowClobber switch because I just thought there's some conflict with something existing on test machines.
Knowing that it has to be my module having a problem I've decided to check two places that made the most sense to me as possible suspects:
And to my expectations I was right, that's where my mistake was. Can you see it yet?
Export-ModuleMember ` -Function @('Get-Events','Get-EventsFilter','Get-EventsInformation') ` -Alias @('')
Recently as part of my optimization process to speed up loading of modules I've written a module that has one neat feature of integrating all functions into single PSM1 file (Why? Have a read here). During that process, it also adds Export-ModuleMember at the end of the file. If you've not yet noticed where the error is it seems that Export-ModuleMember -Function @(‘MyFunction') -Alias @(”) at fault. I've made mistake and left Alias Array with a single member. An empty string. I thought it wouldn't matter but it seems it does.
So how do I fix this issue? I simply had to modify my module to create an empty Array @() for Alias parameter instead of Array with an empty string. Simple, but effective, and another reason that small things matter and we have to pay attention to details.
This post was last modified on %s = human-readable time difference 20:37
Today, I made the decision to upgrade my test environment and update the version of…
Have you ever looked at your Active Directory and wondered, "Why do I still have…
Active Directory replication is a critical process that ensures the consistent and up-to-date state of…
Hey there! Today, I wanted to introduce you to one of the small but excellent…
Active Directory (AD) is crucial in managing identities and resources within an organization. Ensuring its…
In today's digital age, the ability to create compelling and informative HTML reports and documents…