사용자가 빈 문자열을 포함 할 수없는 파일 이름을 지정해야하는 함수를 만들려고합니다. 그 외에도 문자열에는 점이 포함될 수 없습니다. 이 함수를 실행하면 예를 들어 "test"를 입력 할 때 루핑을 계속합니다. 왜 그런가?내보내기 함수
감사합니다.
Function Export-Output{
do{
$exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
}until($exportInvoke -eq "Y" -or "N")
if($exportInvoke -eq "Y"){
do {
$script:newLog = Read-host "Please enter a filename! (Exclude the extension)"
if($script:newLog.Length -lt 1 -or $script:newLog -match ".*"){
Write-Host "Wrong input!" -for red
}
}while ($script:newLog.Length -lt 1 -or $script:newLog -match ".*")
ni "$script:workingDirectory\$script:newLog.txt" -type file -value $exportValue |out-null
}
}
편집 : 관련 메모에
:
do{
$exportInvoke = Read-Host "Do you want to export this output to a new .txt file? [Y/N]"
}until($exportInvoke -eq "Y" -or "N")
나는 단순히 읽기 호스트를 우회 Enter 키를 눌러 수있는 코드의 다음 라인을 사용
."Y" -or "N"
을 간단히
"Y"
으로 바꿀 때 그렇지 않습니다. 왜 이런 일이 벌어지고 있는지에 대한 생각은?
좋아을 많이하는 데 도움이 . 나는 또 다른 작은 관련 질문에 대한 메인 포스트를 편집했다. 그걸 보시 겠어? –
@ user2744349 업데이트 된 답변보기 –
많이 감사하겠습니다. 좋은 읽을 거리에 대해서는 ... 솔직히 말해서 "N"이 $ true가되는 이유를 확실히 알 수는 없지만 알아낼 것입니다. –