Browse Source

check for empty username

Tobias Simetsreiter 2 years ago
parent
commit
47920c4dfb
2 changed files with 7 additions and 2 deletions
  1. 3 2
      bin/Invoke-Script.ps1
  2. 4 0
      bin/Set-AutoLogin.ps1

+ 3 - 2
bin/Invoke-Script.ps1

@@ -1,8 +1,9 @@
 param(
     $Script,
-    $ComputerName
+    $ComputerName,
+    $ArgumentList = @()
 )
 
 $source = Get-Command $Script  | Select-Object -ExpandProperty ScriptBlock
 
-Invoke-Command -ScriptBlock $source -ComputerName $ComputerName
+Invoke-Command -ScriptBlock $source -ComputerName $ComputerName -ArgumentList $ArgumentList

+ 4 - 0
bin/Set-AutoLogin.ps1

@@ -17,6 +17,10 @@ if ($null -eq $Username){
     $Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)'
 }
 
+if ("" -eq $Username) {
+    throw "Username is Empty!"
+}
+
 if ($null -eq $Pass){
     $Pass = Read-Host "Enter password for $Username"
 }