param (
[Parameter(Mandatory=$false)][String[]]$computer = ".",
[Parameter(Mandatory=$false)][String[]]$computerName =
$env:computername,
[Parameter(Mandatory=$false)][String]$DefaultDomainName =
$env:USERDOMAIN,
[Parameter(Mandatory=$false)][String]$DefaultUserName =
"test",
[Parameter(Mandatory=$false)][String]$DefaultPassword = "pwd",
[Parameter(Mandatory=$false)][String]$Group = "administrators",
[Parameter(Mandatory=$false)][Int]$AutoLogonCount
)
function add_autologon(){
foreach($computer in $computerName){
#do local modifications here
Write-Verbose
"Adding required registry values on $($computer)"
Write-Verbose
"Saving curent location"
Push-Location
Set-Location
"HKLM:\Software\Microsoft\Windows NT\Currentversion\WinLogon"
New-ItemProperty -Path
$pwd.Path -Name "AutoAdminLogon" -Value 1 -PropertyType
"String" -Force | Out-Null
New-ItemProperty -Path
$pwd.Path -Name "DefaultUserName" -Value $DefaultUserName
-PropertyType "String" -Force | Out-Null
New-ItemProperty -Path
$pwd.Path -Name "DefaultPassword" -Value $DefaultPassword
-PropertyType "String" -Force | Out-Null
New-ItemProperty -Path
$pwd.Path -Name "DefaultDomainName" -Value $DefaultDomainName
-PropertyType "String" -Force | Out-Null
if ($AutoLogonCount) {
New-ItemProperty -Path
$pwd.Path -Name "AutoLogonCount" -Value $AutoLogonCount -PropertyType
"Dword" -Force | Out-Null
}
Write-Verbose
"restoring earlier location"
Pop-Location
}
}
沒有留言:
張貼留言