Category Archives: Microsoft

Exchange Microsoft PowerShell

Use the Exchange Management Shell to set up mail forwarding

This example delivers email to the mailbox of Douglas Kohn and, at the same time, forwards all mail sent to Douglas Kohn to douglaskohn.parents@fineartschool.net.

Set-Mailbox -Identity "Douglas Kohn" -DeliverToMailboxAndForward $true -ForwardingSMTPAddress "douglaskohn.parents@fineartschool.net"  

 

This example forwards all email sent to the mailbox of Ken Sanchez, an employee of Contoso Suites, to one of his coworkers, pilarp@contoso.com.

 
Set-Mailbox -Identity "Ken Sanchez" -ForwardingSMTPAddress "pilarp@contoso.com"
 

For detailed syntax and parameter information, see Set-Mailbox.

 

Note:
-ForwardingsmtpAddress to multiple addresses Shell script

The parameter “ForwardingSmtpAddress” only allow to setup one SMTP address.
To work around this issue, you can setup the mailbox forwarding to a distribution group, you need to add the users you want to forward message to this distribution group.

 

link:
https://docs.microsoft.com/en-us/exchange/recipients/user-mailboxes/email-forwarding?view=exchserver-2019

Databases SQL Server Tips & tricks Transact-SQL

How to get different SQL Server date formats

Below is a list of formats and an example of the output.  The date used for all of these examples is “2006-12-30 00:38:54.840”.

DATE ONLY FORMATS
Format # Query Sample
1 select convert(varchar, getdate(), 1) 12/30/06
2 select convert(varchar, getdate(), 2) 06.12.30
3 select convert(varchar, getdate(), 3) 30/12/06
4 select convert(varchar, getdate(), 4) 30.12.06
5 select convert(varchar, getdate(), 5) 30-12-06
6 select convert(varchar, getdate(), 6) 30 Dec 06
7 select convert(varchar, getdate(), 7) Dec 30, 06
10 select convert(varchar, getdate(), 10) 12-30-06
11 select convert(varchar, getdate(), 11) 06/12/30
12 select convert(varchar, getdate(), 12) 061230
23 select convert(varchar, getdate(), 23) 2006-12-30
101 select convert(varchar, getdate(), 101) 12/30/2006
102 select convert(varchar, getdate(), 102) 2006.12.30
103 select convert(varchar, getdate(), 103) 30/12/2006
104 select convert(varchar, getdate(), 104) 30.12.2006
105 select convert(varchar, getdate(), 105) 30-12-2006
106 select convert(varchar, getdate(), 106) 30 Dec 2006
107 select convert(varchar, getdate(), 107) Dec 30, 2006
110 select convert(varchar, getdate(), 110) 12-30-2006
111 select convert(varchar, getdate(), 111) 2006/12/30
112 select convert(varchar, getdate(), 112) 20061230
TIME ONLY FORMATS
8 select convert(varchar, getdate(), 8) 00:38:54
14 select convert(varchar, getdate(), 14) 00:38:54:840
24 select convert(varchar, getdate(), 24) 00:38:54
108 select convert(varchar, getdate(), 108) 00:38:54
114 select convert(varchar, getdate(), 114) 00:38:54:840
DATE & TIME FORMATS
0 select convert(varchar, getdate(), 0) Dec 12 2006 12:38AM
9 select convert(varchar, getdate(), 9) Dec 30 2006 12:38:54:840AM
13 select convert(varchar, getdate(), 13) 30 Dec 2006 00:38:54:840AM
20 select convert(varchar, getdate(), 20) 2006-12-30 00:38:54
21 select convert(varchar, getdate(), 21) 2006-12-30 00:38:54.840
22 select convert(varchar, getdate(), 22) 12/30/06 12:38:54 AM
25 select convert(varchar, getdate(), 25) 2006-12-30 00:38:54.840
100 select convert(varchar, getdate(), 100) Dec 30 2006 12:38AM
109 select convert(varchar, getdate(), 109) Dec 30 2006 12:38:54:840AM
113 select convert(varchar, getdate(), 113) 30 Dec 2006 00:38:54:840
120 select convert(varchar, getdate(), 120) 2006-12-30 00:38:54
121 select convert(varchar, getdate(), 121) 2006-12-30 00:38:54.840
126 select convert(varchar, getdate(), 126) 2006-12-30T00:38:54.840
127 select convert(varchar, getdate(), 127) 2006-12-30T00:38:54.840
FORMATS WITH ISSUES
130 select convert(varchar, getdate(), 130) 10 ?? ????? 1427 12:38:54:840A
131 select convert(varchar, getdate(), 131) 10/12/1427 12:38:54:840AM

You can also format the date or time without dividing characters, as well as concatenate the date and time string:

Sample statement Output
select replace(convert(varchar, getdate(),101),’/’,”) 12302006
select replace(convert(varchar, getdate(),101),’/’,”) + replace(convert(varchar, getdate(),108),’:’,”) 12302006004426

read more »

Hyper-V Tips & tricks Utils

VMDK to VHDX

Follow steps:

  • Download: http://www.microsoft.com/en-us/download/details.aspx?id=42497
  • Open Powershell as administrator and run Import-Module 'C:\Program Files\Microsoft Virtual Machine Converter\MvmcCmdlet.psd1'
  • And after ConvertTo-MvmcVirtualHardDisk -SourceLiteralPath
    d:\scratch\vmx\VM-disk1.vmdk -VhdType DynamicHardDisk -VhdFormat vhdx
    -destination c:\vm-disk1

If you counter following error:

ConvertTo-MvmcVirtualHardDisk : The entry 1 is not a supported disk database entry for the descriptor.

In my case it was entry 4

Follow these steps:

  1. download and extract dsfok tools
  2. use dsfo.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to extract the descriptor
  3. edit the descriptor file in Notepad++: comment the above mentioned line (as I added the extra single character (#) I also deleted one NULL character from the end to keep the file size of 1024 bytes (not sure if this is needed).
  4. use dsfi.exe "c:\temp\disk2.vmdk" 512 1024 descriptor1.txt to inject the descriptor back into the VMDK
  5. repeat these steps for the other disk (my VM has two .vmdk files)
  6. reissue the ConvertTo-MvmcVirtualHardDisk command

 

Source:

https://gist.github.com/rahilwazir/69a750b70348459875cbf40935af02cb

https://stackoverflow.com/questions/37481737/error-when-converting-vmware-virtual-disk-to-hyperv

Related articles:

Yes, you can! Convert VMDK to VHD with these tools

 

Exchange Microsoft Office365

Email Forwarding on an on-prem mailbox to Office 365 mailbox

 

 Configure email forwarding for a mailbox

Set-Mailbox -Identity “OnPrem mailbox” -ForwardingSMTPAddress “Office 365 mailbox”

Exchange Microsoft Tips & tricks Tutorials Utils

How to prevent internal email spoofing in an Exchange organization

Ensuring email security might be one of the most important and most difficult tasks an administrator must face. Every day, servers process thousands of emails and controlling such a big mail flow is not easy. No wonder hackers focus on this channel when they plan attacks. They use various tricks to make users think that opening a suspicious attachment is a good idea.

One of the tricks they use is email spoofing.

Prevent Internal Spoofing in Exchange organization

What is email spoofing?

Email spoofing is a very popular attack method. The sender modifies message headers so that emails appear as sent from someone else. Hackers use it, for example, to impersonate employees of a company to obtain login credentials, personal data, or other confidential information. Two most common ways to protect your organization from external spoofing attacks are:

  • An SPF record – a list of IP addresses which are authorized to send emails from a domain.
  • DKIM check – an email authentication method. It enables you to sign and verify email messages using public and private keys. The public keys, published in the DNS records are used to verify if the message comes from the original sender. You cannot configure it on the Exchange Server natively – you require a plugin for SMTP gateway.

Both ways give good results when fighting with external spoofing. The problem starts when we come across internal spoofing when one employee tries to impersonate a colleague. It might be a joke, or to achieve some benefits – either way, it can sabotage a company in a number of ways:

  • Cause chaos,
  • Induce material damage,
  • Harm data integrity,
  • Damage the company reputation.

 

 

See Full article in https://www.codetwo.com/admins-blog/how-to-prevent-internal-email-spoofing-in-exchange/

 

Code Snippets IIS

IIS: Redirect to another domain

Redirect from any page of www.mysite1.com to a static root of another site www.mysite2.com

 

<rule name="site2.com" stopProcessing="true">
             <match url=".*" />
             <conditions>
                 <add input="{HTTP_HOST}" pattern="^(.*)?site1.com" />                 
             </conditions>
             <action type="Redirect" url="http://www.site2.com/{R:0}" />
</rule>
Code Snippets ASP.Net IIS

SSL Redirect URL, rewrite rule

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.webServer>
	<rewrite>
		<rules>
			<rule name="Redirect to http" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
				<match url="*" negate="false" />
				<conditions logicalGrouping="MatchAny">
					<add input="{HTTPS}" pattern="off" />
				</conditions>
				<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
			</rule>
		</rules>
	</rewrite>
  </system.webServer>
</configuration>

read more »

Exchange Office365 Tips & tricks

MRS Proxy Error “The connection to the server could not be completed”

Check MRS endpoint user and password.

read more »

Exchange Microsoft

Exchange 2013 not receiving external emails

Backpressure,  check for free space on the disks.

 

read more »

Exchange Microsoft Office365

Remote Server returned ‘550 5.1.8 Access denied, bad outbound sender

Remote Server returned ‘550 5.1.8 Access denied, bad outbound sender’

Solution:

Non-Office 365 user use this https://sender.office.com (self-service delisting portal) to remove themselves from the blocked senders list.

Office 365 user, as an admin you can unblock your blocked Office 365 email account via using Exchange admin center.

• Go to the EAC, navigate to protection > action center.
• Select the Search icon and enter the SMTP address of the blocked user.
• Click Unblock Account in the description pane.
• Click Yes to confirm the change.

For more detailed information, please refer to the article: Removing a user, domain, or IP address from a block list after sending spam email