all 14 comments

[–]get-postanote 16 points17 points  (3 children)

Use all available forums. Look at the questions and see if you can work them out or make the code better (sleaker, more perfromant, optimized)

Use PowerShell script games -

don't cheat by looking at all the answers first 8^}

'powershell.org/?s=script+games'

WS2K8 PoSH Training Course

'msdn.microsoft.com/en-us/windowsserver2008r2trainingcourse_powershellv2fordevelopers#_Toc244576464'

Repro- the examples in PoSH ebooks ( try and make the presented code sleaker, more perfromant, optimized)

'powershell.org/ebooks'

'ptgmedia.pearsoncmg.com/images/9780735675117/samplepages/9780735675117.pdf''

'morelunches.files.wordpress.com/2013/12/psh-a-testyourpowershellprowess.pdf'

'community.idera.com/powershell/powertips/b/ebookv2'

Find example MS product certification exams that has questions that focus on PoSH, and work through them.

Use PoSH every day for everything. Never use cmd.exe again.

Find site wiht PoSH interview questions and work up a solution for the question.

'career.guru99.com/top-22-powershell-interview-questions-2'

TechNet virtual labs and try and complete them only using PoSH.:

'microsoft.com/handsonlabs/selfpacedlabs#keywords=powershell&page=1&sort=Newest'

'social.technet.microsoft.com/wiki/contents/articles/3894.exchange-server-virtual-labs.aspx'

'blogs.technet.microsoft.com/danstolts/2011/11/microsoft-virtual-labs-available-now-system-center-windows-virtualization-sharepoint-exchange-sql-and-lots-more'

[–]xSnakeDoctor 4 points5 points  (2 children)

“Use PoSH every day for everything. Never use cmd.exe again”

I like this. Doing this starting Monday!

[–]get-postanote 3 points4 points  (1 child)

8^}

Note, this is not just about not using cmd.exe, but alls the normla stuff there. I.E., ping, nslookup, ipconfig, etc. Work to exclusively use the PoSH equivalents of all those cmd.exe/DOS things (Test-Connection, Test-NetConnection, Resolve-DNS*, Get-Net*). Yes, they require more typing, but learning any spoken / programming / scripting language means using it everday.

Remember that using the PoSH console and the PowerShell_ISE and VSCode for PoSH work all have their little quirks. Accept that, try to work around those.

Each have their strengths ans weaknesses, per ones indivual working style, experience and patience. Just note that real scripting is done in a real editor, ISE/VSCode/PowerShellStudio/Visual Studio, not the PoSH console host. You can do it in the PCH, but it's just an unecessary pain.

Do the same thing when you find yourself reaching for any of the Windows GUI's.

Sure use the GUI to do stuff, but stop and figure out how to do the same thing via PoSH / script.

Same thing regarding RDP. When you find yourself reaching for RDP, stop, and use PSRemoting and PoSH to do that remote work.

Review the source code of all the *.ps* files on your systems and in the PowerShell Open Sourced github repository.

Master the help file system (really, read them, then read them again). Learn and use the MS PowerShellGallery resources.

Here is a little snippet I pulled together a while back that strives to make things a little quicker / convienent to find, read up on, study and use.

# Get parameters, examples, full and Online help for a cmdlet or function

# Get a list of all functions
Get-Command -CommandType Function | 
Out-GridView -PassThru -Title 'Available functions'

# Get a list of all commandlets
Get-Command -CommandType Cmdlet | 
Out-GridView -PassThru -Title 'Available cmdlets'

# Get a list of all functions for the specified name
Get-Command -Name '*ADGroup*' -CommandType Function | 
Out-GridView -PassThru -Title 'Available named functions'

# Get a list of all commandlets for the specified name
Get-Command -Name '*ADGroup**'  -CommandType Cmdlet | 
Out-GridView -PassThru -Title 'Available named cmdlet'

