Trending December 2023 # Basics Of Windows Powershell Script # Suggested January 2024 # Top 16 Popular

You are reading the article Basics Of Windows Powershell Script updated in December 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested January 2024 Basics Of Windows Powershell Script

Basics Of Windows PowerShell Script

PowerShell Script consists of commands that are called cmdlets. The cmdlets let you access data stores such as certificate and registry stores like file systems. Putting in simple words, using this very rich Scripting language, you can do almost any task that you do on Graphical User Interface (GUI)

What is the need for PowerShell Script when there is already a command prompt?

If you have just come across Windows PowerShell Script, you might be wondering that how is PowerShell Script any different from Command Prompt?

In the blog that follows, you shall also see how you can create a PowerShell Script

How to create a PowerShell Script?

There are two ways using which you can create PowerShell Script

You can write PowerShell Script using the notepad editor or

You can use Integrated Scripting Environment or ISE to create PowerShell Scripts

1. To write PowerShell Script Using Notepad

Step 1:

Step 2:

Once you opened the Notepad, type or paste your text (which is known as the Script). For e.g. Type, This is my first Script

Step 3:

Follow the path mentioned below –

In the File name suffix name with .ps1.

For e.g. sample_Script.ps1 and hit Save button

2.  To Create Windows PowerShell Script Using Integrated Scripted Environment (ISE) What is an ISE?

ISE short for integrated scripting environment is an editor where you will run, test and debug scripts. In simple terms, it is a console where you run commands. As shown in the figure above it consists of 3 parts namely –

Script Interface

PowerShell Console

Command Module

Note: Once you write a PowerShell Script in a script interface, it gets executed in PowerShell Console once you press F5 button.  

Step 1:

Go to search bar and type Windows Powershell

Step 2:

Now you will find Run as Administrator

Step 3:

Type a text in the window that opens. For e.g. This is my first PowerShell Script

Step 4:

Save the file with the suffix the file name with .ps1

Executing the Windows PowerShell Script

Now after you have created the file, it’s time to run that file. For this, you will first have to change the execution policy. What this will do is that it will allow Scripts to run. It is very crucial to note is that there are four execution policies namely (please write these as mentioned below) –


Scripts created on the device are run. If you wish to run scripts on another device, these scripts would require a signature from a trusted publisher.


This command, as the name suggests will stop any script from being executed.


This command permits all scripts to be executed on a condition that they are signed by a trusted publisher.


This command runs all the scripts without any restriction.

Let’s try and execute a sample Windows PowerShell Script. To do this –  

Step 1:

In the search bar type PowerShell and then choose the Run as Administrator option

Step 2:

Type the below-mentioned command in the PowerShell Script editor:

Set-ExecutionPolicy RemoteSigned

Step 3:

Then type “A” and press enter

Step 4:

Type the following command in the Windows PowerShell Script editor and press enter

C:Userssarang.bhargavaDesktopSample Script.ps1

Cmdlet – An Overview

Once you have assigned the execution policy, you might as well want to try some useful PowerShell Script. Here are some of the important points with regards to cmdlets.

Cmdlets are a combination of a verb and a noun separated by a hyphen (which is also the syntax). When you type verb and place a hyphen ‘-’ after that, you will get options for noun.

Syntax: “verb-noun”. E.g. Get-Certificate

Some of the common types of Cmdlets are

Start: Run a command

Get: Get something out of a command

Stop: To stop command from running

Set: Use to define

New: when you want to create something new

Out: This is used to give an output

There are 3 types of cmdlets



Custom cmdlets

Cmdlets outputs results as an array of objects

Cmdlets are case-insensitive. Which means wither you write Set-Alias or set-alias, it is one in the same thing.

To Sum Up

And, we regularly post interesting concepts pertaining to technology. For more such content, keep reading Tweak Library and don’t forget to subscribe to our YouTube channel.

Quick Reaction:

About the author

Sarang Bhargava

You're reading Basics Of Windows Powershell Script

How To Update Powershell On Windows 11

By default, Windows 11 comes with the latest Powershell 5.1 preinstalled. But you’d be surprised that Microsoft has also released a cross-platform Powershell Core (version 7.x) with extensive features.

