param ([Parameter (Mandatory)]$DirName) $NewDir = "$env:HOMEPATH\Documents\$DirName"; if (-not(Test-Path $NewDir)) { try { New-Item -ItemType Directory -Path $NewDir | Out-Null; Write-Output "Created directory $NewDir"; } catch { Write-Output "Error creating $NewDir"; Exit 102; } } else { Write-Output "Using existing directory $NewDir"; } $NewFile = "$NewDir\NewStuff.txt"; New-Item -Path $NewFile -ItemType File -Force | Out-Null; Add-Content -Path $NewFile -Value (Get-Date); Add-Content -Path $NewFile -Value $env:USERNAME; Add-Content -Path $NewFile -Value $MyInvocation.MyCommand.Name; Write-Output "(Re)created $NewFile"; Get-Content $NewFile;