| |
SAPIENScripter
Posts: 261
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
Is this function in your profile or did you paste it into your Powershell session? The function worked fine for me. If you are using it in a script, it has be inserted at the beginning of your script before any other code that uses it. Unlike VBScript where functions can be any where, functions in a PowerShell script must be defined at the beginning of the script before you can use it. Also, if the function is in a script, it only "exists" in the script's scope meaning once the script ends it is not available in the general console session. If you want to load the function into your console when running the script, then you need to dot source it: PS C:\. ./myscript.ps1 The script, myscript.ps1, will execute and any functions will remain in the global scope, ie your session.
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com
|
|