Hi OldDog,
You can copy the function as is into your $profile, restart powershell and
call the function from the console:
PS > Get_SysInternals
Or with its parameters:
PS > Get_SysInternals -sysIntDir="d:\foo"
You can also paste the function into a ps1 file and dot-sorce:
# it the script is in the working directory
PS > . .\Get_SysInternals.ps1
# from the full path to the file
PS > . c:\scripts\Get_SysInternals.ps1
Now you can call it the same way as above.
Another option is to remove the 'function Get-SysInternals {' line and the
last '}' (e.g at the bottom of the script), save it to a ps1 file
and call it like so:
PS > .\Get_SysInternals.ps1 -sysIntDir="d:\foo"
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
O> On Sep 19, 9:32 am, OldDog <mikef2...@xxxxxx> wrote:
O>
>> On Sep 19, 9:11 am, Ozone <rs_dov...@xxxxxx> wrote:
>>
>>> Put a space between the dots. As you have it, the shell is looking
>>> in the folder one level up, and the script can't be located. To dot
>>> source your script there should be a space between the two dots...
>>>
>>> HTH
>>> Ozone >> That was fun. Now I get another error;
>>
>> C:\Scripts\PS1> . .\Get_SysInternals.ps1
>> Exception calling "SetShouldExit" with "1" argument(s): "Object
>> reference not set to an instance of an object."
>> Notice that "SetShouldExit" is not part of the Function.
>> O> OK, Its the whole function thing that has mu confused.
O>
O> If I remove the
O>
O> function Get-SysInternals {
O>
O> param (
O>
O> The trailing ) after $sysIntDir="C:\PSTools\" and the last } and save
O> it as Get_SysInternals.ps1 it works just fine.
O>
O> So I know its not the code. I just don't know how to call a function
O> in PowerShell. So I guess my question is,
O>
O> How do you call a Function in PowerShell.
O>
O> OldDog
O>