When you are working in the operating system, there may be instances where you need to copy or move files and folders around on the operating system. PowerShell provides two cmdlets to copy and move files. The copy-item
cmdlet allows you to copy a file or a folder from one location to another. The proper syntax of this cmdlet is calling copy-item
, followed by –path
argument for the source you want to copy and the –destination
argument for the destination of the file or folder. The copy-item
cmdlet also has the –force
argument to write over a read-only or hidden file. There are instances when read-only files cannot be overwritten, such as a lack of user permissions, which will require additional code to change the file attributes before copying over files or folders. The copy-item
cmdlet also has a –recurse
argument, which allows you to recursively copy the files in a folder and its subdirectories.
Mastering Windows PowerShell Scripting
By :
Mastering Windows PowerShell Scripting
By:
Overview of this book
Table of Contents (22 chapters)
Mastering Windows PowerShell Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Variables, Arrays, and Hashes
Data Parsing and Manipulation
Comparison Operators
Functions, Switches, and Loops Structures
Regular Expressions
Error and Exception Handling and Testing Code
Session-based Remote Management
Managing Files, Folders, and Registry Items
File, Folder, and Registry Attributes, ACLs, and Properties
Windows Management Instrumentation
XML Manipulation
Managing Microsoft Systems with PowerShell
Automation of the Environment
Script Creation Best Practices and Conclusion
Index
Customer Reviews