3. MEET THE PRESENTER
I have worked in the majority of all market sectors within
tech functions for over 10 years
My Specialties are:-
Networking (Multi-vendor full stack)
Cloud (Public and Private)
VMware, Hyper-V and Citrix
Azure, AWS, GCP
Storage (Dell EMC / HP etc)
Deployment Automation (Windows / Linux)
Social
LinkedIn :- https://www.linkedin.com/in/theheroic/
Instagram :-
https://www.instagram.com/daisyoliviastevens/
WordPress :- https://adminscriptbank.wordpress.com/
4. WHAT IS POWERSHELL?
PowerShell is an automated task framework from Microsoft, with a command line shell and a scripting
language integrated into the .NET framework.
PowerShell is used to automate batch process’s and perform administrative tasks in Windows, Linux and
MacOS environments.
Windows PowerShell executes four types of commands:
Cmdlets
PowerShell functions
PowerShell scripts
Executable programs
6. TOOLING - VSCODE
Visual Studio Code is a source-code editor
developed by Microsoft for Windows, Linux and
macOS. With a large array of features to enhance
your development experience such as :-
Intellisence
Refactoring
Debugging
Version Control
Terminal Integration
Multi Language Support (15+)
7. TOOLING – NOTEPAD++
Notepad++ is a free (as in "free speech" and also as in "free beer")
source code editor and Notepad replacement that supports
several languages. Running in the MS Windows environment
Syntax Highlighting and Syntax Folding
PCRE (Perl Compatible Regular Expression) Search/Replace
GUI entirely customizable: minimalist, tab with close button,
multi-line tab, vertical tab and vertical document list
Document Map
Auto-completion: Word completion, Function completion and
Function parameters hint
Multi-Document (Tab interface)
Multi-Language environment supported
Bookmark
Macro recording and playback
8. TOOLING – POWERSHELL ISE
The Windows PowerShell Integrated Scripting
Environment (ISE) is a host application for Windows
PowerShell. In the ISE, you can run commands and
write, test, and debug scripts in a single Windows-
based graphic user interface.
Context-sensitive help
Selective execution
Multiline editing
10. DATA TYPES
A data type is an attribute of data which tells the
compiler or interpreter how the programmer
intends to use the data.
Data types defines the operations that can be
done on the data
Data Type Description Example
[string] Text String Hello World
[char] Symbol =
[bool] Boolean $true
[int] Integer 32 Bit 235235345
[long] Integer 64 Bit 2352353457
[decimal] 128 Bit Decimal 23523.53456d
[DateTime] Date And Time 26/07/19 10:30
[array] A series of objects all of
which are the same size
and type
“One”,”Two”,”Three”
And More!
11. OBJECTS / VARIABLES
PowerShell lets you create named objects known as
variables. Variable names can include the underscore
character and any alphanumeric characters.
When used in PowerShell, a variable is always specified
using the $ character followed by variable name.
Within PowerShell you have also have global and local
variables:
Global variables are declared outside any function,
and they can be accessed (used) on any function in
the program
Local variables are declared inside a function, and
can be used only inside that function. It is possible
to have local variables with the same name in
different functions.
12. FUNCTIONS
A function is a list of PowerShell statements that
has a name that you assign. When you run a
function, you type the function name. The
statements in the list run as if you had typed them
at the command prompt.
Like cmdlets, functions can have parameters. The
parameters can be named, positional, switch, or
dynamic parameters. Function parameters can be
read from the command line or from the pipeline.
13. IF
Every programming and scripting language has had
some sort of way to perform a conditional
operation using an If statement as part of flow
control in a script or program.
You can use the If statement to run code blocks if a
specified conditional test evaluates to true. You can
also specify one or more additional conditional
tests to run if all the prior tests evaluate to false
14. TRY
Handle a terminating error (exception) within a
script block.
Use the Try block to define a section of a script in
which you want PowerShell to monitor for errors.
When an error occurs within the Try block, the error
is first saved to the $Error.
PowerShell then searches for a Catch block to
handle the error. After a Catch block is completed,
the Finally block is run.
15. LOOP
It is a fundamental concept of any programming
language
PowerShell loops, at their most basic, simply
repeat the same set of commands a set number
of times.
16. STRUCTURE
Structured programming is a subset of procedural
programming that enforces a logical structure on
the program being written to make it more efficient
and easier to understand and modify.
Structured programming frequently employs a top-
down design model, in which developers map out
the overall program structure into separate
subsections.
Remember be consistent!
Naming Conventions, Indentation, Capitalisation
• Comment Block
• Comment Based Help
Header
• $UserName
• $UserAge
Input Params
• $Global:UDateTime = get-date
• $Env:ComputerName
Global Params
• Function Get-CompName {write-host “The Computer Name is $Env:ComputerName”}
Functions
• Get-ComputerName
Call Stack
• Write-host “The Script Has Now Finished Executing!”
Script End