Exploring Commands: Step-by-Step Exercises


In this exercise, we explore the use of command-line utilities in Windows PowerShell. You will see that it is as easy to use command-line utilities in the Windows PowerShell as in the CMD interpreter; however, by using such commands in the Windows PowerShell, you gain access to new levels of functionality.

  1. Start Windows PowerShell by using Start | Run | Windows PowerShell. The PowerShell prompt will open by default at the root of your Documents And Settings.

  2. Change to the C:\ root directory by typing cd C:\ inside the PowerShell prompt:

     Cd c:\

  3. Obtain a listing of all the files in the C:\ root directory by using the dir command:

     dir

  4. Create a directory off the C:\ root directory by using the md command:

     Md mytest

  5. Obtain a listing of all files and folders off the root that begin with the letter m:

     Dir m*

  6. Change the working directory to the PowerShell working directory. You can do this by using the Set-Location command as follows:

     Set-location $pshome

  7. Obtain a listing of memory counters related to the available bytes by using the typeperf command. This command is shown here:

     typeperf "\memory\available bytes"

  8. After a few counters have been displayed in the PowerShell window, use the ctrl-c command to break the listing.

  9. Display the current boot configuration by using the bootcfg command:

     Bootcfg

  10. Change the working directory back to the C:\Mytest directory you created earlier:

     set-location c:\mytest

  11. Create a file named Mytestfile.txt in the C:\Mytest directory. Use the fsutil utility, and make the file 1,000 bytes in size. To do this, use the following command:

     fsutil file createnew mytestfile.txt 1000

  12. Obtain a “directory listing” of all the files in the C:\Mytest directory by using the Get-ChildItem cmdlet. This is shown here:

     get-childitem

  13. Print out the current date by using the Get-Date cmdlet. This is shown here:

     get-date

  14. Clear the screen by using the cls command. This is shown here:

     cls

  15. Print out a listing of all the cmdlets built into Windows PowerShell. To do this, use the Get-Command cmdlet. This is shown here:

     get-command

  16. Use the Get-Command cmdlet to get the Get-Alias cmdlet. To do this, use the -name argument while supplying Get-Alias as the value for the argument. This is shown here:

     get-command -name get-alias

  17. This concludes the step-by-step exercise. Exit the Windows PowerShell by typing exit and pressing Enter.




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