Blog

Archive for January, 2013

Configure IIS to listen on specific IPs

By default IIS will listen for connections on port 80 for any IP bound to the server. This happens even if there are no host headers or bindings set for a specific IP. This can be a problem when trying to run multiple web servers on port 80.

To set IIS to listen on specific IPs follow the instructions below.

Windows Server 2003/IIS 6:

1. This requires the Server 2003 support tools. If this is not already installed it can be downloaded here.

2. Once installed open a command prompt and navigate to the support tools installation folder (default is C:\Program Files\Support Tools).
cd C:\Program Files\Support Tools

3. Stop http.
net stop http /y

4. Use this command to display the current list of IPs:
httpcfg query iplisten

5. By default it will listen on all IPs (0.0.0.0) so we can remove this.
httpcfg delete iplisten -i 0.0.0.0

6. Specify the IP(s) that IIS should listen on. Make sure to update 127.0.0.1 to the desired IP and run the command for each IP IIS should listen on.
httpcfg set iplisten -i 127.0.0.1

7. Start http and test out your sites.
net start http

Windows Server 2008/IIS 7:

1. Open a command prompt and type “netsh”.
netsh

2. Type “http”.
http

3. Enter the following command to display the current list of IPs to listen on. Note if no IPs are displayed like in the below image, IIS will listen on all IPs (default).
show iplisten

4. Use the command below to set IIS to listen on a specific IP. Make sure to replace 127.0.0.1 with the correct IP and run the command again for any additional addresses.
add iplisten ipaddress=127.0.0.1

5. In case you need to delete an IP from this list, use the following command.
delete iplisten ipaddress=127.0.0.1

6. Restart IIS to apply these changes.
iisreset

 

source http://toastergremlin.com/?p=320

Posted in: Blog, Technical

Leave a Comment (0) →

Install Microsoft and Windows Updates

A lot of scripts out there only install windows updates, this one gets the lot.
I’ve found that there are a number of patches not included in the LanGuard patch management, so here’s a script to fill in the gaps.

This script is a modified version of the one found here – blogs.technet.com/b/chrad/archive/2009/07/13/dynamic-provisioning-with-vmm-proxy-windows-updates-and-scripts.aspx

