Unable to connect SQL server port 1433 remotely

  1. Ensure network firewall policy is created for TCP port 1433
  2. Check for Windows Server firewall that port 1433 or SQL program is allowed.
  3. Check port 1433 is listening [telnet servername 1433]
  4. If not find which port is listening to: netstat –ab (eg. Netstat –an or netstat –an | findstr :1433)

Microsoft SQL Server “2012”

Reboot sql server service or host server itself

Posted in Windows | Tagged

Hide External Contact from Office 365 GAL

Open Windows PowerShell

Enable Scrpits to run in PowerShell

Set-ExecutionPolicy RemoteSigned

Run the following commands in order:
a.     $LiveCred = Get-Credential

Enter an Office 365 administrator address and password on open window.

b.     $Session = New-PSSession -ConfigurationName Microsoft.Exchange –ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection

c.     Import-PSSession $Session

Hide external contact from Global Address List

Set-MailContact -Identity robiul@mydomain.com -HiddenFromAddressListsEnabled $true

Posted in Powershell | Tagged

Delete contents from users mailbox

Following steps help when accidentally sent email to undesirable participants or removing virus attachment for unsolicited emails.

Source: http://technet.microsoft.com/en-us/library/dd298173.aspx

Download and install followings:

Microsoft Online Services Sign-In Assistant for IT Professionals RTW


[Install BETA if you get any error installaing Azur AD http://www.microsoft.com/en-us/download/confirmation.aspx?id=39267]

Windows Azure Active Directory by using Windows PowerShell

Reference to Available PowerShell Cmdlets in Exchange Online

Click Start > All Programs > Windows Azure Active Directory > Windows Azure Active Directory Module

Type in the following command, a Windows PowerShell Credential request will open opens, type in your Office 365 credentials.


$LiveCred = Get-Credential

Type in Command:


$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection

[Set-ExecutionPolicy RemoteSigned]

Type in the following command:


Import-PSSession $Session

Administrators may need to search for / delete inappropriate or potentially harmful e-mail messages sent to multiple mailboxes across their organization. For example, e-mail messages can contain viruses or links to download a virus, inappropriate content, such as jokes or confidential information that was accidentally sent to the incorrect recipients.

Exchange Control Panel (ECP) or 0ffice365doesn’t provide this feature yet but Windows PowerShell does by using the Search-Mailbox cmdlet with the DeleteContent switch parameter.

Note.  Search-Mailbox cmdlet with the DeleteContent parameter, email items are permanently deleted from the user’s mailbox and it is not recoverable.

Administrator needs required rights to perform the tasks.

Mailbox Search   This role allows you to search for messages across multiple mailboxes in your organization. Administrators aren’t assigned this role by default. To search multiple mailboxes, add yourself as a member of the Discovery Management role group.

Add or Remove Role Group Members.
Use administrator role groups to assign users permissions to perform specific administrative tasks, such as creating new mailboxes, resetting passwords, or troubleshooting the Outlook Web App Options page of another user.

To assign users’ permissions to perform specific administrative tasks, you add the user as a member of the administrator role group for those administrative tasks. Here’s how:

  1. In the Exchange Control Panel, select Manage My Organization > Roles & Auditing > Administrator Roles.
    —————- For Microsoft Office365———-
    For office365 https://outlook.office365.com/ecp/ and Permission
    link from left.
    we may create new user and add these two roles or add in the exiting role where administrator name is belonged.

  2. __________End O65 steps_________

  3. Select the role group that you want to add the user to, and then click Details.
  4. Under Members, click Add.
  5. In the Select Members dialog box, select the user, security group, or role group. You can search for a name by typing all or part of a display name, and then clicking . You can also sort the list by clicking the Name or Display Name column headings.
  6. Click Add.
  7. Click OK to return to the role group page.
  8. Click Save to save the change to the role group.
    The new member is displayed under Members in the details pane for the selected role group.

Mailbox Import Export   This role allows you to delete messages from a user’s mailbox. This role isn’t assigned to administrators by default. To delete messages from users’ mailboxes, add the Mailbox Import Export role to the Organization Management role group.

Edit Role Group Properties
Use the Role Group dialog box to view or change the configuration of the role group.

A unique, descriptive name for the role group.


A description of the role’s capabilities.

Write Scope

The write scope defines the administrative boundary of the roles assigned to the role group. In other words, the write scope defines where members of the role group can make changes.

When you select a write scope from the drop-down list, it is applied to all the roles that are assigned to the role group. You can select from two kinds of write scopes:

  • Default   This is the implicit write scope that applies to all the roles assigned to the role group. For built-in administrator roles that allow users to modify objects, the default write scope is the entire organization.
  • Custom   These are custom write scopes you created using the New-ManagementScope cmdlet.
    • Cloud-based organizations can create custom write scopes based on recipient filters. For example “All users where CustomAttribute1 contains ‘students'”.
    • On-premises implementations of Microsoft Exchange Server 2010 can also create custom write scopes based on Exchange Server attributes, Exchange database attributes, or organizational units.

    Note   Exclusive write scopes don’t appear in the drop down list. An exclusive write scope isolates specific mailboxes so they can be managed by designated administrators only.

If any of the following conditions are true, you can’t view or change the write scope here:

  • An end-user role is assigned to the role group.
  • A role is assigned to the role group using a different write scope than the other roles.
  • Roles are assigned to the role group using exclusive write scopes.

To view or change the write scope of role assignments that you can’t manage here, you can use the Get-ManagementRoleAssignment or Set-ManagementRoleAssignment cmdlets.



Deleting email content from Robiul Islam’s mailbox email subject matches with: Attached Image’

Search-Mailbox -Identity “Robiul Islam” -SearchQuery ‘Subject:”Attached Image’ –DeleteContent

The following command searches Scott Johnson’s mailbox for messages that have the phrase Download this file in the Subject field and logs the search results in the SearchLogs folder in the administrator’s mailbox.


Search-Mailbox -Identity "Scott Johnson" -SearchQuery subject:"Download this file" -TargetMailbox Administrator -TargetFolder SearchLogs -LogOnly -LogLevel Full

The following command searches all mailboxes for messages that have any type of attached file named Virus and sends a log message to the administrator’s mailbox.

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery attachment:virus* -TargetMailbox Administrator -TargetFolder SearchLogs -LogOnly -LogLevel Full

The following command searches all the mailboxes for messages with the subject line Download this file, and then permanently deletes them.

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery subject:"Download this file" -DeleteContent

Note. Before you permanently delete messages, we recommend that you either use the LogOnly parameter to generate a log of the messages found in the search before they’re deleted, or copy the messages to another mailbox before deleting them from the source mailbox.

The following command searches all mailboxes for messages with the subject line Download this file, copies the search results to the DeletedMessages folder in the administrator’s mailbox, and then permanently deletes the messages from users’ mailboxes.

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery subject:"Download this file" -TargetMailbox Administrator -TargetFolder DeletedMessages -DeleteContent


The script below only deletes the emails from last year.  I want to delete any emails older than 30 days.

get-mailbox -Identity spam -resultsize unlimited | Search-Mailbox -SearchQuery ‘sent:lastyear’ -deletecontent

Email content deletes from 30 days before.

$a= Get-Date
get-mailbox -Identity spam -resultsize unlimited | Search-Mailbox -SearchQuery ‘sent:>$a.AddDays(-30)’ –deletecontent

Using Search-Mailbox to search emails

For example:

Get-Mailbox -Identity “UserMailbox To Search” | Search-Mailbox -SearchQuery subject:”This email is PRANK!”,from:” spammer@prank.com” -TargetMailbox “Mailbox to put search results into” -TargetFolder “A folder in that mailbox”

This will search “UserMailbox to search” for any emails with a subject that contains “This email is Prank!” and from “pammer@prank.com”. If it finds any emails that fit the criteria, then it will copy them all to “Mailbox to put search results into” in the folder “A folder in that mailbox”. Simple huh!

Note – if you leave the -Identity off the Get-Mailbox cmdlet, then it will search EVERY mail box in Exchange. Could be quite slow, depending on number of mailboxes you have.

Using Search-Mailbox to delete emails

Now, if you want to delete emails, it’s pretty much the same command, just put a -DeleteContent onto the Search-Mailbox cmdlet and remove the TargetMailbox/TargetFolder options.

For example:

Get-Mailbox -Identity “UserMailbox To Search” | Search-Mailbox -SearchQuery subject:”This email is Prank!”,from:”spammer@prank.com” -DeleteContent

Posted in Others | Tagged

Hide, Un-hide, Mailboxes and Block Office365 Users


Open Windows PowerShell

Click Start > All Programs > Accessories > Windows PowerShell

Note: Right-click Windows PowerShell and select Run as administrator. If you get a user account control prompt that
asks if you would like to continue, respond Continue.

Verify PowerShell can run scripts

Run this command:

Note: If the value returned is anything other than “RemoteSigned”, you need to change the value using Step 3. Otherwise skip to Step 4.

Enable Scrpits to run in PowerShell

Run this command:
Set-ExecutionPolicy RemoteSigned

Connect PowerShell to the cloud-based service

Run the following commands:
$LiveCred = Get-Credential

Note: The above command will open a login window. Enter an Office 365 administrator address and password.

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred
-Authentication Basic -AllowRedirection

Import-PSSession $Session


1. Hide mailbox users (mailbox enabled) from Global Address Book (GAL) in Office 365
Set-Mailbox -Identity User@domain.com -HiddenFromAddressListsEnabled $true

2. Un-hide mailbox users (mailbox enabled) from Global Address Book (GAL) in Office 365
Set-Mailbox -Identity User@domain.com -HiddenFromAddressListsEnabled $false
$users = import-csv C:\HiddenContacts.csv
Foreach($_ in $users) {Set-mailbox -identity $_.identity -HiddenFromAddressListsEnabled $false}

3. Hide a contact from the Global Address Book (GAL) in Office 365
Set-MailContact emailaddress@mydomain.com -HiddenFromAddressListsEnabled $true

Unhide the contacts from C:\HiddenContacts.csv file by running the following cmdlet
$users = import-csv C:\HiddenContacts.csv
Foreach($_ in $users) {Set-mailcontact $_.identity -HiddenFromAddressListsEnabled $false}

4. Hide all external contacts from the Global Address Book (GAL) in Office 365
Get-MailContact -ResultSize unlimited | Set-MailContact -HiddenFromAddressListsEnabled $true

5. Export a list for contacts hidden from GAL by running the following cmdlet:
Get-Mailcontact -Filter {HiddenFromAddressListsEnabled -eq $true} | Select identity,alias,HiddenFromAddressListsEnabled |
Export-Csv -Path C:\HiddenContacts.csv -NoTypeInformation

6. Block Users (so user will not be able to login to their mailbox)
Set-MsolUser -UserPrincipalName Scott@domain.com -blockcredential $true

Block users from C:\blockusrslist.csv file by running the following cmdlet
$users = import-csv C:\blockusrslist.csv
Foreach($_ in $users) {Set-MsolUser -UserPrincipalName Scott@domain.com -blockcredential $true}

Posted in Powershell | Tagged , ,

Renew Web server certificate for Watchguard

Simple steps to renew Watchguard self-signed certificate. I created this blog post to remember the steps as it is a rare task that need to perform.

  1. Open Policy Manger
  2. Click on Setup –> Authentication –> Web Server Certificate
  3. Select Default certificate signed to Firebox

  4. Now save the configuration.
  5. Open System Manager and Certificate

View from system manager

Optional: Following steps for creating certificate using custom details.

We can also type an Organization Name and an Organization Unit Name to identify the part of your organization that created the certificate.

(Note: Third party certificate option allows to install public certificate so it will not alert you for the security warning).

Click Add Domain Names or Add Interface IP Addresses.

In the text box at the bottom of the dialog box, type a domain name or IP address of an interface on our XTM device.

Click Add.

Repeat Steps above to add more domain names if Add Domain names is selected.

Click OK

Posted in WatchGuard | Tagged

CAL items are restored automatically

Issue Definition: Office 365 Deleted calendar events keep coming back.


This action will need the global administrator permission for the Office 365 account.

1. Please start the Windows PowerShell in the PC and run it as administrator.

2. Then run the command below to connect to the exchange online PowerShell:

    Set-ExecutionPolicy RemoteSigned

    $LiveCred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential

$LiveCred -Authentication Basic –AllowRedirection

Note: When the credential window pops up, please type in your Office 365 admin account and password.

    Import-PSSession $Session

3. Run the command below, replace the username with the bosses’ email address in the command:

Set-Mailbox -Identity username -CalendarRepairDisabled $true


Set-Mailbox -Identity username@myemaildomain.com -CalendarRepairDisabled $true


Posted in Powershell | Tagged