Thursday, May 12, 2016

PowerShell cmdlet of the Day : Test-Path

 

Believe me or not! you are going to use this cmdlet in almost all of your scripts.

By using Test-Path cmdlets, we can find if specific file / folder exists or now. If the file/folder does exists then the output is True, and if they don't then the output is False.

The basic usage of the cmdlet is simple, type the Test-Path cmdlet and in -Path parameter provide the name of file/folder which you want to test.

Test-Path -Path C:\temp\ad.txt

444

In above screenshot, the folder and file both exists, so the output of command in True.

555

In the above screenshot, neither the folder and file exists, so the output of command is false.

Cool! no :)

With Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel
for PowerShell video tutorials. You can download all of my scripts from “Microsoft
TechNet Gallery”.

 

Wednesday, May 11, 2016

PowerShell cmdlet of the Day : Test-Connection


Ping! I can bet, that you use this command almost daily. We use Ping.exe to test networking by pinging IP Addresses or hostnames. If the reply comes then we know networking is working fine and if we get RTO's , then we know, networking is not working.

In PowerShell we have a cmdlet Test-Connection which does the same.

The usage is simple, type the Cmdlet Test-Connection and in -Count parameter provide the numbers of Pings you want to send.

Test-Connection 8.8.8.8 -Count 3

1
Cool!

Actually the most cool thing is , this cmdlet's -Quiet switch parameter.

When we provide the -Quiet parameter, the output comes in True or False ( Awesome!!!). If your  IP/Host is reachable , then the output result will be True, otherwise it will be False.  This comes quite handy when you need to do some network availability checks in to your script.

:)

With Regards.
Aman Dhally

If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel
for PowerShell video tutorials. You can download all of my scripts from “Microsoft
TechNet Gallery

Tuesday, May 10, 2016

PowerShell cmdlet of the Day : Start-Sleep


Sometime, the more we move ahead, the more we start forgetting the basic things. It's in human nature I think or may be in mine :P .
Today when I was working on a PowerShell script, I come along with a cmdlet which I have used a lot in my early scripts.
The forgot cmdlet is "Start-Sleep".
It's hold the script activity for the period defined in it and it move to next line in the script after the define time in lapsed. For example if you set the Start-Sleep -Seconds 10, then it moved to next line after 10 seconds only.
Aman Dhally , Manya Kaur
The usage is simple., type Start-Sleep and then either use -seconds or -Milliseconds parameter and provide the value in number.

Simple, isn't :)

With Regards.
Aman Dhally
If you like, you can follow me on Twitter and Facebook. You can also check my “You Tube channel for PowerShell video tutorials. You can download all of my scripts from “Microsoft TechNet Gallery”.