Indeed, Powershell is popular among developers, system administrators, and even beginners, thanks to its easy-to-learn lightweight cmdlets. Thus, if you prefer this command-line interface, you’d definitely want to get your hands on its latest version.

Updating or installing the latest Powershell version is relatively easy. You can do it using the MSI package, Zip package, command lines, or even from the Microsoft Store!

Updating or migrating Powershell to 7.x requires manual installation. Once you’ve migrated to the core version, it runs side-by-side with the built-in Windows Powershell.

The open-source software holds features that might be lacking in the 5.1 version, like Automatic Pipeline Parallelization, Null conditional operators, and more. It also supports Docker containers, Defaults to UTF-8 encoding, Powershell Remoting over SSH, etc.

The product works only on those computers running Windows 10 version 17763.0 and higher. So, if you’re running an older Windows generation, it’s only possible to update your Windows Powershell to 5.1.

Now, without further delay, let’s jump into the four different ways to update Powershell on Windows 11.

Microsoft Store is the gateway to installing Windows applications and programs on your computer. Therefore, this platform is the simplest method to get the latest version, 7.3. Kindly follow the below instructions on how to update Powershell from the Microsoft Store:

In the search bar, type Powershell.

Note: Usually, Powershell Core gets updated automatically. If, for some reason, there’s a pending update, you can open the Microsoft Store app and hit the Update button to complete it.

Another way you can update Powershell is by downloading and installing the MSI Package from the official Microsoft website. Go through the following steps to do just that:

Get to the Installing the MSI package section on the website.

You can also install the MSI package or a zip folder from Github. All you have to do is navigate to the Assets section and download the latest version available (7.3.0).

Also, you can directly update or install Powershell Core from the command line interface. This way, you do not have to visit any online page to download the latest version on Windows. Regarding the same, here’s a quick guide that should help you:

In the User Account Control prompt, hit the Yes button.

Again, wait for the installation to complete.

Now, you can open the Run utility and execute the pwsh command to launch the Powershell Core application.

Note: To run Powershell 7.x on Windows Powershell, kindly execute the pwsh cmdlet. To get back to the 5.1 version, simply run the exit command. However, as discussed above, you need to have the version installed on your PC.

One of the easiest ways to launch Windows Powershell is from the Quick Link menu. Simply picking the Windows Terminal would open the utility. 

Certainly, you want the updated version (Powershell Core) to get open instead of the classic Windows Powershell. To make this change, you’re required to make the version 7 interface your default terminal:

Use the Windows + E hotkey to open File Explorer.

15 Mac Terminal Equivalents To Windows Command Prompt And Powershell Commands

In Windows, you can use the Command Prompt and Windows PowerShell consoles for greater control and faster management of the operating system. Both CLIs (command-line interpreters) also help you troubleshoot serious issues with your PC. 

The same goes for the Mac’s Terminal, but its UNIX-based nature requires that you enter a different set of commands.

Table of Contents

If you recently switched to using a Mac, you’ll learn the Terminal equivalents to 15 helpful Command Prompt and Windows PowerShell commands below.

1. View System Information

Suppose you want to identify the various hardware and software components (processor, RAM, operating system version, etc.) on your computer. In that case, you can view the information in Command Prompt or Windows PowerShell with the systeminfo command. 

In Terminal, execute the following instead:


You can also prompt Terminal to filter the information by data type. For example, you can get an overview of Mac’s hardware only by appending SPHardwareDataType to the end of the command—e.g. system_profiler SPHardwareDataType.

For a list of data types, run the system_profiler -listDataTypes command.

2. Ping Devices and Networks 3. Check Network Configurations

The Terminal equivalent opens Interface Configuration and uses the following command:


By default, ifconfig displays active networks only. To make it show all interfaces, run ifconfig -a instead.

4. Flush DNS Cache

An outdated Domain Name System (DNS) cache on your computer causes connectivity issues with websites. In Windows, running the ipconfig /flushdns command via an elevated Command Prompt console helps you clear your computer’s local DNS cache. 

The Terminal equivalent to clearing the DNS cache on Mac is as follows:

sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder

You must enter an administrator password to authorize the command.

5. View All Running Processes

Compared to the Windows Task Manager, typing tasklist into Command Prompt or Windows PowerShell allows for a clearer view of your PC’s background processes. It also contains information such as process IDs (PIDs) and memory usage stats for each task.

