Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Listar Nome, Endereço IP e Mac das maquinas do lab A melhorado
- $computers = Get-Content C:\Users\eliel\Desktop\scritps_powershell\labin_a_pcs.txt
- $online = @()
- $offline = @()
- $credencial = Get-Credential Administrador
- Foreach($pc in $computers) {
- if (Test-Connection -BufferSize 32 -Count 1 -ComputerName $pc -Quiet) {
- if (Test-WSMan -ComputerName $pc ) { $online += $pc }
- else { $offline += $pc }
- }
- else { $offline += $pc }
- }
- Write-Output "O comando sera executado nos seguintes computadores: " $online
- Write-Output "Total de computadores ligados: " $online.Count
- $resultado = (Invoke-Command -ComputerName $online { Get-WmiObject -Class win32_networkadapterconfiguration | Where-Object index -EQ 7 | Select-Object pscomputername, ipaddress, macaddress } -Credential $credencial )
- $resultado | Select-Object pscomputername, ipaddress, macaddress | Sort-Object -Property PSComputerName | Format-Table | Out-File -FilePath C:\Users\eliel\Desktop\nomes_enderecos_mac.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement