Monday, October 29, 2012

How to copy large file across the network on windows environment?



Scenerio:
1.       Sample 10 GB dummy file was created on the Jump Server (*****001)

Cmd:  Fsutil file createnew bigfile.out 10737418240

10 GB =  10*1024*1024*1024 bytes

Note: CMD should be run with administrator’s credentials.

2.       Go to Destination server (*******03)

>robocopy C:\bigfile \\******.59\soumen bigfile.out








Unable to Delete File ?

Utility: Handle.exe from Sysinternals

The syntax is handle.exe -p -c -y.

C:\Toolbox>Handle.exe plugin.jar

Handle v3.2
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

firefox.exe pid: 5508 5B4: C:\Java\jre5\lib\plugin.jar
java.exe pid: 4632 638: C:\Java\jre5\lib\plugin.jar
java.exe pid: 6332 628: C:\Java\jre5\lib\plugin.jar

C:\Toolbox>Handle.exe -p 5508 -c 5b4 -y

Handle v3.2
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

 5B4: File (RW-) C:\Java\jre5\lib\plugin.jar

Handle closed.

C:\Toolbox>Handle.exe plugin.jar

Handle v3.2
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

java.exe pid: 4632 638: C:\Java\jre5\lib\plugin.jar
java.exe pid: 6332 628: C:\Java\jre5\lib\plugin.jar

C:\Toolbox>

OR

Handle.exe -a > List.txt

Search the file which needs to be deleted.

And follow the above process.

Example

Tuesday, October 9, 2012

List Disk Space Status for Bulk Server ?


# Issue warning if % free disk space is less
$percentWarning = 15;
# Get server list
$servers = Get-Content "$Env:USERPROFILE\Desktop\SUBHAG\POWERSHELL\POWERSHELL\servername.txt";
$datetime = Get-Date -Format "yyyyMMddHHmmss";

# Add headers to log file
Add-Content "$Env:USERPROFILE\\Desktop\SUBHAG\POWERSHELL\POWERSHELL\server disks $datetime.txt" "server,deviceID,size,freespace,percentFree";

foreach($server in $servers)
{
# Get fixed drive info
$disks = Get-WmiObject -ComputerName $server -Class Win32_LogicalDisk -Filter "DriveType = 3";

foreach($disk in $disks)
{
$deviceID = $disk.DeviceID;
[float]$size = $disk.Size;
[float]$freespace = $disk.FreeSpace;

$percentFree = [Math]::Round(($freespace / $size) * 100, 2);
$sizeGB = [Math]::Round($size / 1073741824, 2);
$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);

$colour = "Green";
if($percentFree -lt $percentWarning)
{
$colour = "Red";
}
Write-Host -ForegroundColor $colour "$server $deviceID percentage free space = $percentFree";
Add-Content "$Env:USERPROFILE\\Desktop\SUBHAG\POWERSHELL\POWERSHELL\server disks $datetime.txt" "$server,$deviceID,$sizeGB,$freeSpaceGB,$percentFree";
}
}

Change Account Expiry for Bulk Users ?


----------------------------------------------------------------------------------------------------------
Create a file SAMID.txt and put all the account name in it and execute the command from the current directory

for /f %C in (SAMID.txt) do dsquery user -samid %C | dsmod user -acctexpires

Ex. Today 29-May-2012 and extension has to be done upto 30-JUNE-2012,
Then the no. of days will be 30+3=33

------------------------------------------------------------------------------------------------------------

How to Find a Email address of all the members of Security Group ?


dsquery group -name | dsget group -members | dsquery user -limit 0| dsget user -email