Sunday, November 26, 2017

How to get Elastix and OS version


[root@VsrvElastix ~]# cat /etc/*-release
CentOS release 5.10 (Final)
[root@VsrvElastix ~]# rpm -qa elastix
elastix-2.4.0-8

Tuesday, October 17, 2017

How to get All jobs with details from SQL Server

Use Master;
SELECT     [JobName] = [jobs].[name]
        ,[Category] = [categories].[name]
        ,[Owner] = SUSER_SNAME([jobs].[owner_sid])
        ,[Enabled] = CASE [jobs].[enabled] WHEN 1 THEN 'Yes' ELSE 'No' END
        ,[Scheduled] = CASE [schedule].[enabled] WHEN 1 THEN 'Yes' ELSE 'No' END
        ,[Description] = [jobs].[description]
        ,[Occurs] =
                CASE [schedule].[freq_type]
                    WHEN   1 THEN 'Once'
                    WHEN   4 THEN 'Daily'
                    WHEN   8 THEN 'Weekly'
                    WHEN  16 THEN 'Monthly'
                    WHEN  32 THEN 'Monthly relative'
                    WHEN  64 THEN 'When SQL Server Agent starts'
                    WHEN 128 THEN 'Start whenever the CPU(s) become idle'
                    ELSE ''
                END
        ,[Occurs_detail] =
                CASE [schedule].[freq_type]
                    WHEN   1 THEN 'O'
                    WHEN   4 THEN 'Every ' + CONVERT(VARCHAR, [schedule].[freq_interval]) + ' day(s)'
                    WHEN   8 THEN 'Every ' + CONVERT(VARCHAR, [schedule].[freq_recurrence_factor]) + ' weeks(s) on ' +
                        LEFT(
                            CASE WHEN [schedule].[freq_interval] &  1 =  1 THEN 'Sunday, '    ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] &  2 =  2 THEN 'Monday, '    ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] &  4 =  4 THEN 'Tuesday, '   ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] &  8 =  8 THEN 'Wednesday, ' ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] & 16 = 16 THEN 'Thursday, '  ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] & 32 = 32 THEN 'Friday, '    ELSE '' END +
                            CASE WHEN [schedule].[freq_interval] & 64 = 64 THEN 'Saturday, '  ELSE '' END ,
                            LEN(
                                CASE WHEN [schedule].[freq_interval] &  1 =  1 THEN 'Sunday, '    ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] &  2 =  2 THEN 'Monday, '    ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] &  4 =  4 THEN 'Tuesday, '   ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] &  8 =  8 THEN 'Wednesday, ' ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] & 16 = 16 THEN 'Thursday, '  ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] & 32 = 32 THEN 'Friday, '    ELSE '' END +
                                CASE WHEN [schedule].[freq_interval] & 64 = 64 THEN 'Saturday, '  ELSE '' END
                            ) - 1
                        )
                    WHEN  16 THEN 'Day ' + CONVERT(VARCHAR, [schedule].[freq_interval]) + ' of every ' + CONVERT(VARCHAR, [schedule].[freq_recurrence_factor]) + ' month(s)'
                    WHEN  32 THEN 'The ' +
                            CASE [schedule].[freq_relative_interval]
                                WHEN  1 THEN 'First'
                                WHEN  2 THEN 'Second'
                                WHEN  4 THEN 'Third'
                                WHEN  8 THEN 'Fourth'
                                WHEN 16 THEN 'Last'
                            END +
                            CASE [schedule].[freq_interval]
                                WHEN  1 THEN ' Sunday'
                                WHEN  2 THEN ' Monday'
                                WHEN  3 THEN ' Tuesday'
                                WHEN  4 THEN ' Wednesday'
                                WHEN  5 THEN ' Thursday'
                                WHEN  6 THEN ' Friday'
                                WHEN  7 THEN ' Saturday'
                                WHEN  8 THEN ' Day'
                                WHEN  9 THEN ' Weekday'
                                WHEN 10 THEN ' Weekend Day'
                            END + ' of every ' + CONVERT(VARCHAR, [schedule].[freq_recurrence_factor]) + ' month(s)'
                    ELSE ''
                END
        ,[Frequency] =
                CASE [schedule].[freq_subday_type]
                    WHEN 1 THEN 'Occurs once at ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_start_time]), 6), 5, 0, ':'), 3, 0, ':')
                    WHEN 2 THEN 'Occurs every ' +
                                CONVERT(VARCHAR, [schedule].[freq_subday_interval]) + ' Seconds(s) between ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_start_time]), 6), 5, 0, ':'), 3, 0, ':') + ' and ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_end_time]), 6), 5, 0, ':'), 3, 0, ':')
                    WHEN 4 THEN 'Occurs every ' +
                                CONVERT(VARCHAR, [schedule].[freq_subday_interval]) + ' Minute(s) between ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_start_time]), 6), 5, 0, ':'), 3, 0, ':') + ' and ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_end_time]), 6), 5, 0, ':'), 3, 0, ':')
                    WHEN 8 THEN 'Occurs every ' +
                                CONVERT(VARCHAR, [schedule].[freq_subday_interval]) + ' Hour(s) between ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_start_time]), 6), 5, 0, ':'), 3, 0, ':') + ' and ' +
                                STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [schedule].[active_end_time]), 6), 5, 0, ':'), 3, 0, ':')
                    ELSE ''
                END
        ,[AvgDurationInSec] = CONVERT(DECIMAL(18, 2), [jobhistory].[AvgDuration])
        ,[Next_Run_Date] =
                CASE [jobschedule].[next_run_date]
                    WHEN 0 THEN CONVERT(DATETIME, '1900/1/1')
                    ELSE CONVERT(DATETIME, CONVERT(CHAR(8), [jobschedule].[next_run_date], 112) + ' ' +
                         STUFF(STUFF(RIGHT('000000' + CONVERT(VARCHAR(8), [jobschedule].[next_run_time]), 6), 5, 0, ':'), 3, 0, ':'))
                END
