Blog

Archive for October, 2012

Mailcleaner on Citrix Xenserver

Mailcleaner on Citrix Xenserver

How to install mailcleaner on Citrix Xenserver

Make a new VM use the Debian Squeeze 6.0 (64Bit) Set the Ram to over 1024 and what ever size HDD you need.

Select the Mailcleaner install ISO
Untick “Start the new VM automatically”
Then click finish.

Next open a console to your Xenserver.
Run xe vm-list.
Look for your uuid
uuid ( RO) : 08db9437-3e5b-7d60-4229-149671ac1d9d
name-label ( RW): Mailcleaner
power-state ( RO): halted
Next run (sub in your own uuid)

xe vm-param-set uuid=08db9437-3e5b-7d60-4229-149671ac1d9d HVM-boot-params:order=dc HVM-boot-policy=”BIOS order” PV-bootloader=””

Next start the VM. If you get a black screen just hit enter twice. ( just wait a while and if nothing happens just press enter twice again)

The installer should run through.

When its finished eject the DVD and reboot the system.

 

Once the install is finished you can install the Xentool’s by

mount /dev/cdrom /mnt

/mnt/Linux/install.sh

Reboot and your done 😉

 

 

 

 

 

Posted in: Blog, Technical

Leave a Comment (3) →

Deploy and run DeFraggler

This script will run Defraggler with the parameters of your choice.
It will also deploy it if its not already installed.

A full list of parameters can be found here – http://www.piriform.com/docs/defraggler/advanced-usage/command-line-parameters

**Update** – 24/10/2012
Hey guys,

Sorry but I forgot GFI ads a -logfile parameter at the end of scripts so I have updated it to prevent it passing to Defraggler.

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
Dim strFile
 
'Defraggler URL
strURL = "http://download.piriform.com/dfsetup211.exe"
strExecute = "dfsetup211.exe /S"
strOutput = ""
strParameters = ""
 
'Detect Arch
Set WshShell = CreateObject("WScript.Shell")
osType = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
 
If osType = "x86" Then
	strDF = "C:\Program Files\Defraggler\df.exe"
ElseIf osType = "AMD64" Then
	strDF = "C:\Program Files\Defraggler\df64.exe"
Else
	WScript.Echo "ERROR: Unknown Architechture " & osType
	WScript.Quit(2)
End If
 
'Get Run Parameters
Set objArgs = Wscript.Arguments
 
For Each strArg in objArgs
	If (strParameters = "") Then
		strParameters = strArg
	Else
		If InStr(strArg, "log") = 0 Then
			strParameters = strParameters & " " & strArg
		End if
	End If
Next
 
' Create a File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
If objFSO.Fileexists(strDF) Then
	RunDefragler
