Advertisement
Old-Lost

Get-Array

Sep 7th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Get-Array {
  2.     Param (
  3.         [Parameter(Mandatory, Position = 0)] [scriptblock] $Scriptblock
  4.     )
  5.     $Result = & $Scriptblock
  6.     if (0 -eq $Result) { return , (, $Result) }
  7.     if (-not $Result) { return , @() }
  8.     if ($Result -is [array]) {
  9.         return (. {if ($Result.Count -eq 1) { , $Result } else { $Result }})
  10.     }
  11.     return , @($Result)
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement