Difference between revisions of "Working with File Systems in Windows PowerShell 1.0"

From Techotopia
Jump to: navigation, search
(Windows PowerShell File System Cmdlets)
(Windows PowerShell File System Cmdlets)
Line 13: Line 13:
 
* '''UNIX/Linux sh command''' The UNIX/Linux shell equivalent command to help user migrate skills to Windows PowerShell.
 
* '''UNIX/Linux sh command''' The UNIX/Linux shell equivalent command to help user migrate skills to Windows PowerShell.
  
The following table lists the key file system related cmdlets together with the various alternate methods of accessing each one:
+
The following table lists the key file system related cmdlets together with the alias. cmd and Unix shell alternatives:
  
 
<table border="1" cellpadding="5" cellspacing="0" id="E3B" style="border-collapse: collapse; border-color:#cccccc; border-style: solid; border-width: 1px; margin-bottom:20px">
 
<table border="1" cellpadding="5" cellspacing="0" id="E3B" style="border-collapse: collapse; border-color:#cccccc; border-style: solid; border-width: 1px; margin-bottom:20px">

Revision as of 16:00, 5 December 2008

Given that Windows PowerShell is primarily targeted at easing the job of system administrators there is a good chance that part of developing scripts is going to involve interacting with Windows files and file systems. This chapter will focus on working with file systems with Windows PowerShell, while the next chapter, entitled Working with Files in Windows PowerShell, will cover working with the contents of individual files.

Windows PowerShell File System Cmdlets

Windows PowerShell provides a collection of cmdlets specifically for the purposes of interacting with file systems. Each command is accessible in a number of different ways:

  • Cmdlet name - The standard cmdlet name, such as Get-Location.
  • Alias - An preconfigured, abbreviated alias for the cmdlet name such as gl for Get-Location.
  • cmd.exe command - The cmd.exe equivalent command to help users familiar with the Windows Command Prompt migrate to PowerShell.
  • UNIX/Linux sh command The UNIX/Linux shell equivalent command to help user migrate skills to Windows PowerShell.

The following table lists the key file system related cmdlets together with the alias. cmd and Unix shell alternatives:

Cmdlet Name

Alias

Cmd Command

UNIX sh Command

Description

Clear-Item cli N/A N/A Clears content of a file
Copy-Item cpi copy cp Copies file or folder
Get-Content gc type cat Gets the content of a file
Get-Location gl cd pwd Gets the current directory
Move-Item mi move mv Moves file or folder
New-Item ni, md N/A N/A Creates file or folder
Remove-Item ri del, rd rm, rmdir Deletes file or folder
Rename-Item rni, rn ren mv Renames file or folder
Set-Content sc N/A N/A Sets file content
Set-Item si N/A N/A Sets file content
Set-Location sl cd, chdir cd, chdir Sets current directory