Else
	'Get Temp Folder
	strSaveTo = WScript.CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2)
 
	' Check if the specified target file or folder exists,
	' and build the fully qualified path of the target file
	If objFSO.FolderExists(strSaveTo) Then
		strFile = objFSO.BuildPath(strSaveTo, Mid(strURL, InStrRev(strURL, "/" ) + 1 ) )
	ElseIf objFSO.FolderExists(Left(strSaveTo, InStrRev(strSaveTo, "\" ) - 1 ) ) Then
		strFile = strSaveTo
	Else
		WScript.Echo "ERROR: Target folder not found."
		WScript.Quit(2)
	End If
 
	'Download Program
	WScript.Echo "Defraggler NOT FOUND"
	WScript.Echo "Downloading " & strURL & " to " & strSaveTo
	HTTPDownload strURL, strFile
 
	'Install program
	Set oCmd = CreateObject("Wscript.Shell") 
 
	commandLine = "%comspec% /c " & strSaveTo & "\" & strExecute 
	WScript.Echo "Running " & commandLine
	oCmd.Run commandLine, 0, True
 
	WScript.Echo "Defraggler Installed!"
	RunDefragler
 
	WScript.Quit(0)
 
End If
 
Sub RunDefragler()
	WScript.Echo "Running " & strDF & " " & strParameters
 
	Set oExec = WshShell.Exec(strDF & " " & strParameters)
 
	Do While oExec.Status <> 1
		WScript.Sleep 100
	Loop
 
	Do While oExec.StdOut.AtEndOfStream <> True 
		strOutput = strOutput & oExec.StdOut.ReadLine & vbcrlf
	Loop
 
	WScript.Echo strOutput
End Sub
 
Sub HTTPDownload(myURL, strFile)
 
 Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
 
 objXMLHTTP.open "GET", myURL, false
 objXMLHTTP.send()
 
 If objXMLHTTP.Status = 200 Then
 Set objADOStream = CreateObject("ADODB.Stream")
 objADOStream.Open
 objADOStream.Type = 1 'adTypeBinary

 objADOStream.Write objXMLHTTP.ResponseBody
 objADOStream.Position = 0 'Set the stream position to the start

 objADOStream.SaveToFile strFile
 objADOStream.Close
 Set objADOStream = Nothing
 End if
 
 Set objXMLHTTP = Nothing
End Sub

Posted in: Blog, Scripts

Leave a Comment (6) →

Exchange Queue Length Check

Heres a script to check the queue length in exchange.
Just modify the $Threshold from 10 to whatever you desire.

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
$snapinversion = 0;
 foreach ( $snap in get-pssnapin -registered)
 {
     if ( $snap.Name -eq 'Microsoft.Exchange.Management.Powershell.Admin' )
     {
         $snapinversion = 2007;
         Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -ErrorAction SilentlyContinue
 
     }
     if ( $snap.Name -eq 'Microsoft.Exchange.Management.Powershell.Support' )
     {
         $snapinversion = 2010;
         Add-PSSnapin Microsoft.Exchange.Management.Powershell.Setup -ErrorAction SilentlyContinue
         Add-PSSnapin Microsoft.Exchange.Management.Powershell.Support -ErrorAction SilentlyContinue
         Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010 -ErrorAction SilentlyContinue
     }
 }
 
 if($snapinversion -eq 0)
 {
     Write-Host "Exchange Powershell Snapin missing";
     Exit 1003;
 }
 $Threshold = 10
 $MessageCount = Get-ExchangeServer | Where { $_.isHubTransportServer -eq $true } | get-queue |  foreach -begin {$total=0} -process {$total+=$_.messageCount} -end {$total}
 if ($MessageCount -gt $Threshold)
 {
 Write-Host "Warning: $MessageCount Emails in Queue.";
 Exit 1010
 } Else {
 Write-Host "$MessageCount/$Threshold Emails in Queue.";
 Exit 0
 }

Posted in: Scripts, Technical

Leave a Comment (2) →

Xenserver Missing Removable storage Drives

Some times when USB drives have been plugged in for a long time they seems to disappear. Normally that’s not a problem you just unplug them and plug them back in. When the USB drive is in a Data center that’s a long way to drive just to unplug a drive and plug it back in.

For Xenserver try

modprobe -r usb_storage

Unplugs all USB storage from the server

modprobe usb_storage

Plugs it back in. Normally a re scan on the Removable storage put everything back right.

 

Posted in: Blog, Technical

Leave a Comment (0) →

Update Managed Antivirus

Here is a script that Updates MAV and resends the DSC information if required.

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
Dim WshShell, oExec, OsType, FSO, bResendDSC, MAVPath, AgentPath
 Set WshShell = CreateObject("WScript.Shell")
 Set FSO = CreateObject("Scripting.FileSystemObject")
 
 OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
 
 If OsType = "x86" then
     AgentPath = "C:\Program Files\"
 elseif OsType = "AMD64" then
     AgentPath = "C:\Program Files (x86)\"
 end if
 
 If FSO.FolderExists(AgentPath & "Advanced Monitoring Agent") Then
     AgentPath = AgentPath & "Advanced Monitoring Agent"
 ElseIf FSO.FolderExists(AgentPath & "Advanced Monitoring Agent GP") Then
     AgentPath = AgentPath & "Advanced Monitoring Agent GP"
 Else
     wscript.Echo "Agent Folder Not Found."
 End If
 
 MAVPath = Chr(34) & AgentPath & "\managedav\SBAMCommandLineScanner.exe" & Chr(34) & " /updatedefs"
 AgentPath = Chr(34) & AgentPath & "\winagent.exe" & Chr(34)
 
 bResendDSC = True
 Set oExec = WshShell.Exec(MAVPath)
 
 Do While oExec.Status <> 1
     WScript.Sleep 100
 Loop
 
 Do While oExec.StdOut.AtEndOfStream <> True 
     If oExec.StdOut.ReadLine = "DONE:Update not needed" Then
         bResendDSC = False
     End If
 Loop
 
 If bResendDSC = True Then 
     RestartDSC
     wscript.Echo "Updating MAV and resending DSC"
 Else
     wscript.Echo "MAV is up to date"
 End If
 
 Sub RestartDSC()
     'Stop agent Service
     Set oExec = WshShell.Exec(AgentPath & " /stopservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Reset DSC Counter
     Set oExec = WshShell.Exec(AgentPath & " /testreset")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 
     'Restart Service
     Set oExec = WshShell.Exec(AgentPath & " /startservice")
 
     Do While oExec.Status <> 1
         WScript.Sleep 100
     Loop
 End Sub

Posted in: Scripts, Technical

Leave a Comment (3) →

Restart PC if pending reboot

This script checks if there is any rename operations pending or updates pending and initiates a restart of the computer if required.
By running this on demand you can ensure that computers are rebooted only if required,minimizing the effects on users and maximising up time.

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
Dim strComputer
Dim strKeyPath
Dim strValueName
Dim strValue
Dim arrValues
Dim bReboot
Dim oReg
Dim objSysInfo
dim objShell
 
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_MULTI_SZ = 7
strComputer = "."
bReboot = False
 
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager"
strValueName = "PendingFileRenameOperations"
oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrValues
 
If Not IsNull(arrValues) Then
  For Each strValue In arrValues
'Pending Rename operations found, reboot
      bReboot = True
      Exit For
  Next
Else
	'No Pending Rename operations
End If
 
'Only Check for update reboots if we need to
If bReboot = False Then
	Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
	bReboot = objSysInfo.RebootRequired
End If
 
If bReboot = True then
	strCmd = "shutdown -r -t 120 -f /c " & chr(34) & "A system reboot has been initiated, please save all your work." & chr(34)
 
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run strCmd, 0, false 
End If
 
objSysInfo = Nothing
objShell = Nothing

Posted in: Scripts, Technical

Leave a Comment (0) →

Teamviewer Settings

Here is a script that will change TeamViewer settings to disable HTTP, Activates DirectIn to stop the dialog, prevents shutdown and stops it from checking for updates.

1
2
3
4
5
6
7
Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version7]
"ListenHttp"=dword:00000000
"Security_ActivateDirectIn"=dword:00000001
"Security_Disableshutdown"=dword:00000001
"UpdateCheckInterval"=dword:00000002

Posted in: Scripts, Technical

Leave a Comment (0) →

Rename Computer

Here is a script to rename the computer
Make sure you add /NewName:YourNewComputerName in the script parameters and obviously change it for your naming.
Also note that each computer requires a unique name on the network to prevent conflicts so ensure the new name is unique.

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
strComputerName = WScript.Arguments.Named("NewName")
 
If strComputerName <> "" then
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2")
Set colComputers = objWMIService.ExecQuery ("Select Name from Win32_ComputerSystem")
 
For Each objComputer in colComputers
    wscript.echo "Old Computer Name: " & objComputer.Name
    wscript.echo "New Computer Name: " & strNewName
 
    If objComputer.Name <> strNewName Then
 
       ' rename this computer

       intErrorCode = objComputer.Rename(strComputerName)
       ' now reboot
       Reboot
    End if
Next
Else
wscript.echo "Please define a computer name!"
End If
Sub Reboot()
 
dim strComputer, objWMIService, colOS, objOS
  strComputer = "."
 
  Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
  Set colOS = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
 
  For Each objOS in colOS
                objOS.Reboot()
  Next
End Sub

Posted in: Scripts, Technical

Leave a Comment (2) →
Page 1 of 2 12