Posts

Showing posts from May, 2017

DAY-7: POWERSHELL OBJECT'S

Image
Sorting Objects Most PowerShell Cmdlets produce objects in a deterministic fashion, which means that they tend to produce objects in the same order every time you run the command. Both service and process, for example, are listed in alphabetical order by name. What if we want to change that. For example, we want to display a list of processes, which is the biggest consumers of Virtual Memory (VM) at the top of the list. For this, we need to re-order that list of objects based on VM property. PowerShell provides a simple Cmdlet, Sort-Object, which does exactly that: Get-Process | Sort-Object -property VM We're hoping that you'll follow this blog and try to run all the given commands to test it yourself. That command isn't exactly what we wanted. It did a sort on VM, but it did so in ascending order, with the largest values at the bottom of the list. By reading help for the sort-object, we see that it has a -descending parameter

DAY-6: OBJECT'S IN POWERSHELL

Image
Objects: Data By Another Name Use of Objects in PowerShell sometimes can be one of the most confusing elements but at the same time, it's the also one of the most critical concepts, affecting everything you do in the shell. What are the Objects? Run a command Get-Process in PowerShell. You Should see a table with several columns, but those columns barely have the complete information about the processes. Each process object also has a machine name, main window handle, maximum working set, exit code and time, and a great deal of information. In fact, you'll find more than 60 pieces of information associated with a process. Now the question is, why did PowerShell show so few of them? The simple fact is that most of the things PowerShell can access offer more information than what will comfortably fit on the screen. When you run a command, such as Get-Process, Get-Service, or anything, PowerShell constructs a table containing all the inf

Day-5: PowerShell Modules & PSSnapin

Image
Introduction One of the PowerShell's primary Strengths is its extensibility. As Microsoft continues to invest in PowerShell, it develops more and more commands for products like Exchange, SharePoint Server, System Center Family, SQL Server and so on. Typically when you install these product's Management tools, you also get a graphical management console of some kind and one or more extensions for Windows PowerShell. How IT Works You all are familiar with the graphical Microsoft Management Console (MMC), same management team within Microsoft develops both the MMC and PowerShell Modules (or Snap-in) for particular MMC. When you open a new, blank MMC console you add Snap-in like DNS, Active Directory Users and Computer.    PowerShell works in almost exactly the same way. Install the management tools for a given product, doing so will give you any related PowerShell extensions, and it may even create a product specific management she. These Product s

DAY-4: PowerShell Pipeline and Exporting Data

Image
Pipeline - Connecting commands   PowerShell connects commands to each other using something called a Pipeline. The pipeline provides a way for one command to pass, or pipe, its output to another command, allowing that second command to have something to work with. The concept of joining commands is not limited to PowerShell, but PowerShell takes the same piping to a greater extend for better effect.  Exporting Output to Files 1. Get-Process 2. Get-service When we run above commands, a table with several columns of information appears on the screen.  It's great to have information on the screen, but that isn't all you might want to do with the information. For example, if you want to export the information into a CSV file that could be read into an application like Microsoft excel.  Exporting to CSV Exporting to a file is where the pipeline and a second command come in handy. Get-Process | Export-csv C:\procs.csv We

DAY-3: Running PowerShell Cmdlets

Image
PowerShell: Running Commands Powershell, as its name implies, is a shell. It's similar to Cmd.exe command line that you probably used previously. It also has a strong resemblance to the Unix shells, like Bash or even original Unix Bourne shell. Only the difference come with PowerShell commands with all the other shells is that PowerShell has a unique Anatomy of the Cmdlets structure, which is missing in other shells.This structure is very easy to understand and make use while running Cmdlets. Now I will make you understand the anatomy of the Cmdlets in PowerShell. The Anatomy of PowerShell Command The figure shows the basic anatomy of a complex PowerShell command. I have tried to use a complex command so that you can all of the different things that might show up. Now we will tell you all few rules for writing PowerShell commands. 1. Cmdlets Naming Convention - Microsoft has established a naming convention for Cmdlets. The rule is this: Names start with a

DAY-2 : PowerShell Help and Parameter Set

Image
                                                                                                 Author - Ankit Sharma Exploring PowerShell Help Files We work in an industry that doesn’t place a lot of emphasis on reading. Most of the administrators tend to dive right in, relying on things like tooltips, context menus, inbuild instruction, and so forth those GUI discoverability tools—to figure out how to do something. But let’s be clear about one thing: If you aren’t willing to read PowerShell’s help files, you won’t be effective with it.  Updating PowerShell Help On regular basis, Microsoft keeps updating the help files for PowerShell on the internet. By Running a simple command we can update the Help files on our system. Updating help files should be your first task. These files are stored in the System32 directory, which means your shell must be running under elevated privileges Demo video: How to Update Help Files  USING POWE

DAY-1 : POWERSHELL…WHAT IT IS>>>AND WHY

Image
    POWERSHELL …WHAT IT IS>>>AND WHY                                                                                                                                                                                                                                        ANKIT SHARMA For normal computer users it is a useless…..but listen, for an IT administrators it is a great standard command-line interface to help you out with the time management, new learning, automation tool for doing your manual task in automated way and end of the day it gives you time for more coffee breaks in office 😊. As a Windows and VMware Admin myself, I am in love with this. From last 2 years I am learning it and still the process is going on. Every time when I think it is all that this thing can do, then on next day they open up new ocean of possibilities and again this make me learn it more. So there is no ending to what we can achieve with this thing. Now by taking a technical ex