powershell - Check if a number belongs to a list -


i want ot verify if user entered number belongs predefined list, -contains operator behaves different expected:

0 -contains 0. true 

the list generated command (get-disk).number. have false input 0.?

first, should wrap output of (get-disk).number @() force list array. then, ensure array of strings using cast. finally, pass number want check using string:

[string[]]$list = @((get-disk).number) # list contains 0  $list -contains "0." # false 

the double 0. eqal int 0 equal string "0" have pass string.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -