Skip to main content


Showing posts from 2016

How to customize the Powershell Prompt

By default when you open up Powershell console, you will get a screen as shown below :

so today we are going to learn how to replace the PS C:\windows\system32> with any thing lets say I ♥ PowerShell. So lets learn how to do it.

STEP 1 : 

We are going to modify the Powershell Profile for this. So open PowerShell as Administrator & give the below command : 

Test-Path $Profile

If it return True that means Powershell profile is created, if it's False then create the powershell profile by executing the below comand : 
New-Item -Path $PROFILE -Type File -Force
STEP 2 :
Since the Profile is now created, now open the profile in Notepad i.e. 
notepad $Profile
STEP 3 :
Now Copy-Paste the below function in that file and Save it.

You can the change the content as per your choice.

If any message or warning comes then change the encoding type while saving (Since I am using a Heart Shape by default ANSI Encoding will not support it.) 

Once Saved now close the Powershell console and Open it again…

How to Zip and UnZip files using PowerShell

Today we are going to Learn all about Compressing and Decompressing a file using Powershell. So lets get started.

Powershell 5.0 have lots of features added to its feather. One of them is Zipping and Unzipping . Powershell 5.0 contains 2 functions by default for Zipping and Unzipping a file i.e.Compress-ArchiveandExpand-Archive

Syntax :

Zip:Compress-Archive -path <Source_File_Path> -DestinationPath <Destination_File>

Unzip: Expand-Archive -path <Zip_file_path_to_Extract> -DestinationPath <Destination_path_where_to_Extract>

>_ If you are using Powershell version below 5.0 then you can achieve the same by Calling a Class.


Add-Type -Assembly "System.IO.Compression.FileSystem" ;
[System.IO.Compression.ZipFile]::CreateFromDirectory("E:\The Powershell Geek", "E:\")


Add-Type -Assembly "System.IO.Compression.FileSystem"
[System.IO.Compression.ZipFile]::ExtractToDirectory("E:\", &q…

Execution Policy in Powershell

Execution Policy in Powershell

Execution Policy in Powershell helps to determine the type of scripts that can run on a particular system. 

There are different types of Execution Policy in Powershell :


It is the default execution policy in Powershell. It means it doesn't allow any Powershell script(*.ps1) to execute by default. In order to provide security, Microsoft suggests Restricted policy by default so that none of malicious code can be executed by double clicking or running it. 

All the Scripts should have a digital signature from a trusted publisher, then only you will be able to execute the Script else Script will not be executed. This is applicable for the local scripts also which you write of your own, you will need to assign a certificate to it example Self Signed Certificate. 3. REMOTE SIGNED

Local script files doesn't need any signature( they can be executed) but scripts downloaded from any internet source will require Signature from a Tru…