Created
October 21, 2025 09:26
-
-
Save gravejester/99d3669b40815aa2286783d403a9be35 to your computer and use it in GitHub Desktop.
pluralOf - add plural 's' only if array contains more than 1 element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pluralOf - add plural 's' only if array contains more than 1 element | |
| # | |
| # example usage: | |
| # | |
| # Write-Host "Found $($computers.Count) computer$(pluralOf($computers))" | |
| # | |
| function pluralOf($inputObject) { | |
| if ($inputObject -is [System.Array] -or $inputObject -is [System.Collections.ArrayList]) { | |
| Write-Output "$($inputObject.Count -ne 1 ? 's' : '')" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment