Dot-source in ISE versus PS window

I am having a strange problem, and I need help figuring out what might be causing it.

I downloaded a function.  I ensured it was unblocked so I could run it without warnings.  I load it into ISE and click the execute script icon.  In ISE's command line window I can now see and use the function. (get-command <functionname>)

I open a PowerShell command line window, not part of ISE.  I dot-source execute the script.  The function is not recognized in the PowerShell window.  I have tried with both elevated and non-elevated windows.  Tried on two different systems and get the same results.  From one of the windows I manually key in a simple function definition.  It is available.

Appreciate any hints on why it seems to work fine from ISE but not from a PowerShell window.  Can't find anything in the script that seems to be testing for ISE pre

August 21st, 2015 4:21pm

Post steps to reproduce and commands that illustrate it isn't working.
Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 4:23pm

Load function script into ISE.

F5 to execute.

Go to ISE command window and execute get-command <function-name>; Function is listed.  enter function name and it executes.

Move to a PowerShell window.

dot-source execute function script.

get-command <function-name> does not show function.

<function-name> returns error 'The term 'function-name' is not recognized as the name of a cmdlet, function, script file, or operable program.

August 21st, 2015 4:28pm

Just tried it on a third system - same result.  Windows 8.1 and Server 2012 R2.

It is a function that has been downloaded from the gallery over 65,000 times (Convert-WindowsImage), so I don't think it would be a problem in the download itself.  I am guessing it is something in my environments, that's why I'm looking for hints on what I might try.

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 4:46pm

In CLI you must dot source the file.

August 21st, 2015 5:17pm

Yes, that is what I did.

.\Convert-WindowsImage.ps1

PS C:\users\tcerling\documents\scripts> convert-windowsimage
convert-windowsimage : The term 'convert-windowsimage' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
+ convert-windowsimage
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (convert-windowsimage:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command convert-windowsimage was not found, but does exist in the current location. Windows
PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\conv
ert-windowsimage". See "get-help about_Command_Precedence" for more details.
And trying the suggestion of dot sourcing the command doesn't do anything either.

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 5:44pm

Yes, that is what I did.

.\Convert-WindowsImage.ps1

You need another dot.

. .\Convert-WindowsImage.ps1

<dot><space><dot><slash><filename>

August 21st, 2015 6:10pm

Thank you!  I figured it had to be something I was doing.  I was unaware of the dot-space-dot requirement.  I took the instructions to dot-source it literally.  I guess it is really dot-space-dot-source.

Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 6:32pm

FYI - .\name.ps does not refer to dot sourcing.  .\ refers to current folder.  Try it:

dir .

.. refers to the parent of the current folder.

dir ..

dot sourcing means to xecute in current scope

. c:\scripts\myfunctions.ps

You can also use import-module to get the same effect.

August 21st, 2015 7:10pm


In the example given by Mike the first dot (counting left to right) is the
dot-sourcing dot. 

The second dot is just a part of a file path that means "current directory".

If you need to see more separation, you can code several spaces between the dots:

.    .\Convert-WindowsImage.ps1


Free Windows Admin Tool Kit Click here and download it now
August 24th, 2015 11:27pm

I think you are all a bit dotty.

August 24th, 2015 11:47pm


In the example given by Mike the first dot (counting left to right) is the
dot-sourcing dot. 

The second dot is just a part of a file path that means "current directory".

If you need to see more separation, you can code several spaces between the dots:

.    .\Convert-WindowsImage.ps1


  • Edited by LarryWeiss Tuesday, August 25, 2015 3:28 AM
Free Windows Admin Tool Kit Click here and download it now
August 25th, 2015 3:26am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics