How are you calling these functions? From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Orlebeck, Geoffrey Sent: Friday, September 23, 2016 1:38 PM To: 'powershell@lists.myitforum.com' Subject: [powershell] Functions, Scoping, and Returns
I have two functions, one for creating an AD account, another for creating a mailbox. The AD account function has a switch for mailbox creation which calls the create mailbox function. The issue I am running into is passing information from the create mailbox back to the parent user creation function. Our Helpdesk staff are not strong with PowerShell and I'm trying to provide text output so they can validate the script worked. The problem I'm encountering is getting both the outputting the 'write-output' steps in the mailbox function and returning a success/fail result. If I store the function in a variable, I can get it to return the success/failure, but it won't output the text as the function runs. If I don't perform a '$Result = create mailbox function', the various outputs from the mailbox function are visible, but then I have no way of validating it actually worked (for screen output purposes of pass/fail.) I'm attaching both functions (scrubbed of any sensitive data), but I'm wondering if this is where scoping gets involved with respect to global/local/script? I'm reading up on the concept but I'm not sure that's the appropriate path. Any help is appreciated. Thank you. Confidentiality Notice: This is a transmission from Community Hospital of the Monterey Peninsula. This message and any attached documents may be confidential and contain information protected by state and federal medical privacy statutes. They are intended only for the use of the addressee. If you are not the intended recipient, any disclosure, copying, or distribution of this information is strictly prohibited. If you received this transmission in error, please accept our apologies and notify the sender. Thank you.