$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.
Get-Help
cmdlet.
$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:
New-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.
Get-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.