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
$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.
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
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
5. You will find many useful ideas in MS Script Center
https://technet.microsoft.com/en-us/scriptcenter/bb410849.aspx
HTH
Milos
Ok thanks.
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
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
Some "material evidence" may help. I mean more detailes on " I got all sorts of errors when I called on it " , how you run the script and what is the target functionality.
M.
I find that the ISE is too restrictive in that things you can do at the powershell.exe prompt are not available when using ISE.1..... Do not use notepad for Powershell script creation at present time.
...
http://blogs.msdn.com/b/powershell/archive/2009/04/17/differences-between-the-ise-and-powershell-console.aspx
I'm now using Microsoft's free VS Code editor for creating and maintaining PowerShell scripts.
https://code.visualstudio.com/
http://sp.ntpcug.org/PowerShell/Shared%20Documents/Larry_Weiss_VisualStudioCode.demo.txt
I somewhat agree with Larry although there is a prompt in the ISE but it is not as clear to new users as to how it works.
It is very helpful to type at the CLI prompt and get back information. I often build at the CLI and copy nd paste into notepad to create a complete script. If I know exactly what to do I will just type into notepad. I start a script by typing "notepad myscript.ps1" at the CLI prompt. NOw I can create and type Ctl-S to save then edit the notepad command to ".\Myscript.ps1" and run it. Make it an advanced function and we can debug it with /debug or with set-debug.
I also have used PowerShell Studio and PrimalScript for more than 10 years and actually prefer that to any other editor. Unfortunately it is not portable so, when on a clients system, I tend to use notepad. On client systems where I can have my own account I can use OneDrive and use my laptop to edit the script with PowerShell Studio. The script is available from both the laptop and the client session through the OneDrive link. Painless and transparent.
Sapien also has a free portable editor for scripts. It has no debugger or other support but will run form a thumb drive and is like notepad but with syntax coloring and code formatting for PowerShell, VBScript and a few other script languages.
Larry's link to VS Code is good although it is not portable. It is pretty light weight and quick to install.
...
Larry's link to VS Code is good although it is not portable. It is pretty light weight and quick to install.
...
Larry's link to VS Code is good although it is not portable. It is pretty light weight and quick to install.
"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."
As this has already been stated you are storing your output into a variable. So if you want to export the results to a text file then use the following method.
$users | out-file "c:\results.txt"
Thats it. This will pipe the resutls stored in the variable to a text file.
Will.
"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."
As this has already been stated you are storing your output into a variable. So if you want to export the results to a text file then use the following method.
$users | out-file "c:\results.txt"Thats it. This will pipe the resutls stored in the variable to a text file.
Will.
I don't think so unless the line is inside of the file... "scope!"
...
Larry's link to VS Code is good although it is not portable. It is pretty light weight and quick to install.
Try it. It is very light weight. PrimalPad 2015
It is a self expanding zip with the utilities. Just expand it to a th
It is a self expanding zip with the utilities. Just expand it to a thumb dr
Hello,
Now worries that you are new. You have posted in the correct forum. Even I am new. :)
Just follow the instructions fellow forum contributors and moderators have suggested and you will be a powershell wizard in no time.
Till then, I took your single line of code and put in in a powershell window. No script no nothing. Just on a console.
Output below. :)
What you have here is a HASH TABLE. It represents data in form of Key-Value pairs.