FROM     [msdb].[dbo].[sysjobs] AS [jobs] WITh(NOLOCK)
         LEFT OUTER JOIN [msdb].[dbo].[sysjobschedules] AS [jobschedule] WITh(NOLOCK)
                 ON [jobs].[job_id] = [jobschedule].[job_id]
         LEFT OUTER JOIN [msdb].[dbo].[sysschedules] AS [schedule] WITh(NOLOCK)
                 ON [jobschedule].[schedule_id] = [schedule].[schedule_id]
         INNER JOIN [msdb].[dbo].[syscategories] [categories] WITh(NOLOCK)
                 ON [jobs].[category_id] = [categories].[category_id]
         LEFT OUTER JOIN
                    (    SELECT     [job_id], [AvgDuration] = (SUM((([run_duration] / 10000 * 3600) +
                                                                (([run_duration] % 10000) / 100 * 60) +
                                                                 ([run_duration] % 10000) % 100)) * 1.0) / COUNT([job_id])
                        FROM     [msdb].[dbo].[sysjobhistory] WITh(NOLOCK)
                        WHERE     [step_id] = 0
                        GROUP BY [job_id]
                     ) AS [jobhistory]
                 ON [jobhistory].[job_id] = [jobs].[job_id]
where [jobs].[enabled]=1
GO

SQL Server Comand Line



Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\administrator.ULC>sqlcmd -S Server_name -d master -A
1> drop trigger block_ipaddress ON ALL SERVER
2> GO
1> drop trigger block_ipaddress ON ALL SERVER
2> go
1>

Sunday, September 17, 2017

Remote computer shutdown or Restart





To restart or shut down a remote computer and document the reason using the command line

Click Start, click All Programs, click Accessories, and click Command Prompt.
ping computer name or IP
if reply
Type shutdown /[r|s] /m \\ComputerName /force
          For Restart:
         shutdown /r /m \\ComputerName /force
  1. For Shutdown :


    shutdown /s /m \\ComputerName /force

    ping computer name or IP
    if time out then Okay
     

