Posts

Showing posts from 2016

Psexec to run dir

psexec.exe @servers.txt cmd /k dir c:\users /o-d >>output.log

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={($_.

wmic logicaldisk get Name,Size

wmic logicaldisk get Name,Size

Script to get disk space in MB (including MountPoints).

I'm looking for a simple script to get disk space in MB (including MountPoints). Below is the latest vbs script I'm going to try: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk where drivetype <> 5") WScript.Echo "Name Capacity Free Free %" For each objDisk in colDisks percentfree = (objdisk.Freespace / objdisk.Size) * 100 With objDisk WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1048576, 2)) & " " & pad(FormatNumber(.Freespace/1048576, 2)) & " " & FormatNumber(percentfree, 2) End With Next function pad(strText) strText = Space(12) + strText strText = Right(strText, 10) pad = strText end function Ref: http://www.computerhope.com/forum/inde

Script to get disk space in MB (including MountPoints).

I'm looking for a simple script to get disk space in MB (including MountPoints). Below is the latest vbs script I'm going to try: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk where drivetype <> 5") WScript.Echo "Name Capacity Free Free %" For each objDisk in colDisks percentfree = (objdisk.Freespace / objdisk.Size) * 100 With objDisk WScript.Echo .DeviceId & " " & pad(FormatNumber(.Size/1048576, 2)) & " " & pad(FormatNumber(.Freespace/1048576, 2)) & " " & FormatNumber(percentfree, 2) End With Next function pad(strText) strText = Space(12) + strText strText = Right(strText, 10) pad = strText end function Ref: http://www.computerhope.com/forum/inde

Stop hung service (stopping or starting status) without server reboot

Here is a solution to stop an hung service without server reboot. Here an hung service is a service in stopping or starting status. Step 1 : find the PID of the service using any way: Task manager sc queryex servicename tasklist /svc | findstr /i servicename Step 2: Kill the service by it's PID with taskkill /f command, syntax below: taskkill /f /pid pidoftheservice example: taskkill /f /pid 2320 This works for many cases :)

iscsi connection commands for physical servers (NetApp SnapDrive)

The disk list command The  disk list  command displays a list of all the LUNs connected to the host. Syntax for this command is: sdcli disk list The preceding example lists all the SnapDrive LUNs mapped to drive letters on the local host. The disk list command also provides the following information for each LUN: LUN path ( storage system  name, share name, virtual disk file name, and might also include qtree name) Storage System Storage System Path ( storage system -side path, which includes volume name and LUN name) Hyper-V VHD present (a Hyper-V VHD exists) Hyper-V VM name Type Disk serial number Backed by Snapshot copy (if this is a LUN in a Snapshot copy, this displays the  storage system -side path to the Snapshot copy) Shared (whether the disk is dedicated or shared) CSV disk Boot or System Disk SCSI port Bus Target LUN Read only Disk size (in megabytes) SnapMirror source SnapVault primary Disk Partition Style (either MBR or GPT) Clone Split Res

Command to delete a folder in multiple remote computers

Below is the command i used to delete a folder in multiple remote computers: psexec @servers.txt cmd /c rd /s /q c:\folderpath\folder2del