Archive for the ‘Scripting’ Category
How to set a preferred DC in PowerShell
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
VBScript To List WMI providers
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