
Basics
PowerShell is a command-line shell and scripting language that is designed to help you automate administrative tasks. With PowerShell, you can automate repetitive tasks, manage remote computers, and perform complex operations on data. To open PowerShell, click on the Start button and type in âPowerShellâ in the search box. You can also open PowerShell from the Command Prompt by typing in âPowerShellâ and hitting Enter. You can also open PowerShell in Windows Terminal. Once you have PowerShell open, you can start typing in commands.How to Set Up PowerShell Properly
In this post, weâll cover the basics of setting up PowerShell on your machine. Weâll go over the different versions of PowerShell, how to check which version you have, and how to install or update PowerShell if necessary. Weâll also cover how to configure PowerShell to run scripts and how to set execution policies. If youâre new to PowerShell, the first thing you need to do is set it up on your machine. PowerShell comes pre-installed on most Windows machines, but if you need to install or update PowerShell, itâs a straightforward process. First, you need to determine which version of PowerShell you have installed on your machine. To do this, open PowerShell and type in$PSVersionTable
. This will display the version of PowerShell you have installed, along with some other useful information.

C:\powershell_filename.ps1
cannot be loaded because running scripts is disabled on this system.

Set-ExecutionPolicy RemoteSigned
.

Get-ChildItem
cmdlet.
How to get-help?
To get help with a cmdlet, you can use theGet-Help
cmdlet.

variables
Like any other programming language, variables are used to store values and data. They can be used to store text, numbers, objects, and other data types. Variables in PowerShell are denoted by a dollar sign ($), followed by the name of the variable. E.g.,$name
is variable.
To create a variable in PowerShell, simply type the name of the variable, followed by the equals sign (=), and the value you want to assign to the variable. For example, to create a variable called $name
and assign it the value âRajâ, you would type:
$name
variable, you would type:
$name
variable, you could use the following command:
$name
variable to âAntoâ, you would type:

PowerShell Cmdlets and Alias
In the previous post, we covered variables in PowerShell. In this post, we will be discussing cmdlets. It is pronounced as âcommand-lets.â It is the fundamental building block of PowerShell. It is a small, single-purpose, lightweight command that performs a specific task. It is designed to be used in combination with other cmdlets to accomplish complex tasks. PowerShell includes hundreds of built-in cmdlets for tasks such as managing the file system, managing services, and managing processes. Additionally, many third-party software vendors provide PowerShell cmdlets for their products, including Microsoft SQL Server. Cmdlets have a consistent naming convention of Verb-Noun, where the verb describes the action to be taken, and the noun describes the object the action is being taken on. For example, the cmdlet for creating a new folder isNew-Item
, where âNewâ is the verb, and âItemâ is the noun.
To use a cmdlet, simply type its name followed by any required parameters. Letâs take a look at an example using the Get-ChildItem
cmdlet:
Get-ChildItem
cmdlet is used to retrieve a list of all items in the C:\Rajanand\PowerShell\
folder.

data
. We could use the Get-ChildItem
and Where-Object
cmdlets together like this:
Get-ChildItem
cmdlet to retrieve a list of all items in the C:\Rajanand\PowerShell\
folder. We then pipe(i.e., |) that list to the Where-Object
cmdlet, which filters the list to only include items with a Name property starts with data
.


Select-Object
cmdlet, which selects and displays only the Name, CreationTime, LastWriteTime and Length properties of the remaining items.
Alias
Itâs worth noting that many cmdlets also have aliases, which are shorter or alternative names for the same cmdlet. For example, theGet-ChildItem
cmdlet has an alias of ls
or dir
. ls
is used in Unix based system to list out the files in the current directory and dir
is used in windows for the same purpose.
As you can see below, We are able to get the list of items in a directory using ls
and dir
alias of Get-ChildItem

Get-Alias

Set-Alias
In conclusion, cmdlets are the basic building blocks of PowerShell and provide a powerful and flexible way to perform a wide range of tasks. Alias is used to simplify the command that we frequently use.