How to automate a command line utility like DiskPart (vbscript)

Hi all, The other day I created a VBScript to automate DiskPart.exe tool and be able to perform tasks on a disk after selecting it by LUN ID. Note that Diskpart only allow us to select disks by their index number or their location path. Bellow you can see a sample Diskpart.exe script, and how…

3

How to update "Run only specified windows applications" GPO programmatically (VBScript)

Hi all,   A customer of mine had to add a list of thousands of applications to the “Run only specified windows applications” GPO on his Windows Server 2008. And obviously he wanted to automate this task to avoid adding them manually one at a time.  So I went the easy way and created the…

1

How to get the AD groups a user is member of (ASP)

Hi all, The following ASP sample shows how to get all Active Directory groups of the user accessing the ASP page. Note: I know ASP is quite old and people should be using ASP.NET instead. But I’m posting this sample because translating it to VBScript is pretty straightforward, and I still have many customers using VBScript.<%…

1

How to change drive letters (VBScript)

Hi all, Imagine you need to map some shared folders to specific drive letters for all users in your domain, so some internal apps your company needs work fine. Imagine your users connected i.e. USB devices to their systems, so the drive letters those apps need are in use when you are going to map them. The…

3

How to get all DCs in a Forest (VBScript)

Hi all, The following VBScript sample lists all DCs in a Forest:’ Create log file ‘ Set objFSO = CreateObject(“Scripting.FileSystemObject”) Set objLog = objFSO.CreateTextFile (“log.txt”) ‘ Get Forest’s root ‘ Set objRoot = GetObject(“LDAP://rootDSE”) ‘ Get root’s Configuration ‘ Set objConfig = GetObject(“LDAP://” & objRoot.Get(“ConfigurationNamingContext”)) ‘ Search for the Partitions container in root’s Configuration ‘…

1

How to change ownership and give full permissions to a user on a folder (VBScript)

Hi all, Some time ago we faced an issue where a customer renamed users in their domain, but their profile folders didn’t get renamed. So they wanted to automate the following process which worked for them when doing it manually: take ownership of a user’s profile folder with an administrator, give full permissions to that admin…

0

How to get LastLogon property for all users in a Domain (VBScript)

Hi all, The following VBScript sample retrieves all users in Active Directory that haven’t ever logged on the domain, or haven’t logged on for at least maxDays (an argument passed to the script): On Error Resume Next ‘ Constants ‘ Const ONE_HUNDRED_NANOSECOND = .000000100 Const SECONDS_IN_DAY = 86400 ‘ Get Max Days as an argument passed…

4

How to sign EXE files with an Authenticode certificate (part 2)

Hi all, welcome back, The other day a customer of mine was having an issue with SignTool.exe when signing an EXE file. The EXE file was getting corrupted/unusable after signing it. When troubleshooting this issue, I had the chance to play a bit more with SignTool and check what it does behind the scenes. Note: I…

9

How to change Windows Theme programmatically in XP

Hi all, You may know already that there is no i.e. COM object or .NET class we can use to change the Windows Theme programmatically on Windows XP. You may also know the following VBScript which can be used to do this change without user intervention:Set OSHApp = CreateObject(“Shell.Application”) Set oShell = CreateObject(“Wscript.Shell”) ‘ Set…

2

How to get more than 1000 group members including foreign SAMs (VBScript)

Hi all, We may have a group in our Active Directory with members from a foreign domain. We may try to retrieve all those members with ADSI and a code like this: Using IADs::GetInfoEx for Range Retrieval. The issue with this code is that we will only be able to see the SID of foreign…

0