No output from script constructed using notepad
Ok so I'm super new to poweshell. I'm learning a lot in school and this is a wonderful tool and can be extremely useful to me. My question is why is there no output form a script wrote with notepad when I call on it from the shell. I got all sorts of errors when I called on it and it wasn't right now that it's right I just simply get returned to the basic PS c:\> prompt. What am I doing wrong here?
September 12th, 2015 11:58pm

Hi.  It might be a good idea to get someone to help you translating to English.  It is a bit hard to understand what you are asking.

"I got" and "form a script" are hard to understand phrases.  I expect you are trying to say "I have and "from a script"

"when I call on it"???  What is that>?  What are you "calling on" ?  We "call on" a friend or a client."  I suspect you may mean you are "calling" a function.

You have many run on  sentences that are very hard to understand. 

What does notepad have to do with this.  Are you trying to say you "have written" a script file using notepad and you are trying to execute it?  That is good. Do you have a copy of your script?  If you want help don't you think it would be a good idea to post your script so we can try to understand what you are trying to ask?

School is a good time to learn.  Slow down and think carefully about what you are doing.  Look at other posts in these forums and try to understand what people are saying and why they ask the questions they do.

Here is good place to learn how to write a basic script and run it: https://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx?f=255&MSPPError=-2147217396

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 12:36am

$users = @{"John.Doe" = "Jdoe"; "Jane.Smith" = "Jsmith"; "Darrell.Lindsey" = "Dlindsey"; "Stephine.Ellenberg" = "Sellenberg"} 

This is my basic script which would be considered a hash I think. that I'm trying to execute. When I do this in powershell it works no problem. Yet when I wrote this in notepad and ran it it returns nothing. 

Before I had each name in () and I could execute this and it would return errors. Now I can execute this without error, but it returns nothing.

September 13th, 2015 1:44am

That is correct.  That line returns nothing.  What did you expect it to return?

A dash is iike a dictionary.  It just stores things for later use.

See; https://technet.microsoft.com/en-us/library/ee692803.aspx?f=255&MSPPError=-2147217396

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 1:46am

I know that but if I was to type $users it should bring back a list of the users. When I type it directly into powershell it does, however when I execute it it dosn't.
September 13th, 2015 2:20am

1. You are trying something that would not work. Do not use notepad for Powershell script creation at present time.

2. Powershell ISE is better alternative
https://technet.microsoft.com/en-us/library/dd315244.aspx

3. There are other tools that are alternatives of MS Powershell ISE

https://www.idera.com/productssolutions/freetools/powershellplus/powershellregistrationform

http://www.serverwatch.com/server-tutorials/6-powerful-powershell-tools-and-utilities.html

4. I do recommend to follow special webpages

http://powershell.com/cs/

5. You will find many useful ideas in MS Script Center

https://technet.microsoft.com/en-us/scriptcenter/bb410849.aspx

HTH

Milos

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 2:21am

Ok thanks.

September 13th, 2015 2:24am

I know that but if I was to type $users it should bring back a list of the users. When I type it directly into powershell it does, however when I execute it it dosn't.

There is no reason to not use notepad.  I use it all of the time and prefer to NOT use ISE. ISE is good once you understand the basics of PosH but can ge very confusing for new users.

Post the exact script you are trying to run and the exact way you are trying to run it.   Scripts must have the correct extension and must be run with a path as they cannot be run directly.

.\myscript.ps1

or

c:\myscript.ps1

Free Windows Admin Tool Kit Click here and download it now
September 13th, 2015 2:29am

I suspect your issue is scope.  Variables created in a file will only be visible while the file is running.  When the script exits the variables will disappear.

type:help about_Scopes

September 13th, 2015 2:32am

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

Other recent topics Other recent topics