خرید بک لینک

Vote count: 0

I am getting "Get-ChildItem : A parameter caot be found that matches parameter name 'Directory'" error message , below is the script used, kindly help me in finding the issue?

Script:


Function Clear-ReadOnlyFiles([string]$path)
{
  "Clearing readonly attribute from files in $path"
 New-Variable -Name read_only -Value 1 -Option readonly
 Get-ChildItem -Path $path |
 Where-Object { $_.attributes -match 'readonly' } |
 ForEach-Object {
   $_.attributes = $_.attributes -Bxor $read_only }
}#end Clear-ReadonlyFiles


$ZipCmd     = "{0}7za.exe" -f $BackupDir
$ZipCmdArgs     = "-sdel"

# Grab Directories in Location
$Directories = Get-ChildItem -Path $BackupDir -Directory

# Cycle Through and Launch 7za to Compress
# Check if Archive Exists - If yes, delete source folder
ForEach ($Directory in $Directories)
{
    $Source  = "{0}{1}" -f $BackupDir,$Directory.Name
    $Archive = "{0}.7z" -f $Source

    # Clear Read-Only Attribute on Folder
    $SubFiles = Get-ChildItem -Path $Directory -Recurse -ReadOnly
    ForEach ($SubFile in $SubFiles) {
        $SubFile.IsReadOnly = $False
    }

    #If ($Directory.IsReadOnly -eq $True) { $Directory.set_IsReadOnly($False) }

    $AllArgs = @('a', $ZipCmdArgs, $Archive, $Source);

    & $ZipCmd $AllArgs


Error message: Get-ChildItem : A parameter caot be found that matches parameter name 'Directory'. At C:PlayBackupCompress.ps1:35 char:57 + $Directories = Get-ChildItem -Path $BackupDir -Directory <<<< + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Get-ChildItem : A parameter caot be found that matches parameter name 'ReadOnly'. At C:PlayBackupCompress.ps1:45 char:66 + $SubFiles = Get-ChildItem -Path $Directory -Recurse -ReadOnly <<<< + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Property 'IsReadOnly' caot be found on this object; make sure it exists and is settable. At C:PlayBackupCompress.ps1:47 char:18 + $SubFile. <<<< IsReadOnly = $False + CategoryInfo : InvalidOperation: (IsReadOnly:String) [], RuntimeException + FullyQualifiedErrorId : PropertyNotFound

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 15 تير 1395 ساعت: 19:25

صفحه بندی