Monday, September 29, 2014

Balon file for reservation disk space

Often there are situations when the free space on the disk runs out and we miss this moment :) So I suggest to use Balon file occupies 1 GB, and in the event of a critical situation with free space, delete the file. To do this, create a folder on the target disk RESERVE, in the folder, create and run a CMD file:

@echo off
IF NOT EXIST "%~dp0\safesize.rez" fsutil file createnew "%~dp0\safesize.rez" 1024000000
Download rezerve.cmd

Sunday, September 28, 2014

AO configuration null already exist on System HP_3PAR

An unexpected error may occur when you attempt to change the AO configuration storage system HP 3PAR: AO configuration null already exist on System HP_3PAR. This error leads to different thoughts about the need to re-create the AO configuration, but the solution is simple - you need to change the Name field, for example, add 1. It's just a mistake of web-interface.

Sunday, August 31, 2014

How to remove unnecessary users and groups from the local Administrators group, with a VBS script.

There are times when you want to restrict access to your computer at work. Disposable cleaning group will not help, because in the future membership of a group can change the domain group policy. Therefore, it may help a scheduled task, the task can be performed every 5 minutes. With "net localgroup" I was not able to remove the group from the group, so I propose to use the following VBS script to remove users and groups from the local Administrators group:

Download clear_adm.vbs

Set objGroup = GetObject("WinNT://./Administrators,group")

For Each Member in objGroup.members
 if not ((Member.name = "Administrator") or (Member.name = "myAccount1") or (Member.name = "myAccount2") or (Member.name = "myAccount3")) then objGroup.Remove(Member.ADSPath)
Next

Tuesday, August 26, 2014

Quick release system disk windows 2008 by "System queued Windows Error Reporting" and "Service Pack Backup Files"

In Windows 2008 quickly running out of space on the system drive. Servers Windows 2003 was a wonderful tool Disk Cleanup, but unfortunately in Windows 2008, you must additionally install this utility as components Desktop Experience and restart the server after installation, what happens is unacceptable. This gave the idea to create a small script for the prompt release of the system drive. In this scenario, removed "System queued Windows Error Reporting" and "Service Pack Backup Files". Running this script will free the system drive without restarting the server!

Download sys_disk_cleanup.cmd

@Echo off

if exist "%programdata%\microsoft\windows\wer\reportqueue" RD /S /Q "%programdata%\microsoft\windows\wer\reportqueue\" && MD "%programdata%\microsoft\windows\wer\reportqueue\"

dism /online /cleanup-image /spsuperseded

Sunday, July 13, 2014

Reset DSRM password on domain controller

There are unexpected situations when a domain controller fails and you want to boot using the DSRM mode but the password is lost. Actually DSRM password domain controller is local administrator password. Reset your password easy enough to boot (http://home.eunet.no/~pnordahl/ntpasswd/) and reset such as the local administrator password.


In this video I show you how to reset the password for DSRM mode domain controller. To do this, first set the password for DSRM mode, reboot and enter the password in DSRM mode, then reset the password from the boot disk (http://home.eunet.no/~pnordahl/ntpasswd/) and enter without a password on a domain controller in DSRM mode.

Friday, July 11, 2014

How delete lingering objects in Active Directory

In multi-domain environment, there are often problems with replication, caused by the loss of communication, time differences which resulted in an Active Directory assets appear Ghosts (lingering objects), which in turn also inhibit replication. In this article, I show an example of how to create an cmd file for cleaning Ghosts (lingering objects).

Download create_lingering_cmd.ps1

1. Go to root DNS Server and on zone property Allow zone transfers to any server
2. Open cmd nslookup tool and type command "ls -t cname youtdomain.com"
3. Go to root DNS Server and on zone property Only to servers listed on the Name Servers tab
4. Copy result where line contain _.msdcs to notepad and replace (Ctrl - H) text "._msdcs CNAME "
5. Save file with name "guids.csv"
6. Copy "guids.csv" to PC with powershell and create powershell csript

$guids = import-csv -header dcguid, dcname ".\guids.csv" -delimiter " "
$path_cmd_file = ".\lingering.cmd"
Clear-Content -path $path_cmd_file
$cmd_file = "@echo off"
Add-Content -path $path_cmd_file -value "@echo off"
foreach ($guid in $guids)
{
    $guid.dcname -match '^([^.]+).(.+)' > $nul
    $parts = $matches[2].Split(".")
    $dcname_dn = "dc="
    $i = 1
    foreach ($part in $parts)
    {
        if ($i -ne $parts.count) { $dcname_dn += $part + ",dc=" }
        else { $dcname_dn += $part }
        $i++
    }
    $comm = "repadmin /removelingeringobjects * " + $guid.dcguid + " " + $dcname_dn
    $cmd_file += "`n$comm"
    Add-Content -path $path_cmd_file -value $comm
}
$cmd_file += "`npause"
Add-Content -path $path_cmd_file -value "pause"
$cmd_file

7. Powershell script create cmd file "lingering.cmd". Now you you can copy this cmd file, repadmin tool to Domain Controller and run

Tuesday, July 8, 2014

Find using PowerShell, who use the CPU on Microsoft SQL Server

In solving problems with a high load on the server CPU Microsoft SQL Server saw the article "How to find out how much CPU a SQL Server process is really using" but when a large number of processors is not possible to identify problem processes. So the idea came from a script to automate powershell. With this script you can quickly identify problematic processes on the database Microsoft SQL Server:

Download script cpu_spid


$ServerInstance = "YourSQLServer\SQLServerInstanceName"
$CpuThreshold = "90"
$Database = "master"
$ConnectionTimeout = 30
$QueryTimeout = 120
$sql_spid = $null
$QueryBase = "SELECT top 1 spid FROM sysprocesses WHERE kpid="

$proc_time_counters = (get-counter -listset thread).PathsWithInstances | where { ($_ -like "*sqlservr*") -and ($_ -like "*Processor Time") }
$proc_time_values = (get-counter -counter $proc_time_counters).countersamples | sort CookedValue
foreach ($proc_time_value in $proc_time_values)
{
    if ($proc_time_value.CookedValue -gt $CpuThreshold)
    {
        $thread_id_counter = "\" + $proc_time_value.path.split("\")[3] + "\" + "ID Thread"
        $thread_id_value = (get-counter $thread_id_counter).readings.split(":")[1]
        write-host "ID Processor Counter:" $proc_time_value.path
        write-host "Processor Time, %:" $proc_time_value.CookedValue
        write-host "ID Thread Counter:" $thread_id_counter
        write-host "Thread:" $thread_id_value.trim()
        $Query = $QueryBase + $thread_id_value.trim()
        $conn = new-object System.Data.SqlClient.SQLConnection
        $ConnectionString = "Server={0};Database={1};Integrated Security=True;Connect Timeout={2}" -f $ServerInstance, $Database, $ConnectionTimeout
        $conn.ConnectionString = $ConnectionString
        $conn.Open()
        $cmd = new-object system.Data.SqlClient.SqlCommand($Query, $conn)
        $cmd.CommandTimeout = $QueryTimeout
        $ds = New-Object system.Data.DataSet
        $da = New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
        [void]$da.fill($ds)
        $conn.Close()
        $sql_spid = ($ds.Tables[0] | select -first 1).spid
        if ($sql_spid)
        {
            write-host "SQL spid:" $sql_spid
            $conn.ConnectionString = $ConnectionString
            $conn.Open()
            $Query2 = "sp_who2 " + $sql_spid
            $cmd2 = new-object system.Data.SqlClient.SqlCommand($Query2, $conn)
            $cmd2.CommandTimeout = $QueryTimeout
            $ds2 = New-Object system.Data.DataSet
            $da2 = New-Object system.Data.SqlClient.SqlDataAdapter($cmd2)
            [void]$da2.fill($ds2)
            $conn.Close()
            $conn.ConnectionString = $ConnectionString
            $conn.Open()
            $Query3 = "DBCC inputbuffer($sql_spid)"
            $cmd3 = new-object system.Data.SqlClient.SqlCommand($Query3, $conn)
            $cmd3.CommandTimeout = $QueryTimeout
            $ds3 = New-Object system.Data.DataSet
            $da3 = New-Object system.Data.SqlClient.SqlDataAdapter($cmd3)
            [void]$da3.fill($ds3)
            $conn.Close()
            write-host "@@@@@@ SQL session begin @@@@@"
            $ds2.Tables[0]
            $ds3.Tables[0]
            write-host "@@@@@@ SQL session end @@@@@"
        }
    else { write-host "SQL spid: no found" }
    write-host "--------------------------"
    }
}