Skip to content

Instantly share code, notes, and snippets.

@MVKozlov
Last active November 13, 2015 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MVKozlov/5a3a45e6b428dac6d65b to your computer and use it in GitHub Desktop.
Save MVKozlov/5a3a45e6b428dac6d65b to your computer and use it in GitHub Desktop.
#Mandatory, ValidateNotNullOrEmpty - I think nobody want array of nulls from this function, it is useless
#it is not need for script to work, but it is right for automation
param([Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$VMNameStr)
#take single string, divide by comma, return array from non-empty trimmed strings
[array]($VMNameStr.Trim() -split '\s*(?:,\s*)+\s*')
#btw, it will be good practice to rename VMNameStr to ComputerName or something other close to intended usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment