Skip to main content

Folder

#Erstellt Unterordner im aktuellen Verzeichnis
param(
[String] $folderName
)
$exitCode = ":q"

if ( -not $folderName ) {
Write-Host "Geben sie den Verzeichnisnamen an."
while ( -not $folderName ) {
$folderName = Read-Host "Verzeichnis? ($exitCode = Exit)"
}
}
else
{
Write-Host Parameter: $folderName
return 1
}
if ($folderName -eq $exitCode){return -1}

$currentfolder = Get-Location
#Write-Host $currentfolder
$PATH = "$currentfolder\$folderName"
if (!(Test-Path $PATH)) {New-Item -Path $PATH -ItemType Directory}

--------------------------------------------------

Join-Path -Path "path" -ChildPath "childpath"
path\childpath

[IO.Path]::Combine('C:\', 'Foo', 'Bar')

-------------------------------------------------

Test-Path

if(![System.IO.File]::Exists($path)){
# file with path $path doesn't exist
}