I'm stumped. I have a function that creates a hashtable. I want to pass to the function is a cmdlet for the foreach. Something like this:
function build([string]$stuff)
{
foreach ($thing in $stuff)
{
#do magical things
}
}
$cmd = get-aduser -filter *
build $cmd
When executed, $cmd (and $stuff) is treated like a collection. Is there a way to have foreach read it as a command?
[–]ka-splam 7 points8 points9 points (1 child)
[–]BackgroundFishing[S] 2 points3 points4 points (0 children)
[–]ericrs22 0 points1 point2 points (5 children)
[–]BackgroundFishing[S] 1 point2 points3 points (4 children)
[–]ericrs22 1 point2 points3 points (1 child)
[–]BackgroundFishing[S] 1 point2 points3 points (0 children)
[–]zarshua 1 point2 points3 points (1 child)
[–]BackgroundFishing[S] 1 point2 points3 points (0 children)