On the Mac, you can run one of the two commands below:


ps -ax

The top command displays a list of the most resource-intensive processes in real-time, while ps -ax shows you the complete task list on your Mac.

6. End Process

The Mac’s Terminal equivalent is:

7. Check Network Statistics

The netstat command in Windows lets you view a list of all active TCP connections and helps identify network-related problems. 

On the Mac, running the same command yields similar results:


To view a list of flags and options specific to Terminal, type man netstat.

8. Repair Disk Errors

The Check Disk command-line utility on Windows, which you can invoke by running chkdsk in Command Prompt or Windows PowerShell, allows you to check for and repair disk-related errors.

The Terminal equivalent in macOS is the fsck (file system consistency check) command. Start by booting up your Mac in single-user mode—press Command + S at startup. Then, run the following:

/sbin/fsck -fy

9. Create Symbolic Link

Symbolic links (symlinks) are crucial if you find it impossible to change locations that apps and programs use to store files. 

For example, you can use a symlink to sync any folder to a cloud storage service by making it appear as if it’s inside the default sync directory. On Windows, you use the mklink /J command. 

On macOS, the Terminal equivalent is:

To learn more, check out how symlinks work on the Mac.

10. Schedule Shut Down

On the Mac, use the following command instead:

You can always use the sudo killall shutdown command to cancel a scheduled shutdown.

11. Compare File Differences

On Windows, you can compare the difference between two files using the fc command. 

The Mac’s Terminal equivalent is:


The diff command comes with multiple options. For example, you can use the -i switch to make it ignore case differences in text files. Run man diff to view a complete list of options. 

12. Find Wi-Fi Password

On the Mac, you must run the following command in Terminal:

13. Update Mac

In Windows, you can install operating system updates via Windows PowerShell with the Get-WindowsUpdate and Install-WindowsUpdate commands. It’s faster and less sluggish compared to using the GUI.

The Terminal equivalents to update macOS are:

14. Renew IP Lease

Releasing and renewing the IP (Internet Protocol) lease can fix connectivity-related issues on your computer. That involves running the ipconfig /release and ipconfig /renew commands via Command Prompt in Windows. 

If you don’t know the network interface name, use the ifconfig command to identify it—e.g. en0. 

15. Check Uptime

You can check your PC’s uptime with the (get-date) – (gcim Win32_OperatingSystem).LastBootUpTime Windows PowerShell command.

On the Terminal in macOS, run the following command instead:


The uptime command helps you determine if it’s time to shut down or restart your Mac. That often helps resolve random technical glitches preventing macOS from working correctly.

Switching to Terminal

What Is Computer Networking? Basics, Uses & Components

What is a Computer Network?

A computer network is a group of two or more interconnected computer systems. You can establish a network connection using either cable or wireless media.

Every network involves hardware and software that connects computers and tools.

In this Computer Networking Concepts tutorial, you will learn:

Computer Network Components

Here are essential computer network components:


Switches work as a controller which connects computers, printers, and other hardware devices to a network in a campus or a building.

It allows devices on your network to communicate with each other, as well as with other networks. It helps you to share resources and reduce the costing of any organization.


Routers help you to connect with multiple networks. It enables you to share a single internet connection with multiple devices and saves money. This networking component acts as a dispatcher, which allows you to analyze data sent across a network. It automatically selects the best route for data to travel and send it on its way.


Servers are computers that hold shared programs, files, and the network operating system. Servers allow access to network resources to all the users of the network.


Clients are computer devices which access and uses the network as well as shares network resources. They are also users of the network, as they can send and receive requests from the server.

Transmission Media:

Transmission media is a carrier used to interconnect computers in a network, such as coaxial cable, twisted-pair wire, and optical fiber cable. It is also known as links, channels, or lines.

Access points

Access points allow devices to connect to the wireless network without cables. A wireless network allows you to bring new devices and provides flexible support to mobile users.

Shared Data:

Shared data are data which is shared between the clients such as data files, printer access programs, and email.

Network Interface Card:

Network Interface card sends, receives data, and controls data flow between the computer and the network.

Local Operating System:

A local OS which helps personal computers to access files, print to a local printer and uses one or more disk and CD drives which are located on the computer.

Network Operating System:

