Hi i made a script that checks disk space and transfers it on to a log and i want to put the error that pops on the prompt inside the log heres my code:
$equipos = "D:\SCRIPTSM\AAAA\equipos.txt"
$listaEquipos = Get-Content $equipos
$fecha = (Get-Date).ToString('dd.MM.yyyy')
$espaciotxt = foreach ($equipo in $listaEquipos){
Get-WmiObject -Class Win32_LogicalDisk -ComputerName $equipo -Filter "drivetype=3" | Sort-Object -Property DeviceID | Format-Table -Property DeviceID,
@{name='EspacioLIBRE(MB)';expression={$_.Freespace / 1MB -as [int]}},
@{name='TamañoDISCO(GB)';expression={$_.Size / 1GB -as [int]}},
@{name='%Libre';expression={$_.FreeSpace / $_.Size * 100 -as [int]}}
Write-Output "Ip del equipo : $equipo fecha del test: $fecha"
}
$espaciotxt | Out-File C:\Users\AAAAA\Desktop\PRU.txt
Heres the exit log and where do i want to place the error prompt inside of it.
Error prompt: Get-WmiObject : RPC server is not available...