Monday, 7 January 2013

Win DNS - Delete PTR record with all capitals

As per:

http://www.jetmore.org/john/blog/2012/09/deleting-ptr-records-containing-upper-case-characters-in-microsoft-dns/

use the following command to delete PTR record for 10.10.10.1 for instance:

dnscmd 10.10.10.33 /RecordDelete 10.10.in-addr.arpa. 1.10 PTR

Wednesday, 19 December 2012

Deleting pending or failed certificate requests

As per:

http://blogs.technet.com/b/askds/archive/2010/08/31/the-case-of-the-enormous-ca-database.aspx

For example, if you want to delete all failed and pending requests submitted by the 19/December/2012, the command is:

certutil -deleterow 12/19/2012 Request

Tuesday, 25 September 2012

Getting a list of persistently mapped drives

There are many scripts on the Internet I found that allow you to enumerate which drives a user has currently mapped. What I needed was a list of drives mapped persistently (thus manually), which would exclude drives user has just mapped temporarily as well as drives mapped by other scripts. Here's the VBSCRIPT I came up with:


' List Persistently Mapped Network Drives
Option explicit

const HKEY_CURRENT_USER = &H80000001

Dim strComputer
Dim objReg
Dim objShell
Dim arrSubKeys
Dim i
Dim strRemotePath

strComputer = "."

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objShell = Wscript.CreateObject("WScript.Shell")

objReg.EnumKey HKEY_CURRENT_USER, "Network", arrSubKeys

If IsArray(arrSubKeys) Then
    For i=0 to UBound(arrSubKeys)
        objReg.GetStringValue HKEY_CURRENT_USER, "Network\" & arrSubKeys(i), "RemotePath", strRemotePath
        objShell.Run ("%comspec% /K echo " & arrSubKeys(i) & ": is mounted to " & strRemotePath &_
            ">> \\server\share\%USERNAME%_on_%COMPUTERNAME%.txt"),0
    Next
Else
    objShell.Run ("%comspec% /K echo No persistent mappings found>> \\server\share\%USERNAME%_on_%COMPUTERNAME%.txt"),0
End If


Specify the script above as the Logoff script using a GPO and after a few days/weeks you will have a full list of who has mapped what and where, so that then a decision can be made as to how to migrate from manual drive mappings to automated ones.