Understanding Windows PowerShell


Perhaps the biggest obstacle for a Windows network administrator in migrating to Windows PowerShell is understanding what the PowerShell actually is. In some respects, it is like a replacement for the venerable CMD (command) shell. As shown here, after the Windows PowerShell is launched, you can use cd to change the working directory, and then use dir to produce a directory listing in exactly the same way you would perform these tasks from the CMD shell.

 Windows PowerShell  Copyright (C) 2006 Microsoft Corporation. All rights reserved.    PS C:\Documents and Settings\edwilson> cd c:\  PS C:\> dir        Directory: Microsoft.PowerShell.Core\FileSystem::C:\    Mode                LastWriteTime     Length Name  ----                -------------     ------ ----  d----          7/2/2006  12:14 PM            audioBOOK  d----         1/13/2006   9:34 AM            bt  d----         11/4/2006   2:57 AM            Documents and Settings  d----          2/6/2006   2:49 PM            DsoFile  d----          9/5/2006  11:30 AM            fso  d----         7/21/2006   3:08 AM            fso2  d----        11/15/2006   9:57 AM            OutlookMail  d-r--        11/20/2006   4:44 PM            Program Files  d----         7/16/2005  11:52 AM            RAS  d----         1/30/2006   9:30 AM            smartPhone  d----         11/1/2006  11:35 PM            Temp  d----         8/31/2006   6:48 AM            Utils  d----         1/30/2006   9:10 AM            vb05sbs  d----        11/21/2006   5:36 PM            WINDOWS  -a---         7/16/2005  10:39 AM          0 AUTOEXEC.BAT  -a---         11/7/2006   1:09 PM       3988 bar.emf  --r-s         8/27/2006   6:37 PM        211 boot.ini  -a---         7/16/2005  10:39 AM          0 CONFIG.SYS  -a---         8/16/2006  11:42 AM         60 MASK.txt  -a---          4/5/2006   3:09 AM        288 MRED1.log  -a---         9/28/2006  11:20 PM      16384 mySheet.xls  -a---         9/19/2006   4:28 AM       2974 new.txt  -a---        11/15/2006   2:08 PM       6662 notepad  -a---         9/19/2006   4:23 AM       4887 old.txt  -a---          6/3/2006  11:11 AM        102 Platform.ini    PS C:\> 

You can also combine “traditional” CMD interpreter commands with some of the newer utilities such as fsutil. This is shown here:

 PS C:\> md c:\test     Directory: Microsoft.PowerShell.Core\FileSystem::C:\ Mode                LastWriteTime     Length Name ----                -------------     ------ ---- d----        11/23/2006  11:42 AM            test PS C:\> cd c:\test PS C:\test> fsutil file createNew c:\test\myNewFile.txt 1000 File c:\test\myNewFile.txt is created PS C:\test> dir     Directory: Microsoft.PowerShell.Core\FileSystem::C:\test Mode                LastWriteTime     Length Name ----                -------------     ------ ---- -a---        11/23/2006  11:43 AM       1000 myNewFile.txt PS C:\test> del *.txt PS C:\test> cd c:\ PS C:\> rd c:\test PS C:\>

We have been using Windows PowerShell in an interactive manner. This is one of the primary uses of PowerShell and is accomplished by opening a PowerShell prompt and typing commands. The commands can be entered one at a time, or they can be grouped together like a batch file. We will look at this later because you need more information to understand it.




Microsoft Press - Microsoft Windows PowerShell Step by Step
MicrosoftВ® Windows PowerShell(TM) Step By Step (Step By Step (Microsoft))
ISBN: 0735623953
EAN: 2147483647
Year: 2007
Pages: 128
Authors: Ed Wilson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net