r/PowerShell • u/Skippy9871 • Jan 09 '26
Question Learning PS
I dont know if i can ask this here but im kind of out of options. Im studying Server & Network engineering. Within 2 weeks i have an exam where i need to make some scripts. The way they teach in school sucks for me. They just roll over everything & they learn us to copy & paste all cmds they give so i dont rly get the change to get the feeling of it. Do any of u guys know how i could learn or get the feeling from Powershell to pass my exam?
7
Upvotes
View all comments
Show parent comment
0
u/Future-Remote-4630 Jan 12 '26
I would get as many of those examples as you can and feed them into your AI engine of choice to generate a wider curriculum set. From there, don't use the AI to make the scripts. Ask it for at most a hint as to what command you should research to get started, and use the other resources provided in this thread to get through the whole curriculum set. If you have any programming experience to start with, a source like learnxinyminutes can help you more quickly translate the concepts you already know into their powershell script equivalent: https://learnxinyminutes.com/powershell/ Otherwise, your goal should be to get comfortable with getting the help that you can get while building scripts. Example: File Dir Checker
Need to be able to read a directory or file. What command can we use to do that? After learning some of the powershell basics, files, directories, registry keys, and much more are all considered "Items". The PS equivalent of "ls" in linux or "dir" in cmd is "Get-ChildItem". Knowing that, we just need to figure out how to use that command.
Get-Childitem | Get-Help
This will show us the syntax and the parameters we can give this command.
This will show us some actual use cases that we can probably modify to our use case here.
Let's say we didn't know that Get-Childitem was an option, and instead just try searching a command. All files and folders have to be located somewhere, so lets see what commands we have if we search for "path".
Looking at the results from that search, we can use the module their from to eliminate some of them, so from here we can use Get-Help and the -examples switch in order to view the potential options more clearly. Test-Path looks like it does exactly what we want here to see if something exists or not.
2. Need to be able to determine if it's there or not From the example, we can see that after using test-path and giving it a path, it already returns a True or False value, so it does this step for us. 3. Need to return that value In order to make it a checker, rather than just a command we are entering, we need to make it a function. You can get information about powershell programming concepts, like functions, by using get-help as well.
Ok, so that last example looks like exactly what we need, aside from needing a way for us to provide it with the path we are checking. Similar to other OOP languages, we just add in a parameter to the definition for the input we will need. function example($ThisIsMyParameter){#Do something} Lastly, we can combine the above into the final product.
This is really just a wrapper around the test-path function, so it's not doing much now. Maybe that's all they want from you, or maybe you need it to be more specific. Once we have this, we really just need to hone it to the asks of the question. Your example said "A script to check whether certain files and/or folders are present at a specified location/data carrier". Maybe that means we need to be able to accept a list of file names or folders and check if all of them exist in the target path?
Good luck.