Advertisement
Eliel_Sec

PowerShell_Listar Nome_Ipv4_mac labin A

Aug 31st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##Listar Nome, Endereço IP e Mac das maquinas do lab A
  2.  
  3. $computers  = Get-Content C:\Users\eliel\Desktop\scritps_powershell\labin_a_pcs.txt
  4. $online = @()
  5. $offline = @()
  6. $credencial = Get-Credential Administrador
  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 { Get-WmiObject -Class win32_networkadapterconfiguration | Where-Object index -EQ 7 | Select-Object pscomputername, ipaddress, macaddress | Format-Table -AutoSize } -Credential $credencial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement