wackou

Windows 7 Post-installation script

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