Wednesday, May 3, 2017

how to restart Sql service using Batch File


1.Open a new text file from notepad. type the following commands in the text file
2.Save the file as RestartSql.bat on to your desktop
3.whenever you want to restart your Sql Service...just double click the RestartSql.bat on ur desktop

********************************************************************************

net stop "SQL Server Agent (MSSQLSERVER)"
net stop MSSQLSERVER
net start MSSQLSERVER
net start "SQL Server Agent (MSSQLSERVER)"

*******************************************************************************

How to Restart IIS Using Batch file




1.Open a new text file from notepad. type the following commands in the text file
2.Save the file as RestartIIS.bat on to your desktop
3.whenever you want to restart your IIS...just double click the RestartIIS.bat on ur desktop

*******************************************************************************
net stop w3svc
net stop iisadmin
net start iisadmin
net start w3svc
*******************************************************************************
 
 

Sunday, April 30, 2017

How to Server role and Database Role from SQl server

Run the script under Master Database

**************************************************************************
select
[Login Type]=
case sp.type
when 'u' then 'WIN'
when 's' then 'SQL'
when 'g' then 'GRP'
end,
convert(char(45),sp.name) as srvLogin,
convert(char(45),sp2.name) as srvRole,
convert(char(25),dbp.name) as dbUser,
convert(char(25),dbp2.name) as dbRole
from
sys.server_principals as sp join
sys.database_principals as dbp on sp.sid=dbp.sid join
sys.database_role_members as dbrm on dbp.principal_Id=dbrm.member_principal_Id join
sys.database_principals as dbp2 on dbrm.role_principal_id=dbp2.principal_id left join
sys.server_role_members as srm on sp.principal_id=srm.member_principal_id left join
sys.server_principals as sp2 on srm.role_principal_id=sp2.principal_id

*********************************************************************



Exciting 6 Android Marshmallow Features

How to get user roles from SQl Server



*****************************************
SELECT p.NAME,m.NAME
FROM sys.database_role_members rm
JOIN sys.database_principals p
ON rm.role_principal_id = p.principal_id
JOIN sys.database_principals m
ON rm.member_principal_id = m.principal_id
********************************************

SQL Server: How to get login IDs' Server Roles




Returns the names and id's of the roles and their members

SELECT sys.server_role_members.role_principal_id, role.name AS RoleName,   
    sys.server_role_members.member_principal_id, member.name AS MemberName  
FROM sys.server_role_members  
JOIN sys.server_principals AS role  
    ON sys.server_role_members.role_principal_id = role.principal_id  
JOIN sys.server_principals AS member  
    ON sys.server_role_members.member_principal_id = member.principal_id; 
 
 
 
 
 
 
Fixed server-level role

Description
sysadmin Members of the sysadmin fixed server role can perform any activity in the server.
serveradmin Members of the serveradmin fixed server role can change server-wide configuration options and shut down the server.
securityadmin Members of the securityadmin fixed server role manage logins and their properties. They can GRANT, DENY, and REVOKE server-level permissions. They can also GRANT, DENY, and REVOKE database-level permissions if they have access to a database. Additionally, they can reset passwords for SQL Server logins.

** Security Note *\* The ability to grant access to the Database Engine and to configure user permissions allows the security admin to assign most server permissions. The securityadmin role should be treated as equivalent to the sysadmin role.
processadmin Members of the processadmin fixed server role can end processes that are running in an instance of SQL Server.
setupadmin Members of the setupadmin fixed server role can add and remove linked servers by using Transact-SQL statements. (sysadmin membership is needed when using Management Studio.)
bulkadmin Members of the bulkadmin fixed server role can run the BULK INSERT statement.
diskadmin The diskadmin fixed server role is used for managing disk files.
dbcreator Members of the dbcreator fixed server role can create, alter, drop, and restore any database.
public Every SQL Server login belongs to the public server role. When a server principal has not been granted or denied specific permissions on a securable object, the user inherits the permissions granted to public on that object. Only assign public permissions on any object when you want the object to be available to all users. You cannot change membership in public.

Note: public is implemented differently than other roles. However, permissions can be granted, denied, or revoked from public.
 

Thursday, April 20, 2017

How to block IPs to connect to Database Server


After Running this query one trigger and one table will be created.
Trigger Name : block_ipaddress
Table Name: IPBLock
The add ip addresses which are needed to block.


********************************************************************************

USE [master]
GO
/****** Object:  Table [dbo].[IPBLock]    Script Date: 04/20/2017 13:43:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[IPBLock](
    [ipaddress] [varchar](15) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

/****** Object:  DdlTrigger [block_ipaddress]    Script Date: 04/19/2017 20:24:57 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TRIGGER [block_ipaddress]
ON ALL SERVER
FOR LOGON
AS
BEGIN
            DECLARE @capturedip NVARCHAR(15);
            SET @capturedip = (SELECT EVENTDATA().value('(/EVENT_INSTANCE/ClientHost)[1]', 'NVARCHAR(15)'));
            IF EXISTS(SELECT ipaddress FROM master.dbo.IPBLock WHERE ipaddress = @capturedip)
            BEGIN
                        Print 'Your IP Address is blocked, Contact Administrator'
                        ROLLBACK
            END
            ELSE
            BEGIN
                        DECLARE @IPRange VARCHAR(15)
                        SELECT @IPRange= SUBSTRING(@capturedip,1,LEN(@capturedip)-CHARINDEX('.',REVERSE(@capturedip)))+'.*'
                        IF EXISTS(SELECT ipaddress FROM master.dbo.IPBLock WHERE ipaddress = @IPRange)
                        BEGIN
                            Print 'Your IP Address Range is blocked, Contact Administrator'
                            ROLLBACK
                        END
            END
END

GO

SET ANSI_NULLS OFF
GO

SET QUOTED_IDENTIFIER OFF
GO

ENABLE TRIGGER [block_ipaddress] ON ALL SERVER
GO

*********************************************************************************

Saturday, April 8, 2017

User Lync Server Control Panel returns that error "Insufficient access rights to perform the operation"



"Insufficient Access Rights" error when modifying/removing Lync:


1. Open Active Directory Users and Computers
2. In ADUC, make sure "Advanced Features" is turned on in the view menu
3.Open the user account Properties
4.On the Security Tab, Click the Advanced button
5. Enable Inheritance
6. Click OK.
7. Then go to Lync server Control Panel and try to edit or delete.

Should be solved. 

Wednesday, April 5, 2017

What is SMTP





SMTP
SMTP stands for Simple Mail Transfer Protocol and used to sending email messages between different email servers. SMTP is reliable and efficient way to transfer email. Today mostly email systems used SMTP to transfer their email on the Internet and the POP (Post Office Protocol) or IMAP (Internet Message Access Protocol) protocol is used for retrieved email at client end.

How to Transfer FSMO Roles Windows Server 2003.



This article describes how to transfer Flexible Single Master Operations (FSMO) roles (also known as operations master roles) by using the Active Directory snap-in tools in Microsoft Management Console (MMC) in Windows Server 2003.
FSMO Roles
In a forest, there are at least five FSMO roles that are assigned to one or more domain controllers. The five FSMO roles are:
·         Schema Master: The schema master domain controller controls all updates and modifications to the schema. To update the schema of a forest, you must have access to the schema master. There can be only one schema master in the whole forest.
·         Domain naming master: The domain naming master domain controller controls the addition or removal of domains in the forest. There can be only one domain naming master in the whole forest.
·         Infrastructure Master: The infrastructure is responsible for updating references from objects in its domain to objects in other domains. At any one time, there can be only one domain controller acting as the infrastructure master in each domain.
·         Relative ID (RID) Master: The RID master is responsible for processing RID pool requests from all domain controllers in a particular domain. At any one time, there can be only one domain controller acting as the RID master in the domain.
·         PDC Emulator: The PDC emulator is a domain controller that advertises itself as the primary domain controller (PDC) to workstations, member servers, and domain controllers that are running earlier versions of Windows. For example, if the domain contains computers that are not running Microsoft Windows XP Professional or Microsoft Windows 2000 client software, or if it contains Microsoft Windows NT backup domain controllers, the PDC emulator master acts as a Windows NT PDC. It is also the Domain Master Browser, and it handles password discrepancies. At any one time, there can be only one domain controller acting as the PDC emulator master in each domain in the forest.
You can transfer FSMO roles by using the Ntdsutil.exe command-line utility or by using an MMC snap-in tool. Depending on the FSMO role that you want to transfer, you can use one of the following three MMC snap-in tools:
Active Directory Schema snap-in
Active Directory Domains and Trusts snap-in
Active Directory Users and Computers snap-in
If a computer no longer exists, the role must be seized. To seize a role, use the Ntdsutil.exe utility.

For additional information about how to use the Ntdsutil.exe utility to seize FSMO roles, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/255504/ ) Using Ntdsutil.exe to Seize or Transfer the FSMO Roles to a Domain
Transfer the Schema Master Role
Use the Active Directory Schema Master snap-in to transfer the schema master role. Before you can use this snap-in, you must register the Schmmgmt.dll file.
Register Schmmgmt.dll
1.     Click Start, and then click Run.
2.     Type regsvr32 schmmgmt.dll in the Open box, and then click OK.
3.     Click OK when you receive the message that the operation succeeded.
Transfer the Schema Master Role
1.     Click Start, click Run, type mmc in the Open box, and then click OK.
2.     On the File, menu click Add/Remove Snap-in.
3.     Click Add.
4.     Click Active Directory Schema, click Add, click Close, and then click OK.
5.     In the console tree, right-click Active Directory Schema, and then click Change Domain Controller.
6.     Click Specify Name, type the name of the domain controller that will be the new role holder, and then click OK.
7.     In the console tree, right-click Active Directory Schema, and then click Operations Master.
8.     Click Change.
9.     Click OK to confirm that you want to transfer the role, and then click Close.
Transfer the Domain Naming Master Role
1.     Click Start, point to Administrative Tools, and then click Active Directory Domains and Trusts.
2.     Right-click Active Directory Domains and Trusts, and then click Connect to Domain Controller.
NOTE: You must perform this step if you are not on the domain controller to which you want to transfer the role. You do not have to perform this step if you are already connected to the domain controller whose role you want to transfer.

3.     Do one of the following:
o    In the Enter the name of another domain controller box, type the name of the domain controller that will be the new role holder, and then click OK.

-or-
o    In the Or, select an available domain controller list, click the domain controller that will be the new role holder, and then click OK.
4.     In the console tree, right-click Active Directory Domains and Trusts, and then click Operations Master.
5.     Click Change.
6.     Click OK to confirm that you want to transfer the role, and then click Close.
Transfer the RID Master, PDC Emulator, and Infrastructure Master Roles
1.     Click Start, point to Administrative Tools, and then click Active Directory Users and Computers.
2.     Right-click Active Directory Users and Computers, and then click Connect to Domain Controller.

NOTE: You must perform this step if you are not on the domain controller to which you want to transfer the role. You do not have to perform this step if you are already connected to the domain controller whose role you want to transfer.
3.     Do one of the following:
o    In the Enter the name of another domain controller box, type the name of the domain controller that will be the new role holder, and then click OK.

-or-
o    In the Or, select an available domain controller list, click the domain controller that will be the new role holder, and then click OK.
4.     In the console tree, right-click Active Directory Users and Computers, point to All Tasks, and then click Operations Master.
5.     Click the appropriate tab for the role that you want to transfer (RID, PDC, or Infrastructure), and then click Change.
6.     Click OK to confirm that you want to transfer the role, and then click Close.