Set-StrictMode -Version 2 # load required modules Import-Module ActiveDirectory Import-Module GroupPolicy #define variables $GPOName = 'GPO-AutoLogon' $defaultNC = ( [ADSI]"LDAP://RootDSE" ).defaultNamingContext.Value $TargetOU = $defaultNC #$TargetOU = 'OU=Serveurs,' + $defaultNC #create new GPO shell $GPO = New-GPO -Name $GPOName #Pose d'éléments pour modifier des clés de registre par GPO Set-GPPrefRegistryValue -Name $GPOName -Action Update -Context Computer -Key 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Type String -ValueName 'DefaultDomainName' -Value 'MyDomain' | out-null Set-GPPrefRegistryValue -Name $GPOName -Action Update -Context Computer -Key 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Type String -ValueName 'DefaultUserName' -Value 'Administrator' | out-null Set-GPPrefRegistryValue -Name $GPOName -Action Update -Context Computer -Key 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Type String -ValueName 'DefaultPassword' -Value 'MotDePasse' | out-null Set-GPPrefRegistryValue -Name $GPOName -Action Update -Context Computer -Key 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon' -Type String -ValueName 'AutoAdminLogon' -Value '1' | out-null