Skip DNS registration for Particular IP Addresses

Today I am sharing a TIP which can be used to skip DNS registration of some of the IP addresses (when you have assigned multiple IP to a single NIC).

When NIC’s are multiple , its easy to just uncheck the box for DNS registration as shown below:(register this connection’s address in DNS )

Capture

Challenge comes when you have a Single NIC & multiple addresses:)

So here is the TIP which utilizes cool Netsh,

ADD the first IP address to the NIC that you want to register in DNS.

Other IP addresses that you need to ADD to NIC , use following commands

Netsh Int IPv4 Add Address NIC1 10.X.X.1 SkipAsSource=True
Netsh Int IPv4 Add Address NIC1 10.X.X.2 SkipAsSource=True

NIC1 is name of the adaptor, you need to note it before hand.

Capture

Now these IP addresses will not get register in DNS.

This article is applicable to windows 2008 & above.

Regards

Sukhija Vikas

http://msexchange.me

 

Posted in SystemAdmin | Tagged , | Leave a comment

Fix Office 365 UPN

Today I am sharing a script that We have written to fix office 365 UPN.

This can help the organizations moving to office 365 & want to update the UPN in phases rather than big bang approach.

Prerequisites: Exchange management Shell

Extract the script from below link & update the text file with samaccountnames of the users for whom you want to match the UPN with SMTP address.

https://gallery.technet.microsoft.com/scriptcenter/Fix-Office-365-UPN-abb1a62f

Run the batch file, script will log as well as report in respective folders.

Report will be as below:

######################################################################### 
#            Author: Vikas Sukhija 
#            Reviewer: 
#            date: 7/6/2016 
#            Modified:7/11/2016                         
#            Description: Fix o365 UPN 
#            Update: Added reporting 
######################################################################### 
 
$date1 = get-date -format d 
$date1 = $date1.ToString().Replace("/","-"$time = get-date -format t 
 
$time = $time.ToString().Replace(":""-"$time = $time.ToString().Replace(" """) 
 
$logs = ".\Logs" + "\" + "Processed_" + $date1 + "_" + $time + "_.log" 
$report = ".\report" + "\" + "Report_" + $date1 + "_" + $time + "_.csv" 
 
$collection = @() 
 
Start-Transcript -Path $logs 
 
If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) 
{ 
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 
} 
 
 
$users = get-content .\users.txt 
 
$users | foreach-object{ 
 
$user = $_ 
 
$mbx=Get-User $user | Where { -Not [string]::IsNullOrEmpty($_.WindowsEmailAddress) }  
 
$mbcoll = "" | select Name,ExistingUPN,WindowsEmailAddress,ModifiedUPN 
 
if($mbx){ 
 
    if($mbx.UserPrincipalName -eq $mbx.WindowsEmailAddress) { 
 
    Write-host "$user is already setup as "$mbx.UserPrincipalName"" -foregroundcolor blue  
    $mbcoll.Name = $mbx.Name 
    $mbcoll.ExistingUPN = $mbx.UserPrincipalName 
    $mbcoll.WindowsEmailAddress = $mbx.WindowsEmailAddress 
    $mbcoll.ModifiedUPN = "Not Modified" } 
 
    else{ 
 
    Set-User -identity $mbx -UserPrincipalName $mbx.WindowsEmailAddress.ToString() 
    Write-host "Updating UPN for $user as "$mbx.WindowsEmailAddress"" -foregroundcolor green 
    #For($i = 1; $i -le "5"; $i++){ sleep 1;Write-Progress -Activity "Updating UPN for $user" -status "$i" -percentComplete ($i /10*100)} 
    #$mbx1 = get-user -identity $mbx 
    $mbcoll.Name = $mbx.Name 
    $mbcoll.ExistingUPN = $mbx.UserPrincipalName 
    $mbcoll.WindowsEmailAddress = $mbx.WindowsEmailAddress 
    $mbcoll.ModifiedUPN = $mbx.WindowsEmailAddress } 
        } 
 
else{ 
 
$mbx=Get-User $user 
write-host "$user ..doesn't have ..WindowsEmailAddress" -foregroundcolor magenta 
    $mbcoll.Name = $mbx.Name 
    $mbcoll.ExistingUPN = $mbx.UserPrincipalName 
    $mbcoll.WindowsEmailAddress = $mbx.WindowsEmailAddress 
    $mbcoll.ModifiedUPN = "Empty Windows Email"$collection +$mbcoll 
} 
 
$collection | export-csv $report -notypeinfo 
 
stop-transcript 
####################################################################

Regards

Sukhija Vikas

http://msexchange.me

Posted in Active Directory, Office 365, Scripting | Tagged , , | Leave a comment

Mailbox Move Agent

Sharing a script that I named as Mailbox agent, it is a package of 3 scripts:

1-SubmitMailBoxMoveRequests.ps1

2-ResumeMailBoxMove.ps1

3-ClearCompleteMailBoxMove.ps1

These we used during mailbox moves from old dags to newly created dags for exchange 2010.

update 1-SubmitMailBoxMoveRequests.ps1 script with OLDDAG/NewDAG name

$mbxsrvsrc = “OLDdag01”

$mbxsrvdst = “Newdag01”

Script will check the $countperday value & from each databse migrate the number of  malboxes (based on the value) to all destination databases.

Example: If DAGOLD has 4 databases & value for $countperday = 10

than 10 mailboxes from each DB will be migrated to destination databses.

if DAGNEW has 10 databases than 1 mailbox will be moved to db1, 2nd will move to db2 & soon…

Mailboxes will be equally distributed among all destination DBs. (this will be all automatic)

1-SubmitMailBoxMoveRequests.ps1  –> This will submit the requests & suspends after 95% completion

2-ResumeMailBoxMove.ps1 –> This will resume the request based on geography if required, just update the $region.

example: $region = “United Kingdom” (keep its value as * if you don’t want to use region)

3-ClearCompleteMailBoxMove.ps1 –> This will clear the completed requests.

All these scripts will send report in email, so please update the email variables inside the scripts.

$smtpserver = 

$from = 

$email1 = 

Extract the scripts from below link, hopefully these will work for you & will make mailbox moves easy.

https://gallery.technet.microsoft.com/scriptcenter/Mailbox-Move-Agent-08921668

 

you can also filter out the mailboxes that you want to move by updating the submit script, below is the example:

that I used to avoid migration of certain mailboxes & also just migrate the ones above 10 MB quota.

$mbx += get-mailbox -database $db -resultsize $countperday | where{(($_.MailboxMoveStatus -like “None”) -and ($_.Name -notlike “sys*”) -and ($_.ProhibitSendQuota -gt “10 MB”))}

 

 

Regards

Sukhija Vikas

http://msexchange.me

Posted in Exchange, Scripting | Tagged , , , , | Leave a comment

DAG Creation Installation Notes

Today I am sharing the brief notes that you can refer for creating the Database Availability Group for Exchange Environment. We have used it for 2010 environment – win 2008 r2sp1 (changed to make it generic).

  1. Copy the installation files to the Server

2. Check Powershell version should be 2.0 ($psversiontable)

3. Run Set-ExecutionPolicy unrestricted in powershell. (you can change it later)

4. Open Powershell & install Win_PreReqs_MBX.ps1 (extract the scripts from below path)

https://1drv.ms/u/s!Aqor_aWWYXrDgRmMXHZ34G518Z-B

5. Install  _WinR2SP1_Cluster_HotFix & _FilterPack (included in above download)

6.  Install Fail-over clustering Feature

7. Set the Service Net.TcpPort Sharing Service to Automatic

8.  Set the Windows Firewall Service to automatic and start the service

9. Check Private/Public NICs (private NIC should not have DNS registration check)

10. Change the binding order of NICs, Public should be on Top.

11. Run setup.com & choose languages on DVD , Custom install(automatically install required features) – Choose the installation path (I generally avoid installation on system drive)

12.  Select Mailbox Role –> finish wizard /restart

13.  Install latest service pack/Rollups /restart

14.  Add free busy fix registry & Max session  (this can be environment specific  – optional)

Download the registry from here:

https://1drv.ms/u/s!Aqor_aWWYXrDgRoUQjWWHnT7L9kN

Setting for Private/Public NIC interfaces

Feature MAPI Network Setting Replication Network Setting
Name Public Private
Teamed As per enviornment NA
Client for Microsoft Networks Enabled Disabled
QoS Packet Scheduler Enabled Enabled
File and Printer Sharing for Microsoft Networks Enabled Disabled
IPv6 Enabled Enabled
IPv4 Enabled Enabled
Link-Layer Topology Discovery Mapper I/O Driver Enabled Enabled
Link-Layer Topology Discovery Responder Enabled Enabled

Follow the same procedure on other node.

15. Now we can proceed further for DAG creation:

New-DatabaseAvailabilityGroup -Name DAG01 -WitnessServer WSServer -WitnessDirectory I:\DAG_FSW\DAG01 -DatabaseAvailabilityGroupIpAddresses 192.168.14.11, 192.168.14.12

16. Thru Exchange management console Configure DAG (Manage membership)

17.  Update DAG Configuration

Set-DatabaseAvailabilityGroup -identity DAG01 -AlternateWitnessServer wsserver2  -AlternateWitnessDirectory I:\DAG_FSW\DAG01 -DatacenterActivationMode DagOnly -networkcompression enabled

18.  Configure Dag Networks now  from Exchange management console, remove the default created networks & create MAPI/Replication networks.

if you want step by step info on how to create new networks & collapse default ones here is the link from other blogger, you can find plenty on the internet

Configuring DAG Networks in Exchange 2010

19.  Create the Mailbox databases

New-MailboxDatabase -Name “DAG01_Database01” -EdbFilePath J:\DAG01_Database01\DAG01_Database01.edb -LogFolderPath J:\DAG01_DatabaseLog01

Mount-Database -Identity “DAG01_Database01

Add-MailboxDatabaseCopy -Identity DAG01_Database01 -MailboxServer Node02

20.  Set activation preferences

Set-MailboxDatabaseCopy -Identity DAG01_Database01\Node02 -ActivationPreference 2

Now you can setup default quotas, Journaling, Quota notification schedules.

This is our default check list for DAG creation, its just a  brief to do kind of list so that we don’t forget what is required.

I-check-my-student-load-balance

Regards

Sukhija Vikas

http://msexchange.me

Posted in Exchange | Tagged , , | Leave a comment

Export Sharepoint List to CSV

This script will assist in exporting the Sharepoint List contents in csv format.

It would be useful in scenarios where you want to export list & further feed some other system to complete further processing.

Example which is being shared was used in one of the automation where IT people can fill the form for setting up alert on service accounts, this information further gets log into the list, from where we extract & feed it to particular path daily.

This csv is than further processed by two other scripts.

For now I am just sharing the part where we exported CSV from the list.

List example:

Extract the solution zip from below link:

https://gallery.technet.microsoft.com/scriptcenter/Export-Sharepoint-List-to-b60f3848

Update the .ps1 file with location of script logs & path where CSV to be saved for other system to process

$dir= “E:\scripts\SPlistEXp\logs”
$netpath1 = “\\server01\c$\scripts\AdAccountexp\Accountexpiry.csv”

$netpath2 = “\\server01\c$\scripts\speventid\Accountexpiry.csv”

Update the sharepoint site details/ List name

$web = Get-SPWeb “http://teamsite.lab.com/sites/accexpAlert”

$list = $web.lists[“AccexpAlert”]

Modify the below code as per your list values

#########################Get items so that these can be exported first##################

$items | foreach-object { $SamaccountName = $_[‘Title’]

$Email1 = $_[‘EmailAddress1’]

$Email2 = $_[‘EmailAddress2’]

$Oncall = $_[‘OnCall’]

$coll = “”| select Account,Email1,Email2,Oncall
$coll.Account = $SamaccountName

$coll.Email1 = $Email1

$coll.Email2 = $Email2

$coll.Oncall = $Oncall

$collection += $coll
}
}

###############################################Export CSV##################

Logs will be retained for 90 days, you can also change this value inside the script.

Now you can just schedule the script or run it by using batch file.

CSV will be extracted in ArchiveCSV folder as well as saved to other paths.

Let me know if there are any queries.

########################################################################################### 
##           Script to export List in CSV    
##           Author: Vikas SUkhija                                                              
##           Reviewer:                                                                 
##           Review Date: 05-19-2016   
##          
##            
########################################################################################### 
#############################Log Files##################################################### 
 
$date = get-date -format d 
$date = $date.ToString().Replace(“/”, “-”) 
$time = get-date -format t 
$month = get-date  
$month1 = $month.month 
$year1 = $month.year 
$time = $time.ToString().Replace(":""-"$time = $time.ToString().Replace(" """) 
 
$log1 = ".\Logs" + "\" + "Splistexport_" + $date + $time + "_.log" 
 
$output1 = ".\Archivecsv" + "\" + "Accountexpiry_" + $date + "_" + $time + ".csv" 
 
$logs = ".\Logs" + "\" + "Powershelllog" + $date + "_" + $time + "_.txt" 
 
$limit = (Get-Date).AddDays(-90) #for Retention 
 
$dir"E:\scripts\SPlistEXp\logs" 
 
$netpath1 = "\\server01\c$\scripts\AdAccountexp\Accountexpiry.csv" 
$netpath2 = "\\server01\c$\scripts\speventid\Accountexpiry.csv" 
 
################################Add Sharepoint Shell##################################### 
 
#Start-Transcript -Path $logs  
 
If ((Get-PSSnapin | where {$_.Name -match "SharePoint.PowerShell"}) -eq $null) 
{ 
    Add-PSSnapin Microsoft.SharePoint.PowerShell 
} 
 
 
######################################get List items to be delted######################## 
 
$web = Get-SPWeb "http://teamsite.lab.com/sites/accexpAlert" 
$list = $web.lists["AccexpAlert"$collection = @() 
 
$items = $list.items 
$itemscount = $items.count 
$itemscount 
$date = get-date 
Add-Content $log1 "$date Reading items in the List" 
$date = get-date 
Add-Content $log1 "$date $itemscount items in the List" 
 
if($items -eq $null) 
{ 
Write-host "nothing to process, script will exit" 
$date = get-date 
Add-Content $log1 "$date nothing to process, script will exit" 
$date = get-date 
Add-Content $log1 "$date Finished processing the requests" 
exit 
 
} else { 
 
$date = get-date 
Add-Content $log1 "$date Collecting the columns from the list item " 
 
#########################Get items so that these can be exported first################## 
$items | foreach-object { 
    $SamaccountName = $_['Title'] 
        $Email1 = $_['EmailAddress1'] 
    $Email2 = $_['EmailAddress2'] 
    $Oncall = $_['OnCall'$coll = ""| select Account,Email1,Email2,Oncall 
 
$coll.Account = $SamaccountName 
$coll.Email1 = $Email1 
$coll.Email2 = $Email2 
$coll.Oncall = $Oncall 
$collection +$coll 
 
} 
 
} 
###############################################Export CSV################################# 
 
 
$date = get-date 
Add-Content $log1 "$date Export List items to CSV" 
 
$collection | export-csv $output1 -notypeinformation 
 
copy $output1 $netpath1 -confirm:$false 
 
timeout 5 
 
copy $output1 $netpath2 -confirm:$false 
 
###########################Recycle##########################################  
  
$path = $dir   
   
Get-ChildItem -Path $path  | Where-Object {    
$_.CreationTime -lt $limit } | Remove-Item -recurse -Force   
  
############################################################################## 
 
#stop-transcript  
 
 
#########################################Script finished#############################

Regards

Sukhija Vikas

http://msexchange.me

Posted in Scripting, SharePoint, SystemAdmin | Tagged , , | Leave a comment

Change Mail directories path IIS SMTP

We had a need to install the SMTP server for some application but we want to change the default Mail directories path:

Capture1

Unfortunately you can’t just do it from IIS management console, for modifying the default paths you need metabase explorer.

However you can change the Badmail directory from IIS console: (right click smtp server –> properties –>Messages Tab)

modify it & restart the SMTP service for changes to take effect.

Capture1

For other directories:

download & install the IIS Metabase explorer from the following link

http://www.microsoft.com/en-us/download/details.aspx?id=17275

1

Follow the wizard & choose custom installation

2

Just select the Metabase Explorer & finish the wizard.

3

Launch Metabase Explorer

Navigate to LM > SmtpSvc > 1 and change the directory paths 

4

Restart the SMTP service & you will notice new paths gets created.

Just follow the steps mentioned above if you are in same situation.

Regards

Sukhija Vikas

http://msexchange.me

 

Posted in SystemAdmin | Tagged , , | Leave a comment