Monday, 17 September 2012

How to pull the report to only 500 group ids even if your organisation is having more than 10000 groups?

For example,  you are having more than 2000 groups in your organisation. Now you are in a situation to get the details of owners name of 500 groups only. How you will do?

We can use Get-content to get the data from the text file with the path name mentioned and do the pipeline to the command like below


[PS] C:\Users\sankar\desktop>$list = Get-Content .\groupid.txt | ?{$_ -ne ""} |%{$_.Trim()}
[PS] C:\Users\sankar\desktop>$list.Count
547
[PS] C:\Users\sankar\desktop>$list | % {Get-DistributionGroup -Identity $_ -ResultSize Unlimited | Select-
Object Name,@{L="ManagedBy";E={$_.ManagedBy}}} | Export-Csv -NoTypeInformation grouplistfromtext.csv


Friday, 7 September 2012

Find out No longer Existing Group

This exchange cmdlet would be helpful if you are dong auditing in your organization. You could filter no longer users details using last log on time.


Get-MailboxStatistics -Server <ServerIdParameter> | Sort-Object LastLogonTime –Descending

Wednesday, 5 September 2012

How to get the details of email addresses Using Powershell

We can use the below exchange cmdlet to pull the details of email addresses. Then export it to the CSV file using Export-CSV cmdlet. 

Get-Mailbox -resultsize unlimited | Select Name, @{Name=’EmailAddresses’;Expression={[string]::join(";", ($_.EmailAddresses))}} | Export-CSV EmailAddress.csv

Tuesday, 21 August 2012

How to set the forwarding SMTP Address through Powershell

You cannot set the Fowarding SMTP Address through EMC. But we can set it through EMC

If you want to forward the mails from local mailbox to outside the organization, we should follow the below steps in powershell

1. DeliverToMailboxAndForward:

set-mailbox -DeliverToMailboxAndForward $true

2. Forwarding Address

set-mailbox intials -forwardingaddress Username

3. ForwardingSMTPAddress

set-mailbox intials -forwardingsmtpaddress email@domain.com

Thursday, 9 August 2012

Get Large Mailboxes from exchange

Using the below script we can get the large mailboes report from the exchange 2007


Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where {$_.TotalItemSize -gt 500MB} `
| Select-Object DisplayName, ItemCount, TotalItemSize, TotalDeletedItemSize, StorageLimitStatus `
| Export-Csv "BigMailbox$(Get-Date -f 'yyyyMMdd').csv" -NoType

Friday, 3 August 2012

How to set the pimary email address and making the existing one as secondary email address

Here is the script to set the primary email address and making the existing as the secondary. if we do so, if anyone sending a mail to old email address, we can avoid the NDR

Import-Csv d:\alias.csv | Foreach-object { Set-Mailbox $_.alias -emailaddresspolicyenabled $false -PrimarySmtpAddress $_.SmtpAddress }


how to change the primary smtp using login id?

$Users = Import-CSV c:\myfile.csv
ForEach($User in $Users)
{
write-host "Processing $($User.loginid)"
set-mailbox -identity $user.loginid -PrimarySmtpAddress $user.primaryemail -EmailAddressPolicyEnabled $false
}

Regards,
Sankar M

Thursday, 2 August 2012

How to import file using Powershell

How to Import the file using powershell

Declare the variable to load CSV file.

C:\temp>$V = import-csv c:\reprot.txt


If you want to see the ouput in console , just type the $v variable, you will be shown with  content loaded into the text file

Then we have run the script line by line, so we must use foreach alias

$v | foreach {
If
{
$_.hide –eq “yes”
}
{
Write-host  “ $_.name will be set as $true”
}