The network operating system is a program which runs on computers and servers. It allows the computers to communicate via network.


A protocol is the set of defined rules that allows two entities to communicate across the network. Some standard protocols used for this purpose are IP, TCP, UDP, FTP, etc.


Hub is a device that splits network connection into multiple computers. It acts a distribution center so whenever a computer requests any information from a computer or from the network it sends the request to the hub through a cable. The hub will receive the request and transmit it to the entire network.

LAN Cable:

Local Area Network(LAN) cable is also called as Ethernet or data cable. It is used for connecting a device to the internet.


OSI stands for Open Systems Interconnection. It is a reference model which allows you to specify standards for communications.

Unique Identifiers of Network

Below given are some unique network identifiers:


Every device of the network is associated with a unique device, which is called hostname.

IP Address:

IP (Internet Protocol) address is as a unique identifier for each device on the Internet. Length of the IP address is 32-bits. IPv6 address is 128 bits.

DNS Server:

DNS stands for Domain Name System. It is a server which translates URL or web addresses into their corresponding IP addresses.

MAC Address:

MAC (Media Access Control Address) is known as a physical address is a unique identifier of each host and is associated with the NIC (Network Interface Card). General length of MAC address is : 12-digit/ 6 bytes/ 48 bits


Port is a logical channel which allows network users to send or receive data to an application. Every host can have multiple applications running. Each of these applications are identified using the port number on which they are running.

Other Important Network Components ARP:

ARP stands for Address Resolution Protocol which helps network users to convert the IP address into its corresponding Physical Address.


Reverse Address Resolution Protocol gives an IP address of the device with given a physical address as input.

Uses of Computer Networks

Here are some common application of computer networks

Helps you to share resource such as printers

Allows you to share expensive software’s and database among network participants

Provides fast and effective communication from one computer to another computer

Helps you to exchange data and information among users via a network.

Advantages of Computer Networking

Here are the fundamental benefits/pros of using Computer Networking:

Helps you to connect with multiple computers together to send and receive information when accessing the network.

Helps you to share printers, scanners, and email.

Helps you to share information at very fast speed

Electronic communication is more efficient and less expensive than without the network.

Here are drawbacks/ cons of using computer networks:

Investment for hardware and software can be costly for initial set-up

If you don’t take proper security precautions like file encryption, firewalls then your data will be at risk.

Some components of the network design may not last for many years, and it will become useless or malfunction and need to be replaced.

Requires time for constant administration

Frequent server failure and issues of regular cable faults


A computer network is a group of two or more interconnected computer systems

Computer networks help you to connect with multiple computers together to send and receive information

Switches work as a controller which connects computers, printers, and other hardware devices

Routers help you to connect with multiple networks. It enables you to share a single internet connection and saves money

Servers are computers that hold shared programs, files, and the network operating system

Clients are computer device which accesses and uses the network and shares network resources

Hub is a device that split a network connection into multiple computers.

Access points allow devices to connect to the wireless network without cables

Network Interface card sends, receives data and controls data flow between the computer and the network

A protocol is the set of defined rules which that allows two entities to communicate across the network

Hostname, IP Address, DNS Server, and host are important unique identifiers of computer networks.

ARP stands for Address Resolution Protocol

RAR Reverse Address Resolution Protocol gives an IP address of the device with given a physical address as input.

Computer network helps you to share expensive software’s and database among network participants

The biggest drawback of installing computer network is that its initial investment for hardware and software can be costly for initial set-up

Guide To Substring Method In Powershell

Introduction to PowerShell SubString

One of the most frequently performed operation or requirement with any language is the manipulation of strings. String functions are an integral part of PowerShell and there are various functions present to handle the string manipulation related tasks. In PowerShell, everything is an object and string is also an object of type System. String. A string is nothing, but a collection of characters enclosed within a single quote (‘’) or a double quote (“”). Substring is the part of any string or substring is nothing but a subset of a string. This article will cover in-depth about string in PowerShell, various functions that are available related to string operations, substrings, functions related to substring. The substring () is used to extract a part of a string and it is available for every string object in PowerShell.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Operations available on a string object:

Before looking at the substring(), let’s see the list of operations that are available for any string object.



Some of the most commonly used operations are StartsWith, Remove, Split, Replace, Rim. The following is an example.

