Power Shell learning

DeathmageDeathmage Banned Posts: 2,496
Hey all,

anyone know a good resource for someone starting out but wanting to learn powershell. I deal with Windows server on a daily basis and I'm curious of PowerShell and what it can do for me.

Any help is appreciated.

Comments

  • kohr-ahkohr-ah Member Posts: 1,277
    Are you looking to script in it or use it?

    I've heard good things about this:
    https://www.youtube.com/user/powershelldon/featured

    To get used to the commands and things you can do. Otherwise I sent a message to my friend as he is a powershell guru and asked how he learned.
  • cs8400cs8400 Member Posts: 90 ■■■□□□□□□□
    Here's two good starters...
    Microsoft PowerShell Tutorial & Training Course
    powershell script, powershell scripts, powershell scripting,

    MVA has a bunch of videos that are really good for learning powershell and MS products (especially since they are free!)

    "Learn Powershell in a Month of Lunches" is also a great resource. I reference it often.
    http://www.amazon.com/Learn-Windows-PowerShell-Month-Lunches/dp/1617291080/ref=sr_1_1?ie=UTF8&qid=1432993104&sr=8-1&keywords=powershell
  • kj0kj0 Member Posts: 767
    Also check out Pluralsight and CBT nuggets if you have a subscription.
    2017 Goals: VCP6-DCV | VCIX
    Blog: https://readysetvirtual.wordpress.com
  • QordQord Member Posts: 632 ■■■■□□□□□□
    The jump start linked above is one of the best resources out there.

    There's also a great powershell forum on the spiceworks community forum, some great helpers there.
  • emerald_octaneemerald_octane Member Posts: 613
    Don't do what I did and expect to know everything about a particular programming language within the first 2 weeks. Get the basics down first, for instance how do you configure your IDE and interpreters (usually the first chapter of most books). Then look at sample code and try modifying it to your needs or write your own simple code. It'll go slow because you need to look up everything but eventually you'll know where to look. If you deal with creating user accounts all day, first start by figuring out how to parse AD for a formatted list of users. Next try to add or remove an account. All this should be in a test environment by the way.
  • the_Grinchthe_Grinch Member Posts: 4,165 ■■■■■■■■■■
    Powershell is pretty amazing and definitely a great language to learn. As an example, when I worked at an MSP a customer asked that we tell him every non-system level account used to run services on all their servers. If I remember correctly they had something like 70 servers and a ton of services utilizing non-system level accounts. Being the night guy they told me it would be my job to get all the information within a week. With the help of some people here I was able to put all the server names in a file and then with Powershell query all the servers for the accounts used for the services. Shocking how many user accounts they were using and the customer was shocked how quickly we got it done.
    WIP:
    PHP
    Kotlin
    Intro to Discrete Math
    Programming Languages
    Work stuff
  • DeathmageDeathmage Banned Posts: 2,496
    the_Grinch wrote: »
    Powershell is pretty amazing and definitely a great language to learn. As an example, when I worked at an MSP a customer asked that we tell him every non-system level account used to run services on all their servers. If I remember correctly they had something like 70 servers and a ton of services utilizing non-system level accounts. Being the night guy they told me it would be my job to get all the information within a week. With the help of some people here I was able to put all the server names in a file and then with Powershell query all the servers for the accounts used for the services. Shocking how many user accounts they were using and the customer was shocked how quickly we got it done.

    Indeed I heard of it's benefits at the VMUG.... but I was like what is this elusive PowerShell....kind of peaked my interest.

    They also said at the VMUG moving in the DCA/VCDX Powershell is a must! - so kind of a good reason to learn. icon_razz.gif
  • techfiendtechfiend Member Posts: 1,481 ■■■■□□□□□□
    I'm about halfway through AD in a month of lunches and most of what I've read so far is typical admin duties I perform in adac and aduc on a regular basis. However it gives powershell commands for every task and explains when it's worth considering over gui. It's a great introduction along with adac powershell history but it doesn't dig very deep, yet.
    2018 AWS Solutions Architect - Associate (Apr) 2017 VCAP6-DCV Deploy (Oct) 2016 Storage+ (Jan)
    2015 Start WGU (Feb) Net+ (Feb) Sec+ (Mar) Project+ (Apr) Other WGU (Jun) CCENT (Jul) CCNA (Aug) CCNA Security (Aug) MCP 2012 (Sep) MCSA 2012 (Oct) Linux+ (Nov) Capstone/BS (Nov) VCP6-DCV (Dec) ITILF (Dec)
  • MutataMutata Member Posts: 176
    I picked up PowerShell by simply deciding I would spend a few months trying to do every admin task I would normally do in a GUI in PowerShell. More than anything, I think that helped me the most.
  • iBrokeITiBrokeIT Member Posts: 1,318 ■■■■■■■■■□
    Anything Don Jones puts out is great. Start with the free YouTube videos and go from there.

    Like any language the more you work with it on a regular basis the better you get at it. Instead of doing simple tasks through the GUI like creating a new AD user or spinning up a VM start doing them in PowerShell so you understand the syntax then turn them into scripts.

    After you got the basics down, try to avoid googling commands and examples, instead use the Get-Help command to lookup the syntax.

    I <3 PowerShell.
    2019: GPEN | GCFE | GXPN | GICSP | CySA+ 
    2020: GCIP | GCIA 
    2021: GRID | GDSA | Pentest+ 
    2022: GMON | GDAT
    2023: GREM  | GSE | GCFA

    WGU BS IT-NA | SANS Grad Cert: PT&EH | SANS Grad Cert: ICS Security | SANS Grad Cert: Cyber Defense Ops SANS Grad Cert: Incident Response
  • elToritoelTorito Member Posts: 102
    The Scripting Guy Blog is also a great resource: Hey, Scripting Guy! Blog - Site Home - TechNet Blogs

    Some of the articles are rather basic, but it's a good way to see what PowerShell is capable of, and it gives insight on correct syntax, proper error handling, and so on.

    One of the writers on that blog, Ed Wilson, also writes comprehensive books on VBscript and PowerShell. They're good reads.
    WIP: CISSP, MCSE Server Infrastructure
    Casual reading:
    CCNP, Windows Sysinternals Administrator's Reference, Network Warrior


  • lsud00dlsud00d Member Posts: 1,571
    PoSH is a must...Windows Server is moving increasingly towards remote administration (as it should be) and everyone should be using Server Core unless there's a business case NOT to.

    With all of PoSH's modules, CLI admin'ing is a breeze. Thanks for coming full-circle, Microsoft!

    @Deathmage, if you haven't checked out this blog you should. It's not PoSH focused but it'll help you get in the command-line/scripting mindset

    http://blog.commandlinekungfu.com/

    Aside from that, fancy things to pick up on are dot notation, piping through 'get-member' to see what all you can incorporate, and ft -hidetableheaders, because unless I'm generating a report I don't want headers ;)
  • MutataMutata Member Posts: 176
    lsud00d wrote: »
    Windows Server is moving increasingly towards remote administration (as it should be) and everyone should be using Server Core unless there's a business case NOT to.

    I think this is a very interesting point. I have worked in some large environments, and have actually YET to see Core out in the wild.
  • lsud00dlsud00d Member Posts: 1,571
    Mutata wrote: »
    I think this is a very interesting point. I have worked in some large environments, and have actually YET to see Core out in the wild.

    There's a large barrier for entry in large enterprise-type environments because they have to start the build/testing process from scratch, in addition to a lot of the technical staff learning new skills and processes.

    But...this is but excuses. From a security perspective, if there's no reason to RDP to a box, if there's no reason for services and/or Windows features to be running/installed...get it OUT OF THERE. Minimize the attack surface, minimize the human element, and ultimately minimize the risk.
  • techfiendtechfiend Member Posts: 1,481 ■■■■□□□□□□
    I get the security aspect of server core but there are some commonly used AD things that are very difficult to perform with powershell that are so easy to perform in gui. It seems like most of the complex AD things are easier or can only be in powershell. I don't think powershell is there yet to rely solely on server core for administrated AD. Frankly I think the language is much more complicated than it has to be. They could use some ideas from cisco and linux. I can imagine a lot of broken tab keys on powershell gurus keyboards.
    2018 AWS Solutions Architect - Associate (Apr) 2017 VCAP6-DCV Deploy (Oct) 2016 Storage+ (Jan)
    2015 Start WGU (Feb) Net+ (Feb) Sec+ (Mar) Project+ (Apr) Other WGU (Jun) CCENT (Jul) CCNA (Aug) CCNA Security (Aug) MCP 2012 (Sep) MCSA 2012 (Oct) Linux+ (Nov) Capstone/BS (Nov) VCP6-DCV (Dec) ITILF (Dec)
  • lsud00dlsud00d Member Posts: 1,571
    Powershell is object-oriented (Ruby, Java, C++) so this is a large departure from IOS and Bash. I came from a *nix background into PoSH scripting and both definitely have their pro's and con's, but PoSH CLI is the future of Windows administration (along with server core)...as long as everyone stops being lazy and hops on the gravy train.

    Powershell is very easy and intuitive once you get the basics and it's fury is unleashed as you scale up. Regardless, I can perform any task faster via CLI than you can via GUI. This is not a challenge--it is a fact. For example, disable all user accounts with lastlogondate greater than 90 days. Pffft, I hardly bat an eye at the one-liner.
  • techfiendtechfiend Member Posts: 1,481 ■■■■□□□□□□
    I wouldn't dare attempt something like that in a gui and that's what I mean by more complex or bulk processing. Something common that's much easier to do with gui instead of powershell is password resets, unless you have a premade script, fine-grained passwords would be another. Can powershell create wmi filters? That's pretty important in heterogeneous environments.

    What I mean by taking ideas from cisco and linux is shortened commands, powershell seems to compete for the longest word on a regular basis and you can't express it any other way and case-sensitive on top of that but the tab key makes it tolerable. I haven't really gotten into aliases yet but it shouldn't be required, the unique possibilities are good unless you deal with many environments then they are nuisance.

    Some thing that doesn't make sense to me in powershell is the DC is often required, it's inconsistent and should default to local if not entered imo. IIRC it also at times requires parameters for unchanged values, this is just dumb.
    2018 AWS Solutions Architect - Associate (Apr) 2017 VCAP6-DCV Deploy (Oct) 2016 Storage+ (Jan)
    2015 Start WGU (Feb) Net+ (Feb) Sec+ (Mar) Project+ (Apr) Other WGU (Jun) CCENT (Jul) CCNA (Aug) CCNA Security (Aug) MCP 2012 (Sep) MCSA 2012 (Oct) Linux+ (Nov) Capstone/BS (Nov) VCP6-DCV (Dec) ITILF (Dec)
  • lsud00dlsud00d Member Posts: 1,571
    set-adaccountpassword...?

    How to Change a User's Active Directory Password with PowerShell - Hey, Scripting Guy! Blog - Site Home - TechNet Blogs

    What do you want to do with WMI filters?

    Exporting and Importing WMI Filters with PowerShell: Part 1, Export - Manny Murguia's Blog - Site Home - TechNet Blogs

    PoSH has aliased commands (like IOS/bash) and it's definitely not case-sensitive. There are many ways to shorten PoSH commands/scripts.

    I'm fairly well-versed in CLI on mutliple platforms and honestly I'm not trying to argue with you here but I don't think you've explored these things enough for the claims (opinions) you're stating.
  • snadamsnadam Member Posts: 2,234 ■■■■□□□□□□
    elTorito wrote: »
    The Scripting Guy Blog is also a great resource: Hey, Scripting Guy! Blog - Site Home - TechNet Blogs

    Some of the articles are rather basic, but it's a good way to see what PowerShell is capable of, and it gives insight on correct syntax, proper error handling, and so on.

    One of the writers on that blog, Ed Wilson, also writes comprehensive books on VBscript and PowerShell. They're good reads.


    +1 for Scripting guy. A few years back at my old job, I was tasked to create a weekly report regarding accounts with VPN access in AD. IIRC, Scripting Guy taught me how to build the report in a comprehensive readable csv format, and then email it to management in one script. I scheduled/automated it in Server 2008 and that was that. I'm sure it wasn't the most secure method on the planet, but the point is it worked and Scripting Guy taught me.
    **** ARE FOR CHUMPS! Don't be a chump! Validate your material with certguard.com search engine

    :study: Current 2015 Goals: JNCIP-SEC JNCIS-ENT CCNA-Security
  • techfiendtechfiend Member Posts: 1,481 ■■■■□□□□□□
    I mean password resets without a script, it's a much more complicated process than it really should be. I've never seen a common command half as complex in IOS or bash, much less having to download/write a script. Another thing I came across today is creating a global catalog, it apparently can't be done with powershell commands and requires a script. It's a 5 second task in AD sites and Services. I'm guessing I'll come across more as I continue to study.

    Create a WMI filter in powershell, I haven't found a way to do it yet. Tough to rely solely on server core when useful features like this can't even used with it. I don't dislike powershell and think it can do a lot of useful things but it definitely deserves some criticism.
    2018 AWS Solutions Architect - Associate (Apr) 2017 VCAP6-DCV Deploy (Oct) 2016 Storage+ (Jan)
    2015 Start WGU (Feb) Net+ (Feb) Sec+ (Mar) Project+ (Apr) Other WGU (Jun) CCENT (Jul) CCNA (Aug) CCNA Security (Aug) MCP 2012 (Sep) MCSA 2012 (Oct) Linux+ (Nov) Capstone/BS (Nov) VCP6-DCV (Dec) ITILF (Dec)
  • Matt2Matt2 Member Posts: 97 ■■□□□□□□□□
    Another resource.. though might be a mix of other MSFT URL content already provided... https://technet.microsoft.com/en-us/scriptcenter/powershell.aspx
  • lsud00dlsud00d Member Posts: 1,571
    IOS and *nix default user databases aren't LDAP-based, but as I stated above it's a simple one-liner to reset a single users password, or all users in the domain.

    As far as a global catalog--

    Set-ADObject "CN=NTDS Settings,CN=Fabrikam-DC1,CN=Servers,CN=Default-First-Site-Name,CN=Sites,CN=Configuration,DC=Fabrikam,DC=COM" [email]-Replace@{options='1'}[/email]https://technet.microsoft.com/en-us/library/dd378812(v=ws.10).aspx

    WMI filtering (as in Group Policy) is a little trickier since WMI uses WQL but it can be exposed through Group Policy's COM interface, as explained in this guy's cool module:

    https://gallery.technet.microsoft.com/scriptcenter/Group-Policy-WMI-filter-38a188f3

    All languages definitely deserve their criticism but I'm not sure if you're digging deep enough.
  • techfiendtechfiend Member Posts: 1,481 ■■■■□□□□□□
    It's pretty shallow right now because while I've used PS for rare things over the years I've only just begun using it heavier a month ago. IOS I have a few months of experience with and have no real common sense criticisms and bash I have a few years of experience but years ago and no real criticisms with. That I'm finding all these things so early on doesn't bode well but maybe they'll improve it enough to turn me,

    AD delegation is another thing missing in PS, it needs a module or a lengthy script to do it. Also why is there no sorting by default when listing? Another thing that makes no sense to me.

    Microsoft bringing SSH to Windows and PowerShell | Ars Technica good news for powershell but it shows I'm not alone when it comes to it not being a good shell environment. More of a scripting language with some cmdlets to emulate shell.
    2018 AWS Solutions Architect - Associate (Apr) 2017 VCAP6-DCV Deploy (Oct) 2016 Storage+ (Jan)
    2015 Start WGU (Feb) Net+ (Feb) Sec+ (Mar) Project+ (Apr) Other WGU (Jun) CCENT (Jul) CCNA (Aug) CCNA Security (Aug) MCP 2012 (Sep) MCSA 2012 (Oct) Linux+ (Nov) Capstone/BS (Nov) VCP6-DCV (Dec) ITILF (Dec)
  • DigitalZeroOneDigitalZeroOne Member Posts: 234 ■■■□□□□□□□
    Deathmage wrote: »
    Hey all,

    anyone know a good resource for someone starting out but wanting to learn powershell. I deal with Windows server on a daily basis and I'm curious of PowerShell and what it can do for me.

    Any help is appreciated.

    Since people have already given resources and links to go to, I would recommend this. Make sure that you learn the basics of PowerShell first, don't try to dive right in and learn certain cmdlets for Win2k12. I've had many co-workers say how difficult PS is, but that's because they want to jump right into some complex script, they don't want to take the time to really learn the fundamentals.

    Once you have a firm understanding of PS, you can use it on practically anything. I learned the foundations, and then when it came time to do things on vSphere, I was about to find the cmdlets that I needed and perform complex tasks quickly. The versatility of PS is endless. HP has PS input, VMware, too many Microsoft products to list, and that's just the start.

    Go into this thinking that it is going to take years to fully master it, because it can get quite complex, but the overall time you'll save in performing tasks, as well as the boost in your career is well worth the time and effort.
Sign In or Register to comment.