Also just added the ability to skip updates.
So if you don’t want the bing bar or windows search or any other update, just put add the name to the array. (Should also work with Most KB Numbers)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
Const ssDefault = 0
 Const ssManagedServer = 1 
 Const ssOthers = 3 'Microsoft Updates
 Const ssWindowsUpdate = 2 'Windows Updates
 'Array of updates to skip. 
 SkipUpdates = Array("bing","windows live","windows search")
 '#############################
 ' Create Session
 '#############################
 Set UpdateSession = CreateObject("Microsoft.Update.Session")
 Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
 '#############################
 ' Register Microsoft Update
 '#############################
 RegisterMu
 updateSearcher.ServerSelection = ssOthers '<==== **** CHANGE THIS TO YOUR PREFERENCE ****
 updateSearcher.ServiceID = "7971f918-a847-4430-9279-4a52d1efe18d"
 '#############################
 ' Create List of Updates to Download
 '#############################
 Set UpdatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
 '#############################
 ' Search for Updates
 '#############################
 Set SearchResult = UpdateSearcher.Search("Isinstalled=0")
 '#############################
 ' Quit if No Updates Found
 '#############################
 If SearchResult.Updates.Count = 0 Then
     WScript.Echo "No updates found."
 WScript.Quit
 End If
 Dim strSpacer
 For I = 0 To SearchResult.Updates.Count-1
     Set Update = SearchResult.Updates.Item(I)
 
     ' formatting helper
     If I < 10 Then
         strSpacer = " "
     Else
         strSpacer = ""
     End If
 
     'Check updates to skip
 bSkip = false
 For Each Name in SkipUpdates
 If Instr(LCase(update.Title), LCase(Name)) > 0 Then
 bSkip = True
 Exit For
 End if
 Next
 If bSkip = True Then
 WScript.Echo "Skipping update " & update.Title
 Else
 'WScript.Echo "[" & strSpacer & I & "]  Found Update, Marking For Download:  " & update.Title
 UpdatesToDownload.Add(Update)
 End if 
 
 Next
 '#############################
 ' Download Updates
 '#############################
 Set Downloader = UpdateSession.CreateUpdateDownloader()
 Downloader.Updates = UpdatesToDownload
 On Error Resume Next
 Downloader.Download()
 If Err.number <> 0 Then
     Wscript.Echo "An error occurred in  Downloader.Download() of updates"
     Wscript.Echo "Number: " & err.number
     Wscript.Echo "Description:  " & err.Description
     Wscript.Quit (Err.number)
 End If
 On Error Goto 0
 '#############################
 ' Create List of Updates to Install
 '#############################
 Set UpdatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
 For I = 0 To SearchResult.Updates.Count-1
     set Update = SearchResult.Updates.Item(I)
     If Update.IsDownloaded = true Then
         UpdatesToInstall.Add(Update)
     End If
 Next
 '#############################
 ' Install Updates
 '#############################
 Set Installer = UpdateSession.CreateUpdateInstaller()
 Installer.Updates = UpdatesToInstall
 Set InstallationResult = Installer.Install()
 wscript.Echo "Installation Result: " & InstallationResult.ResultCode
 wscript.Echo "Reboot Required: " & InstallationResult.RebootRequired
 wscript.Echo "Listing of updates installed and individual installation results:"
 
     For I = 0 to UpdatesToInstall.Count - 1
         WScript.Echo I + 1 & "> " & Chr(9) & UpdatesToInstall.Item(I).Title & Chr(9) & ": " & TranslateMuCode(InstallationResult.GetUpdateResult(i).ResultCode)
     Next
 '#############################
 ' Quit
 '#############################
 WScript.Quit
 '================================================================================
 ' Translate Microsoft Update Installation Results
 '================================================================================
 Function TranslateMuCode(theCode)
   TranslateMuCode = "[" & theCode & "] "
   if (theCode = 0) Then TranslateMuCode = TranslateMuCode & "Not Started"
   if (theCode = 1) Then TranslateMuCode = TranslateMuCode & "In Progress"
   if (theCode = 2) Then TranslateMuCode = TranslateMuCode & "Succeeded"
   if (theCode = 3) Then TranslateMuCode = TranslateMuCode & "Succeeded with Errors"
   if (theCode = 4) Then TranslateMuCode = TranslateMuCode & "Failed"
   if (theCode = 5) Then TranslateMuCode = TranslateMuCode & "Aborted"
 End Function
 '================================================================================
 ' Register Microsoft Update (if never registered)
 '================================================================================
 Function RegisterMu
     Dim fso
     Dim file
     Dim WshShell
     Dim updateService
     Dim updateServiceManager
 
     found = false
 
     Set fso = CreateObject("Scripting.FileSystemObject")    
     Set WshShell = WScript.CreateObject ("WScript.Shell")
 
     Set updateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
     Set updateService = updateServiceManager.Services
 
     If err <> 0 Then
         WScript.Echo "CreateObject(Microsoft.Update.ServiceManager) failed with error 0x" & Hex(err.Number)  & err.Description
         WScript.Quit(2)
     End If
     For I=0 to updateService.Count - 1
         Set item = updateService.Item(i)
         If item.ServiceID = "7971f918-a847-4430-9279-4a52d1efe18d" Then
             found = true
         End IF
     Next    
 
     IF found = false Then
         updateServiceManager.AddService2 "7971f918-a847-4430-9279-4a52d1efe18d", 2, ""
 
         If err <> 0 Then
             WScript.Echo "updateServiceManager.AddService() failed with error 0x" & Hex(err.Number) & err.Description
         Else
             WScript.Echo "MU is registered with WU Agent"
         End IF
     End IF
 END Function

Posted in: Scripts, Technical

Leave a Comment (3) →

Detect Internet Explorer Version

Someone requested how to determine what version of IE (internet explorer) was installed on a machine.
The version registry entry was unreliable so this gets the version straight from the executable.

1
2
3
4
5
6
7
8
9
10
11
12
13
strComputer = "."
 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
sQuery="select * from cim_datafile where path=""\\Program Files\\Internet Explorer\\"" and filename=""iexplore"" and extension=""exe"""
set col=objWMIService.execquery(sQuery)
 
for each obj in col
    wscript.echo obj.version
next
 
set col = Nothing
Set objWMIService = Nothing

Posted in: Scripts

Leave a Comment (0) →