Get-Service Name parameter allows Null value
Get-Service -Name $Null returns all services. Expected behavior would be for Name to have ValidateNotNullOrEmpty attribute assigned.

Because this is technically a breaking change, can you guys provide some data on what kind of scenario this might be impacting for you?
3 comments
-
Ben Gelens commented
Any parameter like Name or Id implies the expected result to be explicitly defined. No doubt unless wildcards are allowed.
When you forget to assign a value or the value is Null by accident or a bug results in a Null value and it's used with Name, it will be Null and therefore return all services. Not everyone is using strictmode :-)
-
Roman Kuzmin commented
> provide some data on what kind of scenario this might be impacting for you
In theory, here is a possible unwanted scenario:
$service = Get-ServiceToStop ...
Get-Service $service | Stop-ServiceIf Get-ServiceToStop is expected to get something but returns nothing then all services are going to be stopped.
-
Roman Kuzmin commented
Agree.
Get-Alias -Name $null -- also returns all items, it's not quite right.
Get-Process, Get-Variable fail -- good.