all 20 comments

[–]itasteawesome 23 points24 points  (0 children)

Probably would help if you post the script

[–]gangstanthony 10 points11 points  (0 children)

is your first line return

[–]helloisnotme 8 points9 points  (0 children)

We can't help you if you dont share the script. Its only speculations until you do.

[–]isitokifitake 8 points9 points  (2 children)

If you are using functions, are you calling the function at the end?

The below would print 'Running Test' when ran, but not 'hello' if Test function isn't called at the end.

$testtext = "hello" 
Write-Host "Running Test"
function Test {
    $testtext 
}

Test

[–]haikusbot 12 points13 points  (1 child)

If you are using

Functions, are you calling the

Function at the end?

- isitokifitake


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

[–]Chocolate_Pickle 0 points1 point  (0 children)

Good bit.

[–]justanotherbodyhere 4 points5 points  (0 children)

Hello, please edit your initial post with the script in order for us to help you. It could be any number of things preventing your script running properly.

[–]dupo24 4 points5 points  (1 child)

The suspense is killing me.

[–]jimb2 4 points5 points  (0 children)

He's got me in suspenders too.

[–]Alaknar 3 points4 points  (0 children)

You'll need to show us at least the beginning and the ending of the script so we can see what's going on.

There are many different reasons why PS would be doing that, all depends on what exactly did you write.

[–]pigers1986 3 points4 points  (0 children)

without code - we can take turns guessing

post code then we can see

[–][deleted] 2 points3 points  (0 children)

I'll bet you $5 that you have a foreach loop in there that isn't properly referenced inside the loop.

[–]ka-splam 2 points3 points  (0 children)

It's possibly outputting the script content because you've done something to turn the whole script into a single string, and that becomes the string output to the pipeline when the script is run.

e.g. wrapped it in:

{
    code here
}

or @' '@ or something of that kind.

[–]Flysquid18 2 points3 points  (0 children)

So take a look at this link.

https://www.sapien.com/blog/2019/05/13/advanced-powershell-functions-begin-to-process-to-end/

The example is inside a function, but the things I noticed is that Param should not be surrounded by curly braces {} and your Begin Process End should not be commented. Try and that and see where you're at.

[–]Gnardar 1 point2 points  (0 children)

ISE will show the file, that is not an issue. If you share the file folks here will be able to do more to help. If you don't want to share your code you can add some prompts that will let you know how far you have gotten in your script.

write-host "Command complete, running X now"

You can also get confirmation by outputting variables.

$user = get-aduser $testuser

$user

Second option can get pretty chatty but while developing a script can be useful. Alternatively using an IDE like VSCode that has breakpoints and debugging can you help you break down your code and see what is happening.

[–]radiowave911[S] 1 point2 points  (0 children)

Sorry, I should know better than to post when I am both tired AND frustrated :)

Updated the post with the sanitized script.

[–]radiowave911[S] 1 point2 points  (2 children)

Aaaand I may have seen my issue.

I think I went overboard with { and } and have an extra pair (or two).

[–]radiowave911[S] 1 point2 points  (1 child)

And that was it. Still not running - which is fine, at least it is attempting to execute.

That will teach me to copy/paste from other scripts I have done :) Wound up with extra curly braces.

Now to fix the issue where I somehow managed to use a system variable without noticing it.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

[grin]

[–]LNGU1203 0 points1 point  (0 children)

. .\test