Jeremy Phillips

Thoughts on technology, management and more

Archive for the ‘Scripting’ Category

How to set a preferred DC in PowerShell

without comments

It’s quick and easy but keep in mind this does not set a default for PowerShell sessions. You’ll have to enter this command in each window you want to specify a DC in.

Set-ADServerSettings –PreferredServer <fqdn>

On the same subject, it’s easy to find out what DC & GC you’re using in a particular PowerShell session. Just execute the following command:

Get-ADServerSettings | fl

Possibly Related Posts:

Written by Jeremy Phillips

December 7th, 2009 at 6:29 am

Posted in Scripting

Tagged with

VBScript To List WMI providers

without comments

Just in case you need it as well –

strComputer = “.”

Set objWMIService=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _
strComputer & “\root\cimv2″)
Const ForAppending = 8
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objTextFile = objFSO.OpenTextFile _
(“c:\scripts\wmiProviders.txt”, ForAppending, True)
Set colWin32Providers = objWMIService.InstancesOf(“__Win32Provider”)
For Each objWin32Provider In colWin32Providers
objTextFile.WriteLine(objWin32Provider.Name)
Next
objTextFile.Close

Possibly Related Posts:

Written by Jeremy Phillips

December 7th, 2009 at 6:29 am

Posted in Scripting

Tagged with