Code Snippets Exchange Microsoft PowerShell

Export to CSV all your Exchange 2007/2010 Email Addresses

If you want to export all your users email addresses to a CSV so you can see who has which alias you can do this with this Power Shell Command


Get-Mailbox -ResultSize Unlimited
|Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses
|Where-Object {$_.PrefixString -ceq “smtp”}
| ForEach-Object {$_.SmtpAddress}}}
| Export-CSV c:\smtp.csv -NoTypeInformation

I have wrapped it here so just paste it in to Power Shell to run and this will show the Primary Email address and then all the alias addresses.

PowerShell Get-Mailbox display SMTP addresses


http://cscmblog.blogspot.pt/2012/02/export-to-csv-all-your-exchange.html

Code Snippets ASP.Net

Concatenate data fields as binding expression

Concatenate data fields as binding expression:

<asp:label id="Label1" runat="server" 
     text='<%# String.Format("{0}, {1}", Eval("ContactLastName"), Eval("ContactFirstName")) %>'>
</asp:label> 

how to implemented mailto in Hyperlink asp control inside the gridview:

<asp:HyperLink id="hl1" runat="server" 
   NavigateUrl='<%# Eval("Email" , "mailto:{0}") %>'
   Text='<%# Eval("Email") %>'>
</asp:HyperLink>
Code Snippets

Redirect Domain

php

 <?php
  header('HTTP/1.1 301 Moved Permanently');
  header('Location: http://www.sitedeexemplo.com');
?>

.htaccess

Redirect 301 / http://www.sitedeexemplo.com 

HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Redireccionamento</title>
<meta http-equiv="refresh" content="1; url=http://www.sitedeexemplo.com" />
</head>
<body>
</body>
</html> 

Javascript

<script type="text/javascript">
<!--
window.location = "http://www.sitesample.pt/dir"
//-->
</script>
software Tips & tricks Utils

Bulk Rename Utility

Bulk Rename Utility is an easy to use file rename program (a.k.a. file renamer). Renaming multiple files has never been easier! It has a small memory footprint so it can be left running all the time without consuming all your memory. It started as a freeware Visual Basic tool, but as its popularity has grown it has been completely rewritten in C++ to be robust and lightweight – and very, very fast! It can easily handle folders/discs containing well over 100,000 entries… and it can batch rename 1,000s of files in seconds.

The software is freeware and gets downloaded very frequently. It has a large base of regular users. Most of the features have originated from other users’ suggestions. As such, it is continually being enhanced and improved.

As well as being “recommended” by a number of web sites, Bulk Rename Utility has also appeared on many magazine cover-discs, from Brazil to Sweden.

If you have a suggestion for a new feature, get in touch and it could appear in a future release of the software!

http://www.bulkrenameutility.co.uk/Download.php

Code Snippets .NET

Programmatically set the selected menu item in the Menu control

Mnu1.Items(1).Selected = True
Mnu1.FindItem("Nutrients").Selected = True
mnu1.Items(indexToSelect).Selected = True
MenuItem mi = this.Menu1.FindItem("Home");
 mi.Selected = true;
this.Menu1.Items[0].Selected = true;
Code Snippets .NET VB

Get First and last word from sentence

        Dim Nome As String = "Carlos Galhano"
        Dim firstword As String = Nome.Substring(0, Nome.IndexOf(" "))
        Dim lastWord As String = Nome.Substring(Nome.LastIndexOf(" "c) + 1)
        Response.Write("first: " & firstword & " Last: " & lastWord)
Tips & tricks Tutorials

Break lines at specific character in Notepad ++

  1. In Notepad++, click Search > Find.
  2. Click the Replace tab.
  3. Under the Search Mode group, select Regular expression.
  4. In the Find what text field, type ],\s*
  5. In the Replace with text field, type ],\n
  6. Click Replace All.

read more »

Exchange Microsoft

Enable auth login on smtp server exchange 2010

2 errors can happen:

a) “504 5.7.4 Unrecognized authentication type”
And, after was resolved, (b) happened:
b) “550 5.7.1 Client does not have permission to send as this sender”

read more »

ASP.Net

Using “Cache” in ASP.Net

 Data can be stored on the client – using the view state of the page, or on the server in a variable session state or application, or using the server cache.
ASP.NET implements System.Web.Caching.Cache class to store objects that require a large amount of server resources to be created, so that they do not have to be recreated each time it is needed.
You can access via code information about a class instance cache through the property cache, the object of the HttpContext or Page object.
Expiration policy for items in cache:
  • Specific time:  absolute expiration
  • May also expire if not accessed for a period of time:  sliding expiration

read more »

MySQL

MySql Group_Concat

The result of GROUP_CONCAT is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024.

This will cause  data-destroying bugs in production. For this reason you should probably not use GROUP_CONCAT . At least you must set the value of group_concat_max_len to an insanely high value on every database server your application runs on.

Like MAX or COUNT, GROUP_CONCAT is a MySQL aggregation function you can use whenever your query contains a GROUP BY. You can use it to retrieve a comma-separated list of all values in a given column within each group.

select  client
,Month
,year
,Sum(Amount) as Amount_Total
,GROUP_CONCAT(Amount) as Amount_Detail
,GROUP_CONCAT(InvoiceNum) as Invoices
from mytable
 group by Client