Próbuję utworzyć folder przy użyciu PowerShell, jeśli nie istnieje, więc zrobiłem:Tworzenie folderu, jeśli nie istnieje - „Obiekt już istnieje”
$DOCDIR = [Environment]::GetFolderPath("MyDocuments")
$TARGETDIR = "$DOCDIR\MatchedLog"
if(!(Test-Path -Path MatchedLog)){
New-Item -ItemType directory -Path $DOCDIR\MatchedLog
}
To daje mi błąd, że folderze już istnieje, co robi, ale nie powinno próbować go tworzyć.
Nie jestem pewien, co się dzieje tutaj
New-Item: Element z nazwą określoną C: \ Users \ L \ Documents \ MatchedLog już istnieje. W C: \ Users \ l \ Documents \ \ email.ps1 PowerShell: 4 Znak: 13 + New-Item < < < < katalog -ItemType -path $ DOCDIR \ MatchedLog + CategoryInfo: ResourceExists: (C: \ Users \ L .... enty \ MatchedLog: String) [New-Item], IOException + FullyQualifiedErrorId: DirectoryExist, Microsoft.PowerShell.Commands.NewItemCommand`
Spróbuj to: New-Item -ItemType katalog -force - Ścieżka C: \ Ścieżka \ Która \ Maj \ Or \ May \ Not \ Exist –