All posts by npulis

Fix: Slave server not connecting to master on Yosemite Server Backup

When you install Yosemite Backup solution on a server having multiple network cards, the agents will not work and the server will not be visible by the master server. This is because Yosemite binds itself to a network card. Now, to fix this, simply edit the ytconfig.ini in the Yosemite folder and add the following line under the configuration tab and set it to your the IP address of the network card:

bindTo=10.1.1.1

(822)

How To: List all software installed on a machine with VBScript

This VBScript will list all the software installed on the computername you specify in the first line of code. Simply save the code below in a .vbs file and execute it by running it as:

CSCRIPT.EXE /NOLOGO myscript.vbs >logfile.txt

This will give you a nice text file with all the applications installed on the specified computer.

strComputer = "mycomputername"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")'
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")

WScript.Echo "Installed Software List and OS Information"
WScript.Echo "=========================================="
Wscript.Echo ""

'Computer Information'
Wscript.Echo "COMPUTER INFORMATION"
Wscript.Echo "===================="
Wscript.Echo "Computer Name: " & strComputer
For Each objOperatingSystem in colSettings
'Crop Operating system name for clean name'
Result = InStr(objOperatingSystem.Name, "|")
Result = Result -1
MyString = Left(objOperatingSystem.Name,Result)
'Echo stuff
Wscript.Echo "Operating System: " & MyString
Wscript.Echo "Service Pack: " & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion
Wscript.Echo "Installed In: " & objOperatingSystem.WindowsDirectory
Wscript.Echo ""
Next

'Software Information'
Wscript.Echo "SOFTWARE LIST"
Wscript.Echo "============="
For Each objSoftware in colSoftware
wscript.echo objSoftware.Caption
Next

(20601)

How To: Send email with embedded text file as body with VBScript

This is an easy VBScript that will allow you to send notifications by mail. Thou applications like SQL have the Database mail, if you have log files which you need to send a text log file from an application as a notification.

Just change the basic email information to your likings and the Mail Server configuration. If it’s an open SMTP server leave the MailSendUsername and MailSendPassword empty. To embed a text file in the body, change the Logfile.txt entry to your filename. Save the below code as anything.vbs and run it as a scheduled task.

Dim objEmail
Set objEmail = CreateObject("CDO.Message")

'************************************
'** Seting basic email information **
'************************************
Const EmailFrom = """My server notification"" "
Const EmailTo = "myboss@myserver.com,myself@myserver.com"
Const EmailSubject = "My Notification"

'***************************************
'** Setting Mail Server Configuration **
'***************************************
Const MailSendUsing = "2"
Const MailSendServer = "smtp.myserver.com"
Const MailSendPort = "25"
Const MailSendUsername = "noreply@myserver.com"
Const MailSendPassword = "mypassword"
Const MailSendAuthenticationType = "1"

'**************************************
'** Email Parameters (DO NOT CHANGE) **
'**************************************
objEmail.From = EmailFrom
objEmail.To = EmailTo
objEmail.Subject = EmailSubject
objEmail.Textbody = EmailBody
objEmail.AddAttachment EmailAttachments
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = MailSendUsing
ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailSendServer
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailSendPort
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = MailSendAuthenticationType
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = MailSendUsername
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MailSendPassword

'*******************************************************
'** Setting a text file to be shown in the email Body **
'*******************************************************
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'** File to be inserted in Body
Const FileToBeUsed = "Logfile.txt"
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
'** Open the file for reading
Set f = fso.OpenTextFile(FileToBeUsed, ForReading)
'** The ReadAll method reads the entire file into the variable BodyText
objEmail.Textbody = f.ReadAll
'** Close the file
f.Close
'** Clear variables
Set f = Nothing
Set fso = Nothing

'* cdoSendUsingPickup (1)
'* cdoSendUsingPort (2)
'* cdoSendUsingExchange (3)

'********************************
'** Parameters (DO NOT CHANGE) **
'********************************
ObjEmail.Configuration.Fields.Update
objEmail.Send

(18801)

How To: Automated shrink transaction logs in SQL

Making a scheduled automated shrink logs for the databases with specific space to shrink.

DECLARE @Step1 VARCHAR(200)
DECLARE @Name varchar(50)

DECLARE DBNames CURSOR
FOR
SELECT NAME FROM sysdatabases WHERE dbid > 4
OPEN DBNames

FETCH NEXT FROM DBNames INTO @Name WHILE (@@FETCH_STATUS <> -1)

BEGIN

SET @Step1 = 'USE ' + @Name + '' + CHAR(10)
SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY SIMPLE;' + CHAR(10)
SET @Step1 = @Step1 + 'DBCC SHRINKFILE (' +@Name + '_LOG, 500);' + CHAR(10)
SET @Step1 = @Step1 + 'ALTER DATABASE [' + @Name + '] SET RECOVERY FULL;' + CHAR(10)

EXEC (@Step1)

FETCH NEXT FROM DBNames INTO @Name
END

CLOSE DBNames
DEALLOCATE DBNames

(54858)