A blog by Jose Barreto, a member of the File Server team at Microsoft.
All messages posted to this blog are provided "AS IS" with no warranties, and confer no rights.
Information on unreleased products are subject to change without notice.
Dates related to unreleased products are estimates and are subject to change without notice.
The content of this site are personal opinions and might not represent the Microsoft Corporation view.
The information contained in this blog represents my view on the issues discussed as of the date of publication.
You should not consider older, out-of-date posts to reflect my current thoughts and opinions.
© Copyright 2004-2012 by Jose Barreto. All rights reserved.
Follow @josebarreto on Twitter for updates on new blog posts.
Powershell is a command line interface for Windows that offers a very powerful and flexible model.It is now a feature included with Windows 7 and Windows Server 2008 R2, not an optional download as before.In this post, I show some sample commands that can help you understand some of the basic features and a few more complex ones.
If you never played with it before, try running Get-Help and Get-Command in a PowerShell prompt.
Let's use the Dir command now (actually an alias for Get-ChildItem) and a number of ways to transform the output using pipeline functions:
Now exploring other “drives” in PowerShell with Get-PSDrive, including the certificate store and the registry.
Another easy way to get interesting data is with Get-Process.
Combining PowerShell with WMI is also very interesting. You can leverage any WMI provider on the box using Get-WmiObject.You can get a list of WMI Classes from http://msdn.microsoft.com/en-us/library/aa394554(VS.85).aspx
PowerShell also lets you call the .NET Framework, which is a huge library.You need to use a syntax where the full class name (library.class) is mentioned in , followed by a :: and the method name.
You can find a reference for it at http://msdn.microsoft.com/en-us/library/ms229335.aspx
It’s also interesting to iterate through the list of resulting objects, to perform additional actions.You use the ForEach keyword (actually an alias for ForEach-Object), which allows you to run something for each item. The item is referred to as $_.You can also use the symbol % instead of ForEach-Object.
A similar syntax is used for Where (actually an alias for Where-Object), which can be used to filter objects in the pipeline.You can also use the symbol ? instead of Where-Object.
Now let's focus on the DFS Namespaces service, which is something I’m working on (these will only work if the box is a Windows Server file server with the DFS-N role service installed):
I hope that has helped you see how interesting PowerShell can be. Here are a few links for additional information and tutorials: