Showing posts with label VBSCRIPTS. Show all posts
Showing posts with label VBSCRIPTS. Show all posts

Disable services on list of servers


Below script will be useful for disabling the services

'create a file called list.Txt
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("list.Txt")
Do While Not (InputFile.atEndOfStream)
sComputer = InputFile.ReadLine
aTargetSvcs= Array("WDSServer")
'For list of services use below...
'arrTargetSvcs = Array("service1", "service2", "service3")


Set oWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!\\" _
 & sComputer & "\root\cimv2")
Set cServices = oWMIService.ExecQuery("SELECT * FROM Win32_Service")

For Each oService In cServices
 For Each sTargetSvc In aTargetSvcs
  If LCase(oService.Name) = LCase(sTargetSvc) Then
  
   If oService.State <> "Stopped" Then
    oService.StopService()   
   End If

   If oService.StartMode <> "Disabled" Then   
    oService.ChangeStartMode("Disabled")
   End If 

  End If 
 Next
Next
loop
MsgBox "Done"


 

VBscript Configure Clients Internet based Management Point Setting

on error resume next

' Create variables.
Dim newInternetBasedManagementPointFQDN
Dim client

newInternetBasedManagementPointFQDN = "mp.contoso.com"

' Create the client COM object.
Set client = CreateObject ("Microsoft.SMS.Client")

' Set the Internet-Based Management Point FQDN by calling the SetCurrentManagementPoint method.
client.SetInternetManagementPointFQDN newInternetBasedManagementPointFQDN

' Clear variables.
Set client = Nothing
Set internetBasedManagementPointFQDN = Nothing