创建文件
New-Item -path $file_path -itemtype file
创建目录
New-Item -path $dir_path -type directory
删除目录
Remove-Item-Force-Recurse $dir
赋予权限
$account ="Business"
$Folder = D:WebSite
$FileSystemRights ="FullControl"
$objType =[System.Security.AccessControl.AccessControlType]::Allow
$accessRule =New-ObjectSystem.Security.AccessControl.FileSystemAccessRule($account,$FileSystemRights,$objType)
$acl =Get-Acl $Folder
$acl.SetAccessRule($accessRule)
Set-Acl-Path $Folder -AclObject $acl
访问共享文件夹
$user ="admin"
$passwd ="123456"
net use $dir $passwd /user:$user
复制文件
$files =Get-ChildItem-Path $RemotePath -Force
foreach($file in $files){
Copy-Item-Path $file.FullName-Destination $LocalPath -Recurse-Force
}