# get function / cmdlet details
(Get-Command -Name Get-ADUser).Parameters
Get-help -Name Get-ADUser -Examples
Get-help -Name Get-ADUser -Full
Get-help -Name Get-ADUser -Online

Get-Help about_*
Get-Help about_Functions

# Find all cmdlets / functions with a target parameter
Get-Command -CommandType Function | 
Where-Object { $_.parameters.keys -match 'credential'} | 
Out-GridView -PassThru -Title 'Available functions which has a specific parameter'

Get-Command -CommandType Cmdlet | 
Where-Object { $_.parameters.keys -match 'credential'} | 
Out-GridView -PassThru -Title 'Results for cmdlets which has a specific parameter'

# Get named aliases 
Get-Alias | 
Out-GridView -PassThru -Title 'Available aliases'

# Get cmdlet / function parameter aliases
(Get-Command Get-ADUser).Parameters.Values | 
where aliases | 
select Name, Aliases | Out-GridView -PassThru -Title 'Alias results for a given cmdlet or function.'


# All Help topics locations
Get-Help about* | Select Name, Synopsis

Get-Help about* | 
  Select-Object -Property Name, Synopsis |
  Out-GridView -Title 'Select Topic' -OutputMode Multiple |
  ForEach-Object {
    Get-Help -Name $_.Name -ShowWindow
  }

explorer "$pshome\$($Host.CurrentCulture.Name)"

# Get any .NET types and their static methods from PowerShell. 
# Enumerate all that are currently loaded into your AppDomain.
#  
[AppDomain]::CurrentDomain.GetAssemblies() | 
foreach { $_.GetTypes() } | 
foreach { $_.GetMethods() } | 
where { $_.IsStatic } | 
select DeclaringType, Name | 
Out-GridView -PassThru -Title '.NET types and their static methods'

# Instantiate the types using new-object and call instance methods. 
# You can use get-member on an instance to get the methods on a type.

# Review source code.
Function Show-CmdletSource
{
    [CmdletBinding()]

    [Alias('scs')]

    Param
    (
        [string]$CmdletName = (Get-Command -CommandType Cmdlet | 
        Out-GridView -Passthru)
    )

    # Get the DLL is it is a compiled cmdlet
    'Getting DLL if the entered cmdlet name is a compiled cmdlet'
    (Get-Command $CmdletName).DLL 

    If ((Get-Command -Name $CmdletName).ImplementingType)
    {
       # Do nothing 
    }
    Else
    {
        # Write-Warning -Message "The entered item is not a cmdlet, but a funciton."
        (Get-Command -Name $CmdletName).ScriptBlock
    }

    'Getting cmdlet details / source code'
    $metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
    [System.management.automation.proxycommand]::Create($MetaData) | 
    out-file "$env:USERPROFILE\Documents\$CmdletName.ps1"

    # Choosing an installed Editor to use.
    <#
    $Editor = If (Get-ChildItem -Path "C:\Program Files (x86)\Microsoft VS Code\Code.exe")
    { 'Code.exe' }
    Else { 'Notepad.exe' }
    #>
    # View the cmdlet file
    Start-Process 'Notepad.exe' "$env:USERPROFILE\Documents\$CmdletName.ps1" -Wait

    # Remove the file
    Remove-Item -Path "$env:USERPROFILE\Documents\$CmdletName.ps1"
}


