Я пытаюсь заархивировать некоторые старые папки из нашей общей папки в общую, но при запуске скрипта я получил следующую ошибку:
Get-Acl : Cannot validate argument on parameter 'Path'
PS C:\> C:\movefiles.ps1
112256
Get-Acl : Cannot validate argument on parameter 'Path'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\movefiles.ps1:15 char:19
+ $get_acl = Get-Acl <<<< $files.FullName | ft $files.FullName | out-file $logfile -append
+ CategoryInfo : InvalidData: (:) [Get-Acl], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetAclCommand
Copy-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\movefiles.ps1:18 char:25
+ $Files = Copy-Item -Path <<<< $files -Recurse -Destination $new_document_share -force
+ CategoryInfo : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CopyItemCommand
Сценарий, который я строю:
$logfile = �C:\Scriptlog\logs.txt
$old_document_share = \\server\sharedfolder
$new_document_share = \\server\archive\2019
$date_time = Get-Date -Format g
$names_account = (Get-Content C:\orderstomove.csv) -split �,�
foreach ($account_name in $names_account)
{
# copy foldersmatchthat match account name
write-host $account_name
$files = Get-ChildItem $old_document_share\* | Where-Object{($_.psiscontainer -eq $true) -and ($_.name.Contains($account_name))}
foreach ($files in $folders)
{
write-host $files
$get_acl = Get-Acl $files.FullName | ft $files.FullName | out-file $logfile -append
$output_details = $date_time | out-file $logfile -append
#copy with folder structure
$Files = Copy-Item -Path $files -Recurse -Destination $new_document_share -force
}
}