From c222dfda657008dbf68cb1c0e8b525a826348bd5 Mon Sep 17 00:00:00 2001 From: James Stringer <38541878+jamesstringerparsec@users.noreply.github.com> Date: Sun, 12 Dec 2021 19:36:17 +0100 Subject: [PATCH] Check for long usernames --- CopyFilesToVM.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index 8e6f209..173cab2 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -32,8 +32,8 @@ if ($params.Username -eq $params.VMName ) { if (!($params.Username -match "^[a-zA-Z0-9]+$")) { $ExitReason += "Username cannot contain special characters." } -if (!($params.VMName -match "^[a-zA-Z0-9]+$")) { - $ExitReason += "VMName cannot contain special characters." +if (($params.VMName -notmatch "^[a-zA-Z0-9]+$") -or ($params.VMName.Length -gt 15)) { + $ExitReason += "VMName cannot contain special characters, or be more than 15 characters long" } if (([Environment]::OSVersion.Version.Build -lt 22000) -and ($params.GPUName -ne "AUTO")) { $ExitReason += "GPUName must be set to AUTO on Windows 10."