Posts

Showing posts from October, 2016

Batch script - Ping all IP addresses in a network

Batch script to ping all IP address in a network (subnet): FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply" >c:\ipaddresses.txt Change 192.168.10 to match you own network. By using -n 1 you are asking for only 1 packet to be sent to each computer instead of the usual 4 packets. The above command will ping all IP Addresses on the 192.168.10.0 network and create a text document in the C:\ drive called ipaddresses.txt. This text document should only contain IP Addresses that replied to the ping request. Although it will take quite a bit longer to complete, you can also resolve the IP Addresses to HOST names by simply adding -a to the ping command. FOR /L %i IN (1,1,254) DO ping -a -n 1 192.168.10.%i | FIND /i "Reply" >c:\ipaddresses.txt Ref: https://stackoverflow.com/questions/13713318/ping-all-addresses-in-network-windows

PowerShell Script to get disk size in MB and Used space

Below is PowerShell script to get disks size in MB and Used space in GB: Get-Wmiobject -query "select name,driveletter,capacity,freespace from win32_volume where drivetype=3" | Format-Table -autosize Name, @{ label="SizeGB"; Expression={($_.capacity / 1GB).tostring("F0")}}, @{ label="UsedSizeGB"; Expression={(($_.capacity/1GB) - ($_.freespace/1GB)).tostring("F0")}}, @{label="FreeGB"; Expression={($_.freespace / 1GB).tostring("F0")}}, @{label="Free%"; Expression={($_.freespace*100/$_.capacity).tostring("F0")}}, @{ label="SizeMB"; Expression={($_.capacity / 1MB).tostring("F0")}} >C:\Temp\DisksSizeinMB.txt Values explained: @{label="SizeGB"; Expression={($_.capacity / 1GB).tostring("F0")}}, @{label="UsedSizeGB"; Expression={(($_.capacity/1GB) - ($_.freespace/1GB)).tostring("F0")}}, @{label="FreeGB"; Expression={($_.