Advertisement
Eliel_Sec

PowerShell_Criar usuario local em todas as maquinas

Aug 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##criar um usuΓ‘rio local em todas as maquinas e adiciona-lo ao grupo administradores.
  2.  
  3. $credencial = Get-Credential Administrador
  4. $computers = Get-Content C:\Users\eliel\Desktop\scritps_powershell\labin_c_pcs.txt
  5. $online = @()
  6. $offline = @()
  7.  
  8. Foreach($pc in $computers) {
  9.     if (Test-Connection -BufferSize 32 -Count 1 -ComputerName $pc -Quiet) {
  10.  
  11.          if (Test-WSMan -ComputerName $pc ) {  $online += $pc }
  12.          
  13.          else  { $offline += $pc }
  14.  
  15. }
  16.  
  17. else { $offline += $pc }
  18.  
  19. }
  20.  
  21. Write-Output "O comando sera executado nos seguintes computadores: " $online
  22. Write-Output "Total de computadores ligados: " $online.Count
  23.  
  24. Invoke-Command -ComputerName $online { net user estagiario senha_aqui /add /Y ; net localgroup Administradores estagiario /add } -Credential $credencial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement