From b4dff5966f9c0c6b3000a2f621cd7520caaca252 Mon Sep 17 00:00:00 2001 From: reiyua Date: Fri, 12 Apr 2024 19:11:29 +1000 Subject: [PATCH] Add credit for CSV file verification --- AutoUserADCreator.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AutoUserADCreator.ps1 b/AutoUserADCreator.ps1 index cdd83ad..4baf43f 100644 --- a/AutoUserADCreator.ps1 +++ b/AutoUserADCreator.ps1 @@ -15,6 +15,8 @@ $fpath = Read-Host -Prompt "Please enter the path to your CSV file:" # Check if CSV file exists with the path specified by the end-user # If so, error out the program with generic error stating so. (RAYYAN Contribution) +# This uses the "Test-Path" cmdlet which tests if the path actually exists and can be read by the system. +# Source for code (https://www.itechguides.com/powershell-check-if-file-exists/#:~:text=If%20(Test%2DPath%20%2DPath%20E%3A%5Creports%5Cprocesses.txt%20)%20%7B%0ACopy%2DItem%20%2DPath%20E%3A%5Creports%5Cprocesses.txt%20%2DDestination%20C%3A%5Creports%0A%7D) if (-not (Test-Path $fpath)) { Write-Host "CSV file does not exist. Exiting script." exit