sakko51150 发表于 2018-9-1 11:55:27

PowerShell 修复 Robocopy的权限问题

$a = Get-Content "C:\temp\list.txt"  
#For each folder and subfolders, setup the ownership and NTFS permissions
  
foreach ($i in $a)
  
{
  
    if(test-path $i)
  
{
  
      write-host Taking ownership of Directory $i -fore Green
  
      get-item $i | Set-NTFSOwner -Account 'omnicom\group Australia it access'
  
      get-item $i | add-ntfsaccess -account 'omnicom\group Australia it access' -Acce***ights FullControl
  
      get-item $i | Add-NTFSAccess -Account 'omnicom\sydney track all staff' -Acce***ights modify
  

  
      $items = @()
  
      $items = $null
  
      $path = $null
  
      #if need to setup all subfolders, we can use -recusrse in the following cmdlet.
  
      $items = get-childitem $i -force
  
      foreach($item in $items)
  
            {
  
                $path = $item.FullName
  
                Write-Host ...Adding AdminGroup to $path -Fore Green
  
                Get-Item -force $path | Set-NTFSOwner -Account 'omnicom\group Australia it access'
  
                get-item $item | Add-NTFSAccess -account 'omnicom\group Australia it access' -Acce***ights FullControl
  
                get-item $item | Add-NTFSAccess -Account 'omnicom\sydney track all staff' -Acce***ights modify
  
            }
  
   }
  
}


页: [1]
查看完整版本: PowerShell 修复 Robocopy的权限问题