I am trying to change access permissions for a list of files (recursively):
$global:unc = "\\.\" # unc-format
$files = Get-ChildItem c:\Users\loli\test\ -Filter *.txt -Recurse -Force |
% { $_.FullName }
$username = Read-Host
giveAccess $files $username
function giveAccess ( $files, $username ) {
foreach ( $file in $files) {
icacls ($unc+$dat) /grant $username:F
}
}
Unfortunatelly, I get the error:
icacls : Ungültiger Parameter: "/grant"
In Zeile:9 Zeichen:13
+ icacls ($unc+$dat) /grant $username:F
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Ungültiger Parameter: "/grant":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Apparently it's complaining about the string of $username, but I don't know how I could change it.