You would rewrite the function to return an object, having the properties you require. Consider Get-Service - you don’t have separate commands for getting a name and a status; one command returns objects that have both pieces of information
You should. You want to follow native patterns, not create new ones.
And no, you’d probably not use return anyway, as it’s misleading outside of a class. This is all in “The PowerShell Scripting and Toolmaking Book,” but briefly:
Just add in however many bits of info you intend to output (here, I’ve done two, named Property1 and Property2). That’ll output an object. Whatever runs your function would refer to the desired property. E.g.,
And BTW, having co-authored it, I do heartily recommend the book - http://leanpub.com/powershell-scripting-toolmaking. It’s obvious you have some prior programming experience, and it’s going to lead you down a dark path with PowerShell. The book is intended to get you on the right page with your approach, so that you’re working WITH the shell, instead of against it.
Thanks Don, I do have some basic programming experience, but not professional. I’m the only one at my company that does stuff in PowerShell, so I can’t ask a live person a question. I’ll read your book.