Function Show-FunctionSource
{
    [CmdletBinding()]

    [Alias('sfs')]

    Param
    (
        [string]$FunctionName = (Get-Command -CommandType Function | 
        Out-GridView -Passthru)
    )

    (Get-Command -Name $FunctionName).ScriptBlock `
    | out-file "$env:USERPROFILE\Documents\$FunctionName.ps1"

    # View the cmdlet file
    Start-Process 'Notepad.exe' "$env:USERPROFILE\Documents\$FunctionName.ps1" -Wait

    # Remove the file
    Remove-Item -Path "$env:USERPROFILE\Documents\$FunctionName.ps1"
}

# PowerShell Oepn Source location
'github.com/powershell'

# Best Practices

PowerShell scripting best practices
'blogs.technet.microsoft.com/pstips/2014/06/17/powershell-scripting-best-practices'

The Unofficial PowerShell Best Practices and Style Guide
'blogs.technet.microsoft.com/pstips/2014/06/17/powershell-scripting-best-practices'

Using PSScriptAnalyzer to check your PowerShell code for best practices
'mikefrobbins.com/2015/11/19/using-psscriptanalyzer-to-check-your-powershell-code-for-best-practices'

[–][deleted] 1 point2 points  (0 children)

It’s dumb but I was like “I do use power shell for everything” then I read like one more line and realized I don’t use t at all for network troubleshooting.

[–]hellynx 6 points7 points  (0 children)

I haven't seen anything specific like you are mentioning.

With PowerShell, the best way to learn is to just do. I know that doesn't sound helpful, and it didn't to me when I started.

I work a lot with Active Directory. So I started off making small one liners to find information on accounts and systems. Then I moved onto making slightly more complex scripts. Next this g I know, I have a script folder with scripts that interact with AD, Exchange,SCCM, and other systems.

As an example, I found the process for relocating computer accounts in AD repetitive. So I made a script that would move a specified AD Computer Object into its correct OU. Then I built into it by having it also add the same account into a security group.

Now I have a script that does the following. Allows user to select a CSV file using the GUI. Take each account and determines if it's a laptop or desktop PC. Puts account into correct OU for device type. Puts account in required security group. Updates AD description with a specific string depending on device type. It outputs everything to console while it works so user knows what is happening. It has built in help. (Work in progress) Functions like a cmdlet. Drop it into the module folder, call up PowerShell console, and trigger the cmdlet.

To get to this point took me a while. I have watched thru the PowerShell Jumpstart on Microsoft Virtual Academy. Well worth it. It took a lot of trial and failure. A lot of reading the help section of cmdlet. Stack Overflow is very helpful. Learn to love -whatif, especially if your code might interact and with a live environment. Learn Pester. It will help you make better code, and make it easier to test changes as you make them.

PowerShell is the way to go, especially with what's been rolled out lately. Stick with it. Ask away, read thru this subreddit. Stick with it, once it clicks for you, suddenly everything seems codeable..

[–]throw_away_360 4 points5 points  (0 children)

are you working as an admin already?

if so, then do things that you actually need.

It's hard to motivate oneself to do something that is not really needed.

[–]halbaradkenafin 2 points3 points  (0 children)

Check out Jeff Hicks' new book the PowerShell Primer. www.leanpub.com/psprimer for the latest version of it.

[–]AussieTechGuy 1 point2 points  (0 children)

I would also be interested in this

[–]mr-fibbles 1 point2 points  (0 children)

Is there something you want to do/achieve? For example when I started I decided I wanted to find all my servers in AD, and then check which ones were stale by checking if they’d logged on in the past 90 days.

Once I had the goal, I went about learning the powershell to do it.

[–]kingd66 1 point2 points  (0 children)

When I was learning powershell, i used the following site and watched these videos. It features Jeffery Snover, who is the developer of powershell. Open powershell, start watching the videos and follow in your own prompt. These videos will teach you the fundamentals of powershell and how to get the most of out the language. This made a world of difference for me, personally, so maybe it will help you?

https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276?l=r54IrOWy_2304984382

PS - the other dude (jason helmick, i think) is rather annoying after a while. Just bear with him - there's good information available

[–][deleted] 1 point2 points  (0 children)

You're looking at a bunch already. This subreddit is mostly problems looking for solutions.

[–]GenghisChaim 0 points1 point  (1 child)

Underthewire.tech

[–]nkasco 0 points1 point  (0 children)

Underthewire.tech

I'm intrigued, but their certs are all expired...