Closed PrzemyslawKlys closed 4 years ago
So the first part is working as expected. From the perspective of static analysis, Enabled
is a command and -eq
is a parameter name. Really Get-ADUser
's -Filter
parameter isn't typed as a ScriptBlock
. Instead it's converted to a string and the command internally does some hacky string scanning to look for variables. Most folks (including myself) will recommend rather strongly against using the psuedo scriptblock style (even if documentation uses it). There are tons of scenarios where it just straight up doesn't work like a scriptblock.
For the second example, did you have version of the module without that parameter alias in your module path? I ran a little test:
function Test-Command {
[CmdletBinding()]
param(
[Parameter()]
[Alias('what')]
[string] $Hi
)
}
Test-Command -what 'eyy'
If I highlight the function and F8 then it correctly resolves what
to Hi
. If I remove the Alias
and run that, it shows how you describe. If I don't have the command defined at all, it doesn't work (as expected).
This feature relies heavily on command discovery, so whatever gets resolved first will win. The engine doesn't have support for generating a CommandInfo
purely from an AST, and manually building parameter set information from the AST isn't super feasible.
So really the solution to the latter is to import the module you're working on when you make changes like that. If you manually load the command, it won't pull from module path.
What about this conversion?
$DomainControllers = Get-WinADDomainControllers -TestAvailability
To
$DomainControllers = $getWinADDomainControllersSplat = @{
TestAvailability = $true
}
Get-WinADDomainControllers @getWinADDomainControllersSplat
It's behaving like that now. $DomainControllers should be elsewhere...
Yeah that's wrong for sure 🙂
Working on it now, thanks!
Fixed with v1.0.0-beta1
Install-Module EditorServicesCommandSuite -Scope CurrentUser -AllowPrerelease -Force
Hi @SeeminglyScience
So I have this:
I choose splat expression.. and:
Something is wrong or I am just doing it wrong :-) Also in some other situation it was doing this:
I picked all parameters instead of just simple splat
But actually Name = ServiceName, ServiceStatus = Status now and it's just aliased.
But after I've rebuilt the module it was working ok, yet it was picking up both ServiceName and Name at the same time from somewhere.
I have a feeling it wasn't working like that before. Now it's a bit unpredictable. But maybe I wasn't using it enough ;)