Ver Fonte

add invoke-script and set-autologin

Tobias Simetsreiter há 2 anos atrás
pai
commit
7325e044ad
2 ficheiros alterados com 44 adições e 0 exclusões
  1. 8 0
      bin/Invoke-Script.ps1
  2. 36 0
      bin/Set-AutoLogin.ps1

+ 8 - 0
bin/Invoke-Script.ps1

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

+ 36 - 0
bin/Set-AutoLogin.ps1

@@ -0,0 +1,36 @@
+param(
+    $Username = $null,
+    $Pass = $null
+)
+
+### The code below configures Auto-Login on Windows computers ###
+ 
+<#
+ 
+Author: Patrick Gruenauer | Microsoft MVP on PowerShell
+Web: https://sid-500.com
+ 
+#>
+
+hostname
+if ($null -eq $Username){
+    $Username = Read-Host 'Enter username for auto-logon (f.e. contoso\user1)'
+}
+
+if ($null -eq $Pass){
+    $Pass = Read-Host "Enter password for $Username"
+}
+$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon'
+Set-ItemProperty $RegistryPath 'AutoAdminLogon' -Value "1" -Type String 
+Set-ItemProperty $RegistryPath 'DefaultUsername' -Value "$Username" -type String 
+Set-ItemProperty $RegistryPath 'DefaultPassword' -Value "$Pass" -type String
+ 
+Write-Warning "Auto-Login for $username configured. Please restart computer."
+ 
+$restart = Read-Host 'Do you want to restart your computer now for testing auto-logon? (Y/N)'
+ 
+If ($restart -eq 'Y') {
+ 
+    Restart-Computer -Force
+ 
+}