码迷,mamicode.com
首页 > 系统相关 > 详细

powershell常用操作

时间:2015-08-20 12:48:42      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

创建文件
  1. New-Item -path $file_path -itemtype file
创建目录
  1. New-Item -path $dir_path -type directory

删除目录

  1. Remove-Item-Force-Recurse $dir
赋予权限
  1. $account ="Business"
  2. $Folder = D:\WebSite
  3. $FileSystemRights ="FullControl"
  4. $objType =[System.Security.AccessControl.AccessControlType]::Allow
  5. $accessRule =New-ObjectSystem.Security.AccessControl.FileSystemAccessRule($account,$FileSystemRights,$objType)
  6. $acl =Get-Acl $Folder
  7. $acl.SetAccessRule($accessRule)
  8. Set-Acl-Path $Folder -AclObject $acl
访问共享文件夹
  1. $user ="admin"
  2. $passwd ="123456"
  3. net use $dir $passwd /user:$user
复制文件
  1. $files =Get-ChildItem-Path $RemotePath -Force
  2. foreach($file in $files){
  3. Copy-Item-Path $file.FullName-Destination $LocalPath -Recurse-Force
  4. }

 

powershell常用操作

标签:

原文地址:http://www.cnblogs.com/letong/p/4744348.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!