Example of PowerShell SubString






.Substring( StartIndex [, length] )

StartIndex: The position of the string from which the substring must be started. Usually, it should be 0 or greater than that and less than the length of the string.

Length: The length of the substring.


Used to fetch a portion of a string.





String concatenation:

In some cases, it is required to combine two strings. That is done with the help of ‘+’ operator.





$string3=$string1 + $string2


In the above code if the variables are swapped before concatenation, then the error will not occur


Write-Host $string3


Other commonly used string functions:


The is another method that can be used to split a string into substrings.


String -Split strSeparator [, MaxSubstrings] [, Options] String -Split {scriptblock} [, MaxSubstrings] -Split String

strSeparator: It is character of identification to split the string

MaxSubstrings: The maximum number of substrings that can be generated







This example will show how to split and generate substring based on regex and to split MAC addresses.



Replace function:

When it comes to string, replacing a part of a string or substring is an integral operation. Always it is required by PowerShell users to find a text and replace it with some other piece of text. This is achieved by the.Replace() method.

Replace(strOldChar, strNewChar)

Stroldchar: Character to be found

Strnewchar: character to be replace the found text.



Write-Host “Text is replaced”



Write-Host “text in the file is replaced”


Comparison of strings:

The final method that we are going to see is the string comparison method. Most cases, it is required to compare strings and check if they are equal. This is done using the string compare method.






Thus, the article covered string operations and substring in detail. It covered in detail the substring method in PowerShell, along with various methods of extracting a substring from a string in different ways. It also covered various string methods like string concatenation, string comparison, string replace, etc. The best way to learn more about this would be to try other various methods and practice them in sample scripts.

Recommended Articles

This is a guide to PowerShell SubString. Here we discuss the Introduction, list of operations, and examples with code implementation respectively. You may also have a look at the following articles to learn more –

How To Get Environment Variable Value Using Powershell?

Environment variables are an essential part of the Operating System. They store various information like the path of the system files and folders, the number of processors system running, current user details, and more. Processes and programs utilize these environment variables to retrieve the data for their execution.

Environment variables in PowerShell are stored as PS drive (Env: ). To retrieve all the environment variables stored in the OS you can use the below command.

Get-ChildItem -Path Env: Name                        Value ----                        ----- ALLUSERSPROFILE             C:ProgramData APPDATA                     C:UsersdeltaAppDataRoaming CommonProgramFiles          C:Program FilesCommon Files CommonProgramFiles(x86)     C:Program Files (x86)Common Files CommonProgramW6432          C:Program FilesCommon Files COMPUTERNAME                TEST1-WIN2K12 ComSpec                     C:Windowssystem32cmd.exe FP_NO_HOST_CHECK            NO HOMEDRIVE                   C: HOMEPATH                    Usersdelta LOCALAPPDATA                C:UsersdeltaAppDataLocal LOGONSERVER                 ADDC NUMBER_OF_PROCESSORS        1 OS                          Windows_NT Path                        C:Windowssystem32;C:Windows;C:WindowsSystem32 Wbem PATHEXT                    .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;. MSC;. PROCESSOR_ARCHITECTURE     AMD64 Name Value ---- ----- SystemDrive C:

If there are multiple values displayed for the environment variable then you can separate values using Split operation. For example,

$env:PSModulePath -split ';' Output: C:UsersdeltaDocumentsWindowsPowerShellModules C:Program FilesWindowsPowerShellModules C:Windowssystem32WindowsPowerShellv1.0Modules

You can also use the .NET method of class [System.Environment] to retrieve the specific or all Name Value —- —– COMPUTERNAME TEST1-WIN2K12 USERPROFILE C:Usersdelta HOMEPATH Usersdelta LOCALAPPDATA C:UsersdeltaAppDataLocal PSModulePath C:UsersdeltaDocumentsWindowsPowerShellModules PROCESSOR_ARCHITECTURE AMD64 Path C:Windowssystem32;C:Windows;C:WindowsSystem32 Wbem CommonProgramFiles(x86) C:Program Files (x86)Common Files ProgramFiles(x86) C:Program Files (x86) PROCESSOR_LEVEL 6 LOGONSERVER ADDC PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;. v1.0Modules

Update the detailed information about Basics Of Windows Powershell Script on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!