List DFS targets via VBscript

http://gallery.technet.microsoft.com/scriptcenter/b54f021f-b824-4c7f-a483-e679228cdf7a

Advertisements

vbscript based computer inventory scripts

strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _     & “{impersonationLevel=impersonate}!\\” _     & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _     (“Select * from Win32_OperatingSystem”) For Each objOperatingSystem in colOperatingSystems     Wscript.Echo objOperatingSystem.Caption & _     ”  ” & objOperatingSystem.Version Next

strComputer = “.” Set objWMIService = GetObject( _     “winmgmts:\\” & strComputer & “\root\cimv2”) Set IPConfigSet = objWMIService.ExecQuery _     (“Select IPAddress from Win32_NetworkAdapterConfiguration” _         & ” where IPEnabled=TRUE”)   For Each IPConfig in IPConfigSet     If Not IsNull(IPConfig.IPAddress) Then         For i=LBound(IPConfig.IPAddress) _         to UBound(IPConfig.IPAddress)             WScript.Echo IPConfig.IPAddress(i)         Next     End If Next

Get active directory role with vbscript

sComputer = “.” WScript.Echo DomainRole(sComputer)

Function DomainRole(sNode) Set oWMI = GetObject(“winmgmts:” _ & “{impersonationLevel=impersonate}!\\” & sNode & “\root\cimv2”) Set colComputer = oWMI.ExecQuery _ (“Select DomainRole from Win32_ComputerSystem”) For Each oComputer in colComputer iDR = oComputer.DomainRole Next

Select Case iDR Case 0 DomainRole = “Standalone Workstation” Case 1 DomainRole = “Member Workstation” Case 2 DomainRole = “Standalone Server” Case 3 DomainRole = “Member Server” Case 4 DomainRole = “Backup Domain Controller” Case 5 DomainRole = “Primary Domain Controller” Case Else DomainRole = “Unknown” End Select

End Function

vbscript to copy file to multiple computers from list

Const ForReading = 1
Const OverwriteExisting = TRUE

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFile = objFSO.OpenTextFile(“C:\Computers.txt”)

Do Until objFile.AtEndOfStream
strComputer = objFile.ReadLine
strRemoteFile = “\\” & strComputer & “\C$\example.vbs”
objFSO.CopyFile “C:\example.vbs”, strRemoteFile, OverwriteExisting
Loop