Answer the question
In order to leave comments, you need to log in
What's wrong with rights?
Good morning!
I am writing this simple code. Task: create a test.txt file in each D:\testfolder (it contains three baseX folders)
$test = Get-ChildItem D:\testfolder -Recurse | Where-Object {Test-Path $_.FullName -PathType container}
Foreach ($dir in $test)
{
New-Item -Value test.txt -Path $dir.FullName -ItemType file
}
New-Item : Отказано в доступе по пути "D:\testfolder\base1".
строка:7 знак:9
+ New-Item -Value test.txt -Path $dir.FullName -ItemType file
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (D:\testfolder\base1:String) [New-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : NewItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question