首页 > 系统服务 > 详细

powershell常用操作

时间:2015-08-20 12:47:15      阅读:282      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!