PowerShell Management Series (38) PowerShell operation file Lookup and operation

Source: Internet
Author: User

-----provide ad\exchange\lync\sharepoint\crm\sc\o365 and other Microsoft product implementation and outsourcing, qq:185426445. Phone 18666943750

Requirements One, create a folder

Step 1, we create a folder on the desktop test01, the steps are as follows:

New-item C:\Users\Terry.zhou\Desktop\test01-type Directory

The following error occurred:

650) this.width=650; "Width=" 501 "height=" 382 "title=" QQ picture 20161204232715.png "style=" width:731px;height:450px; "src= "Http://s4.51cto.com/wyfs02/M02/8B/14/wKioL1hENebT7c3NAACQJk-4p2M384.png-wh_500x0-wm_3-wmp_4-s_1306512714.png" alt= "Wkiol1henebt7c3naacqjk-4p2m384.png-wh_50"/>

Step 2, this reason is because we already have the same name folder on the desktop, we can run the following command, if there is a folder with the same name to catch the exception

Try{new-item C:\Users\Terry.zhou\Desktop\test01-type directory-erroraction stop}catch{# "test01 folder already exists and does not need to be created" Write-warning "Error: $_"}

650) this.width=650; "Width=" 501 "height=" 385 "title=" QQ picture 20161204232715.png "style=" width:733px;height:435px; "src= "Http://s2.51cto.com/wyfs02/M00/8B/14/wKioL1hENzCB2UBtAAEIzc1EYL0071.png-wh_500x0-wm_3-wmp_4-s_125203371.png" alt= "Wkiol1henzcb2ubtaaeizc1eyl0071.png-wh_50"/>

2. Move files with the word "copy" inside the test folder to the test01 folder

Try{new-item C:\Users\Terry.zhou\Desktop\test01-type directory-erroraction stop}catch{# "test01 folder already exists and does not need to be created" Write-warning "Error: $_"}get-childitem C:\Users\Terry.zhou\Desktop\test-Recurse |? {$_.name-like "* copy. *"} | Move-item-destination "C:\Users\Terry.zhou\Desktop\test01"

650) this.width=650; "Width=" 501 "height=" 355 "title=" QQ picture 20161205001538.png "style=" width:731px;height:392px; "src= "Http://s2.51cto.com/wyfs02/M01/8B/18/wKiom1hEQTrjSvCkAAEuQWqSHH8723.png-wh_500x0-wm_3-wmp_4-s_2917734174.png" alt= "Wkiom1heqtrjsvckaaeuqwqshh8723.png-wh_50"/>

This article is from the "Zhou Ping Microsoft Technology Exchange Platform" blog, please be sure to keep this source http://yuntcloud.blog.51cto.com/1173839/1879445

PowerShell Management Series (38) PowerShell operation file Lookup and operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.