Advertisement
wackou

Windows 7 Post-installation script

Dec 22nd, 2012
2,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Créé un utilisateur local et l'ajoute dans le groupe Administrateurs.
  2. # Ajoute l'utilisateur actuel dans le groupe administrateurs
  3. # Ajoute le groupe admins_global dans le groupe administrateurs
  4. # Installe la police W92.FON,
  5. # Copie le raccourcie MFGPRO sur le bureau de l'utilisateur
  6. # Installe Access 97
  7. # Il fait un inventaire du poste
  8. #
  9. #
  10. # Wackou
  11. # contact@wackou.com
  12. # www.wackou.com
  13.  
  14. #FONCTIONS
  15. function create-account ([string]$accountName = "supporter") { #CREATION COMPTE LOCAL SUPPORTER
  16.     $hostname = hostname
  17.     $comp = [adsi] "WinNT://$hostname" # connexion PC local
  18.     $user = $comp.Create("User", $accountName) #creation de utilisateur
  19.     $user.SetPassword("P@$$w0rd") #ajout du MDP
  20.     $user.SetInfo()
  21.     $user.UserFlags = 64 + 65536 # Le mot de passe ne peut pas etre changé et n'expire jamais
  22.     $user.SetInfo()
  23.     ([ADSI]"WinNT://$hostname/Administrateurs,group").Add("WinNT://$hostname/$accountName") #ajout du compte dans le groupe administrateurs
  24. }
  25.  
  26. function user_local { #AJOUT DU CURRENT USER EN TANT QU'ADMIN
  27.     $user = $env:USERNAME
  28.     $domain = $env:USERDOMAIN
  29.     $hostname = hostname
  30.     $group = [ADSI]"WinNT://$hostname/Administrateurs,group"
  31.     $user_domain = [ADSI]"WinNT://$domain/$user,user"
  32.     $group.Add($user_domain.Path)
  33. }
  34.  
  35. function AdminGroup { #AJOUT GROUPE admins_global DANS GROUPE ADMINISTRATEURS
  36.     $hostname = hostname
  37.     $domain = $env:USERDOMAIN
  38.     $GroupName = 'Admins_Global'
  39.     $group = [ADSI]"WinNT://$hostname/Administrateurs,group"
  40.     $group_domain = [ADSI]"WinNT://$domain/$GroupName,group"
  41.     $group.Add($group_domain.Path)
  42. }
  43.  
  44. function police { #COPIE DE POLICE W92.FON SUR LE POSTE
  45.     $FONTS = 0x14
  46.     $Path="c:\fonts"
  47.     $objShell = New-Object -ComObject Shell.Application
  48.     $objFolder = $objShell.Namespace($FONTS)
  49.     New-Item $Path -type directory
  50.     Copy-Item "Y:\W92.FON" $Path
  51.     $Fontdir = dir $Path
  52.     foreach($File in $Fontdir) {
  53.         $objFolder.CopyHere($File.fullname)
  54.     }
  55. }
  56.  
  57. function mfgpro { #COPIE DE MFGPRO SUR LE POSTE
  58.     $user = $env:USERNAME
  59.     Copy-Item "Y:\MFGPRO.lnk" C:\users\$user\Desktop\
  60. }
  61.  
  62. function access97 {
  63. Y:\Access97.lnk
  64. }
  65.  
  66. #Check si droit admin
  67. If (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
  68.     Write-Warning "This script requires Admin Rights. Please run this script with an account that has sufficient rights."
  69.     exit
  70. }
  71.  
  72. Write-Host "+--------------------------------+"
  73. Write-Host "¦           Windows 7            ¦"
  74. Write-Host "¦     post migration script      ¦"
  75. Write-Host "+--------------------------------+"
  76. write-host ""
  77. #APPELS DES FONCTIONS
  78. create-account
  79. write-host "Creation du compte supporter ..."
  80. write-host ""
  81. user_local
  82. write-host "Ajout de l'utilisateur courant dans le groupe Administrateurs ..."
  83. write-host ""
  84. AdminGroup
  85. write-host "Ajout de Admins_Global dans le groupe Administrateurs ..."
  86. write-host ""
  87. police
  88. write-host "Installation de la police W92 ..."
  89. write-host ""
  90. write-host "Installer MFGPRO? o/n"
  91. $mfgpro = Read-Host "->"
  92. if ($mfgpro -eq "o")
  93.     {
  94.     mfgpro
  95.     write-host "Copie de MFGPRO sur le bureau ..."
  96.     write-host ""
  97.     }
  98. write-host "Installer access97? o/n"
  99. $access97 = Read-Host "->"
  100. if ($access97 -eq "o")
  101.     {
  102.     access97
  103.     write-host "Lancement de l'installation d'Access97 ..."
  104.     write-host ""
  105.     }
  106. Y:\ocsinventory.exe /server=http://server_ocs/ocsinventory /np /force /hkcu
  107. write-host "Inventaire du poste sur server_ocs..."
  108. write-host ""
  109. read-host "Press any key to continue ..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement