Advertisement
Eliel_Sec

PowerShell_Listar espaço em disco

Aug 31st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##Listar espaço livre e usado em C:
  2.  
  3.  
  4. $credencial = Get-Credential Administrador
  5. $computers  = Get-Content C:\Users\eliel\Desktop\scritps_powershell\labin_a_pcs.txt
  6. $online = @()
  7. $offline = @()
  8.  
  9.  
  10. Foreach($pc in $computers) {
  11.     if (Test-Connection -BufferSize 32 -Count 1 -ComputerName $pc -Quiet) {
  12.  
  13.          if (Test-WSMan -ComputerName $pc ) {  $online += $pc }
  14.          
  15.          else  { $offline += $pc }
  16.  
  17. }
  18.  
  19. else { $offline += $pc }
  20.  
  21. }
  22.  
  23. Write-Output "O comando sera executado nos seguintes computadores: " $online
  24. Write-Output "Total de computadores ligados: " $online.Count
  25.  
  26. Invoke-Command -ComputerName $online { Get-PSDrive C } -Credential $credencial
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement