Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Friday, January 3, 2014

Powershell commands

This post i am documenting some of powershell quick reference scripts

Get Members of a command
c:> get-service | gm

Get-help CMD-NAME
Example:
c:> get-help start-service

Get-process -name "Name"
Example
c:> get-process -name "outlook"

Get Process - physical directory path
PS C:\Windows\system32> get-process outlook | dir

Directory: C:\Program Files (x86)\Microsoft Office\Office14

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         3/31/2011   4:08 PM   15933792 OUTLOOK.EXE

c:> get-service -filter * | select -Property name, @{name='ComputerName',expression={$_.name}_

Monday, September 17, 2012

PowerShell - Get List of files in a Folder path recursively and export to CSV file the output



In this blog post i will discuss document some PowerShell scripts that will help you
  1. Get List of files in a Folder path recursively and export to a CSV file the output with the files meta data information like ( Directory, Name, Length, CreationTime, LastWriteTime, LastAccessTime, FullName, Extension )
  2. Get Distinct COUNT of File extensions inside a folder path recursively.

Get List of files recursively and export to a CSV file with the files meta data information

Open PowerShell
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

Get-Childitem "C:\Bharath\Files" -Recurse | where { -not $_.PSIsContainer } | Select Directory, Name, Length, CreationTime, LastWriteTime, LastAccessTime, FullName, Extension | Export-Csv "C:\Users\E317351\Desktop\FileswithSize.txt"


Get Distinct COUNT of File extensions inside a folder path recursively.

Open PowerShell
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

Get-Childitem "C:\Bharath\Desktop\Some Folders" -Recurse | where { -not $_.PSIsContainer } | group Extension -NoElement | sort count -desc

Exclude some folder (use -exclude) parameter as below

Get-Childitem "C:\Bharath\Desktop\Some Folders" -exclude TestFolderName -Recurse | where { -not $_.PSIsContainer } | group Extension -NoElement | sort count -desc