Some useful commands with powershell

Every now and then I come to some commands that I always forget, therefor I created a page under my blog as a reference.

netstat -aon | ? { $_.Contains('5108') }
netstat -ban

Renaming all files of a directory according to a pattern.

 $prefix = "e"
$extension = ".txt"
$path = "C:\temp\TestFiles"
$i = 1
Get-ChildItem -Path $path -Filter "*$extension" |
 %{
 Rename-Item -Path $_.FullName -NewName (($prefix + $i++) + $extension) -Force
 }
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s