By: Microtek Learning
May. 11, 2022
426
Last Updated On: May. 26, 2023
Windows PowerShell is a scripting language and object-oriented automation engine. It is mainly intended for system administrators and professionals to manage and automate the management of the Windows operating system and other application. It introduces appealing new concepts built on the knowledge and scripts you've developed in the Windows Script Host environments and Windows Command Prompt.
It combines the capability of a GUI-based admin tool, command-line speed, and flexibility of scripting. It enables you to fix problems quickly by supporting system admin in reducing future manual labour hours. We'll go through all the key points you need to know in order to understand PowerShell.
Here are a few compelling reasons to use PowerShell:
Version 1.0 of PowerShell was released in 2006, and Version 7.2 of PowerShell is the most recent version. PowerShell's features and hosting environments expanded significantly as the version and year went by.
PowerShell Remoting: PowerShell allows you to run scripts and cmdlets on a remote system.
Background Jobs: It allows you to asynchronously run a script or pipeline. You can operate your jobs on a single machine or numerous devices controlled remotely.
Transactions: Allow developers to use the cmdlet by enabling it.
Evening: You can use this command to listen to management and system events, forward them, and take action.
Network File Transfer: PowerShell uses the Background Intelligent Transfer Service (BITS) technology to provide throttled, asynchronous native support for prioritizing and moving files between machines.
We will now learn how to start PowerShell on Windows OS.
All current versions of Windows come with pre-installed PowerShell. To start PowerShell, follow these steps:
Step 1: In Windows, look up PowerShell. and click
Step 2: Opens the PowerShell Window
In the Windows PowerShell environment, a cmdlet (also known as a commandlet) is a lightweight command. In the command prompt, PowerShell calls these cmdlets. Using PowerShell APIs, you may construct and run cmdlets commands.
In many other command-shell environment, Cmdlets differ from commands in the following ways.
Cmdlets, which are always in verb-noun structure and not plural, provide most PowerShell functionality. Cmdlets also return objects rather than words. A cmdlet is a set of commands that span many lines and are stored in a text file with the.ps1 extension.
A hyphen should always be used to split a verb and a noun in a cmdlet. You can learn PowerShell by using the following verbs:
Here is a list of helpful PowerShell commands:
Get-Help: PowerShell command and topic help
Example: Show help details regarding the command Format-Table.
Get-Help Format-Table |
Get-Command: Get details about anything that can be triggered.
Example: To get a list of cmdlets and functions installed on your machine, type cmdlets into the search box.
Get-Command |
Get Service: Finds all cmdlets that contain the word 'service.'
Example: Get a list of all services that start with "vm"
Get-Service "vm*" |
Get Member: Demonstrate what an object can do.
Example: Obtain the VM processes' members.
Get-Service "vm*" | Get-Member |
Other Commands:
Example: Make a folder.
New-Item -Path 'X:\Microtek99' -ItemType Directory |
Output:
.ps1 files are used to store PowerShell scripts. You can't launch a script by double-clicking it by default. This safeguards your system from danger. To run a script:
Step 1: Right-click it and select "Run with PowerShell" from the menu.
Furthermore, script execution is restricted by policy. The Get-Execution Policy command will show you this policy.
You'll get the below output:
Step 1: Open a PowerShell prompt, then on PowerShell, right-click and select Run as Administrator.
Step 2: Enter the commands shown below:
Put the following command into a notepad.
Write-Host "Hello, Microtek Learning!” |
ps1 is the extension for PowerShell scripts. Name the file FirstScript.ps1 and save it.
The defaulting editor for Windows-PowerShell is Windows PowerShell Integrated-Scripting-Environment (ISE). You can use this ISE to execute commands, debug scripting and test them in a window-based GUI. You can do syntax colouring, multiline editing, selective execution, tab completion, and other available features.
You can also run commands on the console pane with Windows PowerShell ISE. It does, however, support windows that you can utilize to inspect the source-code of your scripts and other tools that you may pack into the Integrated Scripting Environment at the same time. variable You can even run numerous script windows at once. This is quite useful when debugging a script that calls functions from other modules or scripts.
The identical script can be written in ISE as it was in Notepad.
1 In the editor, paste the code.
2 Save the Script
3 To run the script, press F5.
4 Analyse the console output.
Sample 2:
The below code will provide you with a Free Virtual Memory on your machine.
Get-WmiObject -Class Win32_OperatingSystem –ComputerName localhost |
Select-Object -Property CSName,FreeVirtualMemory
|
PowerShell Certification Training is a popular choice among IT managers because it reduces the time and effort required to operate large corporate networks. For example, Assume you're in charge of an extensive network with over 400 servers. Now you wish to execute a new security solution, and this security solution relies on a specific service that must run on those servers.
You may certainly log in to each server and check whether or not that service is installed and operational. However, it takes quite a bit of human error because your employees must spend a lot of time on this inefficient process.
If you utilize PowerShell, though, you can do this task in a matter of minutes. This is because the entire operation is controlled by a single script that gathers information on the servers' services.
If you utilize PowerShell, though, you can do this task in a matter of minutes. This is because the entire operation is controlled by a single script that gathers information on the servers' services.
Leave a message here