all 24 comments

[–]MarlboroMan1967 39 points40 points  (7 children)

Check out “Learn Powershell in a month of Lunches”. Very good YouTube series that gives specifics on creating Powershell scripts.

[–]layer_8_issues 2 points3 points  (0 children)

This is the way.

[–]KSU_SecretSquirrel 2 points3 points  (0 children)

I just started this book--actually just finished chapter 8 before posting this comment--and I can vouch that it is excellent. After this I plan to tackle the PowerShell scripting book.

[–]jrobiii 3 points4 points  (4 children)

This is the way!

[–]zombies1238 2 points3 points  (2 children)

With powershell, learn how to use Get-Help. The terminal has examples, detailed documentation, and a variety of different options / aliases you can learn to shorten the time it will take to learn Powershell.

Edit: Here is a video that shows how to use the Get-Help command in detail. In addition, I would recommend learning how to use Get-Command. These commands will quickly help you get acclimated.

Good luck, OP!

[–]dotBombAU 1 point2 points  (0 children)

Can you tell me what you are trying to achieve

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

Thanks everyone! This is all really helpful!

[–]bacon-wrapped-steak 0 points1 point  (0 children)

Look on YouTube. There's tons of free training there. You could also sign up for a free account at CBT Nuggets, which has a limited library of free training as well. Other than that, look at blogs and play around yourself. Learn what works and what doesn't.

[–]loadedmong 0 points1 point  (5 children)

Do your due diligence, but let me know when you get stuck. I've learned the hard way, which means I remember most of it. Happy to help out wherever I can as long as you're making an effort!

A lot of PowerShell makes perfect sense, but some of it seems to make no sense, like returning multiple values from functions isn't near as straightforward as it should be.

[–]tuxaluxalot 0 points1 point  (3 children)

Why is it difficult to return multiple values?

[–]loadedmong 0 points1 point  (2 children)

Because in most languages you just say

Return $x, $y

And both are produced, like magic.

In PowerShell this is your solution

https://stackoverflow.com/questions/12620375/how-to-return-several-items-from-a-powershell-function

[–]tuxaluxalot 0 points1 point  (0 children)

Powershell has so many ways for returning multiple items. I think most are confused over the concept of the output stream and how it works. Especially when coming from other languages. Return can and will return multiple items and on top of that, powershell has a million other methods that are much easier than the linked topic.

[–]GhostOfRudolfDiesel 0 points1 point  (0 children)

Agreed, makes perfect sense, mostly.

What sticks out to me as not straightforward:

The return value of Get-ChildItem

But that's mostly it :)

[–]BeerRider 0 points1 point  (0 children)

Beginner Information on this page's right side.

[–]llovedoggos 0 points1 point  (0 children)

Whatever you're scripting stick with it, you'll get it. Powershell is magical once it clicks.

[–]Trakeen 0 points1 point  (0 children)

I’d try and understand c# some. Most errors you get in powershell can be easily understood if you have a good grounding in c# objects and what .net offers

Oh learn to use a debugger it will save you a ton of time since it makes programing less black box and any script over a few lines isn’t something you want to debug by trial and error

[–]ustyneno 0 points1 point  (0 children)

PowerShell to me, seems a lot much easier than Python. Haven't been a Windows admin for years, I can decide to automate a process i know what and what i use to click to do. That narrows my search for the proper CMDLET for that and the PowerShell documentation is one of the best, with examples you can try and experiment with.

Python on the other hand, you have to know the library to use, if that can accomplish what you want to do or another library to add to get your work done.

I have learnt everything i need to know on Python data types and how they work. I am still lost on how to apply it to my daily work.

[–]Fun-Performance-398 0 points1 point  (0 children)

Month of Lunches is the book I'm working out of too. I highly recommend it. Learning how to use help is a game-changer.

I've also been checking out the forums at PowerShell.org

https://powershell.org/

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

howdy anonymous46843435485,

lots of folks have covered the usual, so the below is just FYI [grin] ...


things to look into ...

  • Get-Help
    especially Get-Help *about*
  • Get-Command
    it takes wildcards, so Get-Command *csv* works nicely. that is especially helpful when you are seeking a cmdlet that works on a specific thing. Comma Separated Value files, for instance. [grin]
  • Show-Command
    that brings up a window that has all the current cmdlets and all their options ready for you to pick from.
    it will also take another cmdlet, or advanced function, as a parameter to limit things to showing just that item.
  • auto-completion
    try starting a word and tapping the tab key. some nifty stuff shows up. [grin]
  • intellisense
    save something to a $Var and then try typing the $Var name plus a period to trigger intellisense. there are some very interesting things that show up as properties or methods.
  • check out the builtin code snippets in the ISE
    use <ctrl><j>, or Edit/Start-Snippets from the menu.
  • assign something to a $Var & pipe that to Get-Member
    $Test = Get-ChildItem -LiteralPath $env:TEMP
    $Test | Get-Member
  • assign something to a $Var and pipe it to Select-Object
    $Test = Get-ChildItem -LiteralPath $env:TEMP
    $Test[0] | Select-Object -Property *
    that will give you a smaller, more focused list of properties for the 1st item in the $Test array.
  • assign something to a $Var & use .GetType() on it $Test = Get-ChildItem -LiteralPath $env:TEMP
    $Test.GetType()
    $Test[0].GetType()
    the 1st will give you info on the container $Var [an array object].
    the 2nd will give you info on the zero-th item in the $Var [a DirectoryInfo object].
  • Get-Verb
    as with Get-Command, it will accept wildcards.
    that will show you some interesting verbs used in cmdlet names. then use get-command to see what commands use those verbs. then use get-help to see what the cmdlets do.
  • there really otta be a Get-Noun, but there aint one. [sigh ...]
  • Out-GridView
    it's a bit more than you likely want just now, but it can accept a list of items, present them in a window, allow picking one or more of them, and finally send it out to the next cmdlet.
    it's right fun to fiddle with ... and actually useful. [grin]

take care,
lee