Author Posts

August 17, 2018 at 1:57 pm

First, I apologize if this is the wrong location for this question!  I wasn't sure which forum was correct.

I'm in a book group at work doing Powershell Scripting in a Month of Lunches.  We were doing the last bit in chapter 12 (12.6.1. "Start Here" https://livebook.manning.com/#!/book/learn-powershell-scripting-in-a-month-of-lunches/chapter-12/1)

And we could only get that code to run using except in the ISE with dot sourcing.  It wouldn't run at all in a regular PS shell.

Any thoughts as to why this would be so?  Is it expected behavior from that sample code?

Thanks!

Adam

August 17, 2018 at 2:15 pm

The code you see there is a function. you have to put it into a text file and save it with .ps1 extension, which makes it a PowerShell script. Then dot source it in any PowerShell console and use it. PowerShell ISE is basically meant for developing.

When you use ISE you can define the function using play button(F5) and can be used in the same session. You can even do similar buy copy pasting the whole function in to a normal PowerShell console to use it without dot sourcing.

August 17, 2018 at 2:40 pm

Hey Adam! This is the place for questions, however, some more details would help us help your group. It appears you are referring to the function Set-TMServiceLogon. There is nothing in that code that should run in ISE vs a standard host that I can see, so if you could provide details on what exactly is not working, errors, etc. would help. I can tell you if I paste the code into a Powershell host, hit enter to load it into memory, it is executing for me.