
Introduction. Also don't forget to check out the bonus video! Please note the appendix set up the lab is not online but not necessary you can do everything except Active Directory on your machine
Starting the PowerShell shell
Using the PowerShell shell
Why we already know PowerShell
What are Cmdlets ?
Using Cmdlets and parameters
What are properties ? Do not belong to Cmdlets
EXAMPLES:
Get-Service
Stop-Service
Start-Service
Looking online
Get-LocalUser
Set-LocalUser
To quote or not to quote
Using Help with Cmdlets using the Cmdlet Get-Help to get the parameters and values it needs.
Using the internet to find out about Cmdlets
Updating help with Update-Help
How do you find the right Cmdlet for the job to do ?
Is it Set-LocalUser or Disable-LocalUser for disabling a local user ?
What are modules ?
Using Get-Command
What is the PowerShell pipeline ?
EXAMPLES:
Get-Service –Name ‘spooler’ | Stop-Service
Get-Service –Name ‘spooler’ | Start-Service
Get-LocalUser –Name ‘Dave’ | Set-LocalUser –Description ‘My Lovely Account’
What is the PowerShell pipeline ?
EXAMPLES:
Get-Item -Path ’C:\Source\1.txt' (Retrieve one item)
Copy-Item -Path 'C:\Source\1.txt' -Destination 'C:\Target'
Get-Item -Path ’C:\Source\1.txt' | Copy-Item -Destination 'C:\Target'
What is the PowerShell pipeline ?
EXAMPLES:
Get-ChildItem -Path ’C:\Source' (Retrieve all items in a directory)
Get-ChildItem -Path ’C:\Source' | Copy-Item -Destination 'C:\Target'
How do we output to a text file ?
EXAMPLES:
Get-Service | Out-File –FilePath ‘c:\test\services.txt’
Look at properties again and why parameters are not properties.
Drop a word called ‘object’ on you and see how you respond
How do we format data in PowerShell ?
EXAMPLES:
Get-Service | Format-List –Property
Get-Service | Format-Table –Property
Get-Service | Format-Table –Autosize | Out-File –FilePath ‘C:\test\test.txt’
PowerShell Objects a deeper look what they are and where they come from !
How can we find out the properties and methods of an object?
EXAMPLES:
Get-Service | Get-Member
Get-LocalUser | Get-Member
How can we find out the kind of properties of an object?
EXAMPLES:
Get-Service | Get-Member
How can we find out the kind of parameters we need ?
EXAMPLES:
Get-Service
How can we find out the kind of parameters we need ?
EXAMPLES:
Get-Service
How can we get only the stuff we need based on a property of an object ?
EXAMPLES:
Get-Service | Where-Object {$PSItem.status –eq ‘running’} | Out-File –FilePath ‘C:\reports\report.txt’
How can we get only the stuff we need based on a property of an object ?
EXAMPLES:
Get-LocalUser | Where-Object {$PSItem.enabled –eq $false} | Set-LocalUser ` –Description ‘Disabled Account’
How do we select specific information ?
EXAMPLES:
Get-Service | Select-Object –First 5
Get-Service | Select-Object –Last 5
Get-Service | Select-Object –Property name,status –First 5 | Out-File –FilePath ‘C:\test\services.txt’
How can we group in alphabetical order or from high to low and vice versa?
EXAMPLES:
Get-Service | Sort-Object –Property ‘Status’
How can we output to CSV in a simple way ?
Getting it all together + some gotchas
A nice Mini Challenge to think about!
A nice Mini Challenge to think about...again!
Moving on to a script
What is a PowerShell script ?
Using and exploring the PowerShell ISE (Integrated Scripting Environment)
Running a small script
Set-ExecutionPolicy
Writing our first PowerShell Script “Hello Wonderful People!”
Variables in PowerShell
What is a variable ?
Defining a variable in PowerShell
Different types of variables in PowerShell (DataTypes) and why important ?
Example string,int,datetime and many many more.
Integer (int)
String (str or text)
Boolean (bool)
DateTime (Store Date)
Using [string]$DogType or [int]$Number to tell PowerShell what datatype you want.
Using $MyVariable.GetType() to see what kind of variable you have.
Getting data from the user using Read-Host.
Using this data in a PowerShell Script.
What are Arythmic Operators ?
+ Add, - Subtract, * Multiply, / Divide, % Mod(Remainder)
Objects 2 the return of the killer object…
Putting an object into a variable and using its properties and methods, more specifically it is an instance from a command.
EXAMPLES:
$Service = Get-Service –Name ‘spooler’
$Service | Get-Member
How to use If Statement to make decisions in your script
Creating multiple decisions in your script with If/ElseIf/Else Statement
And some gotchas
If/Elseif/Else statement.
Scripting Example : if a local user is enabled, disable it and if a local user is disabled enable it.
STEPS:
Which Cmdlets do I need ? Look at the internet to find out.
Which Parameters of Cmdlets am I going to use ?
What variables am I going to use.
Which properties of the object which is in the variable do I need and what are the possible values of the properties.
If/Elseif/Else statement. And some extra tips and tricks added continuing part 3!
Scripting Example : if a local user is enabled, disable it and if a local user is disabled enable it.
STEPS:
Which Cmdlets do I need ? Look at the internet to find out.
Which Parameters of Cmdlets am I going to use ?
What variables am I going to use.
Which properties of the object which is in the variable do I need and what are the possible values of the properties.
If/Elseif/Else statement. And let's make a sentence continuing part 4!
Scripting Example : if a local user is enabled, disable it and if a local user is disabled enable it.
STEPS:
Which Cmdlets do I need ? Look at the internet to find out.
Which Parameters of Cmdlets am I going to use ?
What variables am I going to use.
Which properties of the object which is in the variable do I need and what are the possible values of the properties.
Nested If/ElseIf/Else statement.
Continuing Nesting If/ElseIf/Else statement. (That bird doesn't have it easy)
What are comparison operators ?
What are logical operators ?
Are you ready to program the next gaming sensation ?
Explanation of what a loop is and what a While loop does
Explanation of what a loop is and what a While loop does
Are you ready to program the next gaming sensation ?
PowerShell Arrays
Indexing in an Array
Using the Foreach to loop through a PowerShell array
PowerShell Arrays with LocalUsers
Indexing in an Array with LocalUsers
Using the Foreach to loop through a PowerShell array of Local User Objects
Using a combination Foreach and If
Mmmm nothing more descriptive to add here
Are you ready to program the next gaming sensation ?
Creating Local Users from a simple text file
Creating Directories or files from a simple text file
Well...just in case you didn't know how
Using and exploring the Import-Csv Cmdlet
Using the Import-Csv Cmdlet to create Local Users
You will need to finish the set up lab environment to follow along, or use your own setup
Moving to Active Directory
Creating an Active Directory User with PowerShell
Since the Active Directory Cmdlets are tricky, I have added them here in the scripting part
Moving to Active Directory
Retrieving a user in Active Directory
Since the Active Directory Cmdlets are tricky, I have added them here in the scripting part
Moving to Active Directory
Set AD user properties
Since the Active Directory Cmdlets are tricky, I have added them here in the scripting part
Moving to Active Directory
Creating an Organizational Unit
Move Active Directory users from one OU to another OU
Selecting more Active Directory Users with Where-Object
Nothing more to add here, except that maybe you can do this yourself and then watch the video!
Just create a file with some names and add them to Active Directory in any OU you want !
Again, nothing more to add here, except that maybe you can do this yourself and then watch the video!
Just import a CSV file we created earlier for the Local Users!
What is PowerShell remoting ?
Introduced in PowerShell version 2 but PowerShell version 3 perfected it.
Needs Domain Joined Machines, it doesn’t work very well with standalone machines, though still possible with some tweaks here and there.
Enable PS Remoting
How to use an interactive One To One Remoting PowerShell Session with Enter-PSSession
How to do One-To-Many Remoting with Invoke-Command
How to do One-To-Many Remoting with Invoke-Command and establishing a session first with New-PSSession and the advantages
It is almost time for a nice challenge and test yourself, but first some words of encouragement
A hard one but you got this!
Ever found PowerShell and scripting intimidating ? This course will help you!
Designed for the complete beginner like IT engineers, and system administrators with no programming experience, demystifying PowerShell for you from the ground up. Together we will start with the basics of PowerShell Cmdlets and gradually build your skills and confidence to tackle more complex scripting.
Whether you're new to programming, an IT engineer, or a system administrator who's always wanted to script but thought it was out of reach, this course is perfect for you. This course will break down each concept into easy-to-digest lessons, starting with simple Cmdlets like Get-Service and advancing to powerful scripting techniques. You'll learn about parameters, filtering properties with Where-Object, and how to use if/elsif/else statements and arrays with foreach loops.
Imagine the possibilities: automating tasks for your user management, files and folders, server management. PowerShell is everywhere !
Step by step, no prior knowledge assumed, and no steps omitted. I designed this course to be enjoyable and engaging, keeping you motivated throughout the learning journey.
By the end, you'll not only be proficient in using PowerShell Cmdlets but also capable of creating effective PowerShell scripts.
Welcome to PowerShell from Beginner to Sheller and Scripter .