Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##apagar um usuário local em todas as maquinas
- #variaveis
- $credencial = Get-Credential Administrador
- $computers = Get-Content C:\Users\eliel\Desktop\labin_a_pcs.txt
- $online = @()
- $offline = @()
- $contador = 1
- #repetir enquanto $contador <= 5, faz o processo 5 vezes
- DO{
- Foreach($pc in $computers) {
- if (Test-Connection -BufferSize 32 -Count 1 -ComputerName $pc -Quiet ) {
- if (Test-WSMan -ComputerName $pc -ErrorAction SilentlyContinue ) { $online += $pc }
- else { $offline += $pc }
- }
- else { $offline += $pc }
- }
- # Exibe e conta o numero de pcs
- Write-Output "O comando sera executado nos seguintes computadores: " $online
- Write-Output "Total de computadores ligados: " $online.Count
- #deleta o usuario que vc especificar em frente o user
- Invoke-Command -ComputerName $online { net user nerd /DELETE } -Credential $credencial
- #zera o conteudo da variavel e add 1 ao contador
- $online.Clear() ; $online = @()
- $contador++
- } while ( $contador -le 3 )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement