

#------------------------------------------------------------------------------
# THIS CODE AND ANY ASSOCIATED INFORMATION ARE PROVIDED AS IS WITHOUT
# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS
# FOR A PARTICULAR PURPOSE. THE ENTIRE RISK OF USE, INABILITY TO USE, OR 
# RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
#
# AUTHOR(s):
#       Eyal Doron (o365info.com)
#------------------------------------------------------------------------------
# Hope that you enjoy it ! 
# And May the force of PowerShell will be with you   :-)
# 04-5-2014    
# Version WP- 001 
#------------------------------------------------------------------------------


Function Disconnect-ExchangeOnline {Get-PSSession | Where-Object {$_.ConfigurationName -eq "Microsoft.Exchange"} | Remove-PSSession}
function Validate-UserSelection
{
    Param(
        $AllowedAnswers,
        $ErrorMessage,
        $Selection
    )
    foreach($str in $AllowedAnswers.ToString().Split(","))
    {
        if($str -eq $Selection)
        {
            return $true
        }
    }
    Write-Host $ErrorMessage -ForegroundColor Red -BackgroundColor Black
    return $False

}

function Format-BytesInKiloBytes 
{
    param(
        $bytes
    )
    "{0:N0}" -f ($bytes/1000)
}

Function Set-AlternatingRows {
       <#
       
       #>
    [CmdletBinding()]
       Param(
             [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
        [string]$Line,
       
           [Parameter(Mandatory=$True)]
             [string]$CSSEvenClass,
       
        [Parameter(Mandatory=$True)]
           [string]$CSSOddClass
       )
       Begin {
             $ClassName = $CSSEvenClass
       }
       Process {
             If ($Line.Contains("<tr>"))
             {      $Line = $Line.Replace("<tr>","<tr class=""$ClassName"">")
                    If ($ClassName -eq $CSSEvenClass)
                    {      $ClassName = $CSSOddClass
                    }
                    Else
                    {      $ClassName = $CSSEvenClass
                    }
             }
             Return $Line
       }
}


$FormatEnumerationLimit = -1


#------------------------------------------------------------------------------
# PowerShell console window Style
#------------------------------------------------------------------------------

$pshost = get-host
$pswindow = $pshost.ui.rawui

	$newsize = $pswindow.buffersize
	
	if($newsize.height){
		$newsize.height = 3000
		$newsize.width = 150
		$pswindow.buffersize = $newsize
	}

	$newsize = $pswindow.windowsize
	if($newsize.height){
		$newsize.height = 50
		$newsize.width = 150
		$pswindow.windowsize = $newsize
	}

#------------------------------------------------------------------------------
# HTML Style start 
#------------------------------------------------------------------------------
$Header = @"
<style>
Body{font-family:segoe ui,arial;color:black; }
H1{ color: white; background-color:#1F4E79; font-weight:bold;width: 70%;margin-top:35px;margin-bottom:25px;font-size: 22px;padding:5px 15px 5px 10px; }
TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH {border-width: 1px;padding: 5px;border-style: solid;border-color: #d1d3d4;background-color:#0072c6 ;color:white;}
TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
.odd  { background-color:#ffffff; }
.even { background-color:#dddddd; }
</style>

"@

#------------------------------------------------------------------------------
# HTML Style END
#------------------------------------------------------------------------------



$Loop = $true
While ($Loop)
{
    write-host 
    write-host ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    write-host   " Mailbox Time zone and Language configurations   | PowerShell Script menu  "
    write-host ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    write-host
    write-host -ForegroundColor green  'Connect PowerShell session to AD Azure and Exchange Online' 
    write-host -ForegroundColor green  '--------------------------------------------------------------' 
    write-host -ForegroundColor Yellow ' 0)   Login in using your Office 365 Administrator credentials' 
    write-host
    write-host -ForegroundColor green  '---------------------------' 
    write-host -ForegroundColor white  -BackgroundColor Blue 'Section A: Set Time Zone and Language Mailbox settings ' 
    write-host -ForegroundColor green  '---------------------------' 
    write-host
    write-host                                              ' 1)   Set Time Zone for Mailbox'
	write-host                                              ' 2)   Set Time Zone +  Language for Mailbox'
	write-host                                              ' 3)   Set Time Zone +  Language + Date Format for Mailbox'
	write-host 
	write-host -ForegroundColor green  '---------------------------' 
    write-host -ForegroundColor white  -BackgroundColor Blue 'Section B: Set Time Zone and Language - BULK Mode  ' 
    write-host -ForegroundColor green  '---------------------------' 
    write-host
    write-host                                              ' 4)   Set Time zone on ALL Mailboxes (BULK Mode)'
	write-host                                              ' 5)   Set Time zone & Language on ALL Mailboxes (BULK Mode)'
	write-host                                              ' 6)   Correct Time Zone setting for Mailboxs with wrong time zone (BULK Mode)'
	
	write-host -ForegroundColor green  '---------------------------' 
    write-host -ForegroundColor white  -BackgroundColor Blue 'Section C: Display Information about Time Zone and Language  ' 
    write-host -ForegroundColor green  '---------------------------' 
    write-host
    write-host                                              ' 7)   Display a list of time zones you can use'
	write-host                                              ' 8)   Display Time Zone of a specific Mailbox'
	write-host                                              ' 9)   Display Time zone settings for all users'
	write-host  
	
	write-host -ForegroundColor green  '---------------------------' 
    write-host -ForegroundColor Blue  -BackgroundColor Yello ' Exit\Disconnect ' 
    write-host -ForegroundColor green  '---------------------------' 
    write-host
    write-host  -ForegroundColor Yellow                       ' 10)  Disconnect PowerShell session'
	write-host 
	write-host  -ForegroundColor Yellow                       ' 11)  Exit'
	write-host 
	write-host                                          

	

    $opt = Read-Host "Select an option [0-11]"
    write-host $opt
    switch ($opt) 


{


		#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		# Step -00 |  Create a Remote PowerShell session to AD Azure and Exchange Online
		#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


		0
        {

            # Specify your administrative user credentials on the line below 

            $user = Admin@.....

            # This will pop-up a dialogue and request your password
            

            # Import the Local Microsoft Online PowerShell Module Cmdlets and  Establish an Remote PowerShell Session to AD Azure  
            
            Import-Module MSOnline

            

            # Establish an Remote PowerShell Session to Exchange Online 

            $msoExchangeURL = https://ps.outlook.com/powershell/
			$connected = $False
			$i = 0
			while ( -not ($connected)) {
				$i++
				if($i -eq 4){
					
										
					Write-host
					Write-host -ForegroundColor White	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
					Write-host
					Write-host -ForegroundColor Red    "Too many incorrect login attempts. Good bye."	
					Write-host
					Write-host -ForegroundColor White	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
					Write-host
					
					
					exit
				}
				$cred = Get-Credential -Credential $user
				try 
				{
					$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $msoExchangeURL -Credential $cred -Authentication Basic -AllowRedirection  -ErrorAction stop
					Connect-MsolService -Credential $cred -ErrorAction stop
					Import-PSSession $session 
					$connected = $true 
				}
				catch 
				{
					Write-host
					Write-host -ForegroundColor Yellow	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
					Write-host
					Write-host -ForegroundColor Red    "There is something wrong with the global administrator credentials"	
					Write-host
					Write-host -ForegroundColor Yellow	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
					Write-host
				}
			}
            
			$host.ui.RawUI.WindowTitle = ("Windows Azure Active Directory |Connected to Office 365 using: " + $Cred.UserName.ToString()  ) 
        }



		
	


#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# Section A: Set Time Zone and Language
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




1{


#####################################################################
#  Set Time Zone 
#####################################################################

# Section 1: information 

				clear-host

				write-host
				write-host
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
				write-host  -ForegroundColor white		Information                                                                                          
				write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
				write-host  -ForegroundColor white  	"This command will set the following Mailbox settings: " 
				write-host  -ForegroundColor white  	"1. Time Zone - Pacific Standard Time "
				write-host  -ForegroundColor Magenta	oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                          
				write-host  -ForegroundColor white  	'The PowerShell command that we use is: '
				write-host  -ForegroundColor Yellow  	'Set-MailboxRegionalConfiguration -identity <User> -TimeZone "Pacific Standard Time"'
				write-host  -ForegroundColor white		----------------------------------------------------------------------------  	                                  
				write-host
				write-host

					# Section 2: user input	
					
					write-host -ForegroundColor white	'User input '
					write-host -ForegroundColor white	---------------------------------------------------------------------------- 
					write-host -ForegroundColor Yellow	"You will need to provide 2 parameters:"  
					write-host
					write-host -ForegroundColor Yellow	"1. Mailbox or user name  "  
					write-host -ForegroundColor Yellow	"For example:  John@o365info.com ( Manager Mailbox )"
					write-host
					$UserName  = Read-Host "Type the Mailbox name of user that you want to assign Full Access permission "
					write-host
					write-host

					# Section 3: PowerShell Command

					Set-MailboxRegionalConfiguration -identity $UserName -TimeZone "Pacific Standard Time"


					write-host
					write-host


					# Section 4: Display Information

					write-host ---------------------------------------------------------------------------
					write-host -ForegroundColor white	 Time Zone for $UserName  mailbox 
					write-host ---------------------------------------------------------------------------

					get-MailboxRegionalConfiguration -identity $UserName  | Out-String



					# Section 5:  Indication 


					write-host 
					if ($lastexitcode -eq 1)
					{
						write-host "The command Failed :-(" -ForegroundColor red
					}
					else
					{
							
						write-host -------------------------------------------------------------
						write-host -ForegroundColor Yellow	"The command complete successfully !" 
						write-host
						write-host -ForegroundColor Yellow	"The Time Zone for user:  "
						write-host -ForegroundColor White	$UserName.ToUpper() 
						write-host -ForegroundColor Yellow	"was set to: "	
						write-host -ForegroundColor white	"Pacific Standard Time"
						write-host -------------------------------------------------------------
						
					}

					# End of Indication 

					write-host
					write-host
					Read-Host "Press Enter to continue..."
					write-host
					write-host

}




2{


#####################################################################
#  Set Time Zone +  Language 
#####################################################################


# Section 1: information 

				clear-host

				write-host
				write-host
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
				write-host  -ForegroundColor white		Information                                                                                          
				write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
				write-host  -ForegroundColor white  	"This command will set the following Mailbox settings:"  
				write-host  -ForegroundColor white  	"1. Time Zone - Pacific Standard Time "
				write-host  -ForegroundColor white  	"2. Language - English USA "
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
				write-host  -ForegroundColor Magenta	oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                          
				write-host  -ForegroundColor white  	'The PowerShell command that we use is: '
				write-host  -ForegroundColor Yellow  	'Set-MailboxRegionalConfiguration -identity <User> -TimeZone "Pacific Standard Time" Language en-US"'
				write-host  -ForegroundColor white		----------------------------------------------------------------------------  	                                  
				write-host
				write-host

					# Section 2: user input	
					
					write-host -ForegroundColor white	'User input '
					write-host -ForegroundColor white	---------------------------------------------------------------------------- 
					write-host -ForegroundColor Yellow	"You will need to provide 2 parameters:"  
					write-host
					write-host -ForegroundColor Yellow	"1. Mailbox name of user name  "  
					write-host -ForegroundColor Yellow	"For example:  John@o365info.com ( Manager Mailbox )"
					write-host
					$UserName  = Read-Host "Type the Mailbox name of user that you want to assign Full Access permission "
					write-host
					write-host

					#Section 3: PowerShell Command

					Set-MailboxRegionalConfiguration -identity $UserName -TimeZone "Pacific Standard Time" Language en-US



					write-host
					write-host


					#Section 4: Display Information

					write-host ---------------------------------------------------------------------------
					write-host -ForegroundColor white	 Time Zone for $UserName  mailbox 
					write-host ---------------------------------------------------------------------------

					get-MailboxRegionalConfiguration -identity $UserName  | Out-String



					#Section 5:  Indication 


					write-host 
					if ($lastexitcode -eq 1)
					{
						write-host "The command Failed :-(" -ForegroundColor red
					}
					else
					{
							
						write-host -------------------------------------------------------------
						write-host -ForegroundColor Yellow	"The command complete successfully !" 
						write-host
						write-host -ForegroundColor Yellow	"The Time Zone for user:  "
						write-host -ForegroundColor White	$UserName.ToUpper() 
						write-host -ForegroundColor Yellow	"was set to: "	
						write-host -ForegroundColor white	"Pacific Standard Time"
						write-host -ForegroundColor Yellow	"The Language was set to: "
						write-host -ForegroundColor white	"en-US"
						write-host -------------------------------------------------------------
						
					}

					# End of Indication 

					write-host
					write-host
					Read-Host "Press Enter to continue..."
					write-host
					write-host


}



3{


#####################################################################
#  Set Time Zone +  Language + Date Format + Time Format
#####################################################################


# Section 1: information 

				clear-host

				write-host
				write-host
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
				write-host  -ForegroundColor white		Information                                                                                          
				write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
				write-host  -ForegroundColor white  	"This command will set the following Mailbox settings:"  
				write-host  -ForegroundColor white  	"1. Time Zone - Pacific Standard Time "
				write-host  -ForegroundColor white  	"2. Language - English USA "
				write-host  -ForegroundColor white  	"3. Date Format dd/MM/yyyy  Time Format h:mm tt "		
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
			  	write-host  -ForegroundColor white  	'The PowerShell command that we use is: '
				write-host  -ForegroundColor Yellow  	'Set-MailboxRegionalConfiguration -identity $UserName -TimeZone "Pacific Standard Time" Language en-CA -DateFormat "dd/MM/yyyy" -TimeFormat "h:mm tt"'
				write-host  -ForegroundColor white		----------------------------------------------------------------------------  	                                  
				write-host
				write-host


					# Section 2: user input	
					
					write-host -ForegroundColor white	'User input '
					write-host -ForegroundColor white	---------------------------------------------------------------------------- 
					write-host -ForegroundColor Yellow	"You will need to provide 2 parameters:"  
					write-host
					write-host -ForegroundColor Yellow	"1. Mailbox name of user name  "  
					write-host -ForegroundColor Yellow	"For example:  John@o365info.com ( Manager Mailbox )"
					write-host
					$UserName  = Read-Host "Type the Mailbox name of user that you want to assign Full Access permission "
					write-host
											write-host

						# Section 3: PowerShell Command

						Set-MailboxRegionalConfiguration -identity $UserName -TimeZone "Pacific Standard Time" Language en-CA -DateFormat "dd/MM/yyyy" -TimeFormat "h:mm tt"


						write-host
						write-host


						# Section 4: Display Information

						write-host ---------------------------------------------------------------------------
						write-host -ForegroundColor white	 Time Zone for $UserName  mailbox 
						write-host ---------------------------------------------------------------------------

						get-MailboxRegionalConfiguration -identity $UserName  | Out-String



						#Section 5:  Indication 


						write-host 
						if ($lastexitcode -eq 1)
						{
							write-host "The command Failed :-(" -ForegroundColor red
						}
						else
						{
								
							write-host -------------------------------------------------------------
							write-host -ForegroundColor Yellow	"The command complete successfully !" 
							write-host
							write-host -ForegroundColor Yellow	"The Time Zone for user:  "
							write-host -ForegroundColor White	$UserName.ToUpper() 
							write-host -ForegroundColor Yellow	"was set to: "	
							write-host -ForegroundColor white	"Pacific Standard Time"
							write-host -ForegroundColor Yellow	"The Language was set to: "
							write-host -ForegroundColor white	"en-US"
							write-host -ForegroundColor Yellow	"The Date and Time Format was set to:  "
							write-host -ForegroundColor white	"Date: dd/MM/yyyy "
							write-host -ForegroundColor white	"Time: h:mm tt "
							write-host -------------------------------------------------------------
							
						}

						# End of Indication 

						write-host
						write-host
						Read-Host "Press Enter to continue..."
						write-host
						write-host


}



#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# Section B: Set Time Zone and Language (BULK Mode)
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



4{


#################################################################
#  Set Time zone on ALL Mailboxes (BULK Mode)
#################################################################


#Section 1: information & user input 

clear-host

				write-host
				write-host
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
				write-host  -ForegroundColor white		Information                                                                                          
				write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
				write-host  -ForegroundColor white  	"This command will set the Time zone on ALL mailboxes to: Pacific Standard Time"                                                             
				write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
			  	write-host  -ForegroundColor white  	'The PowerShell command that we use is: '
				write-host  -ForegroundColor Yellow  	'$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}'
				write-host  -ForegroundColor Yellow  	'$users | %{Set-MailboxRegionalConfiguration $_.Identity -TimeZone "Pacific Standard Time"}'
				write-host  -ForegroundColor white		----------------------------------------------------------------------------  	                                  
				write-host
				write-host

					
				#Section 2: PowerShell Command
					
				$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
				$users | %{Set-MailboxRegionalConfiguration $_.Identity -TimeZone "Pacific Standard Time"}



				#Section 3:  Indication 


				write-host 
				if ($lastexitcode -eq 1)
				{
					write-host "The command Failed :-(" -ForegroundColor red
				}
				else
				{
						
					write-host -------------------------------------------------------------
					write-host -ForegroundColor Yellow	"The command complete successfully !" 
					write-host
					write-host -ForegroundColor Yellow	"ALL Mailboxes Time Zone was set to:   "
					write-host -ForegroundColor White	"Pacific Standard Time" 
					write-host -------------------------------------------------------------
					
				}

				# End of Indication 



					
				#Section 4: Display Information

				write-host
				write-host
				write-host ----------------------------------------------------------------------------------------
				write-host -ForegroundColor white	  Display information about Time zone settings for all users 
				write-host ----------------------------------------------------------------------------------------


				$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
				$users  | Get-MailboxRegionalConfiguration   | Out-String



				#Section 5: End the Command

				write-host
				write-host
				Read-Host "Press Enter to continue..."
				write-host
				write-host


}




5{



#################################################################
#  Set Time zone and Language on ALL Mailboxes (BULK Mode)
#################################################################


# Section 1: information 

clear-host

write-host
write-host
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
write-host  -ForegroundColor white		Information                                                                                          
write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
write-host  -ForegroundColor white  	This command will set the Time zone on ALL mailboxes to: Pacific Standard Time
write-host  -ForegroundColor white  	and Language to: en-US 	
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
write-host
write-host

	
#Section 2: PowerShell Command
	
$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
$users | %{Set-MailboxRegionalConfiguration $_.Identity -TimeZone "Pacific Standard Time" Language en-US }



#Section 3:  Indication 


write-host 
if ($lastexitcode -eq 1)
{
	write-host "The command Failed :-(" -ForegroundColor red
}
else
{
		
	write-host -------------------------------------------------------------
	write-host -ForegroundColor Yellow	"The command complete successfully !" 
	write-host
	write-host -ForegroundColor Yellow	"ALL Mailboxes Time Zone was set to:   "
	write-host -ForegroundColor White	"Pacific Standard Time" 
	write-host -------------------------------------------------------------
	
}

# End of Indication 



	
#Section 4: Display Information

write-host
write-host
write-host ----------------------------------------------------------------------------------------
write-host -ForegroundColor white	  Display information about Time zone settings for all users 
write-host ----------------------------------------------------------------------------------------


$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
$users  | Get-MailboxRegionalConfiguration   | Out-String



#Section 5: End the Command

write-host
write-host
Read-Host "Press Enter to continue..."
write-host
write-host


}




6{


###########################################################
# Correct Time Zone setting for Mailbox with wrong time zone  (BULK Mode) 
#################################################################

# Section 1: information 

clear-host

write-host
write-host
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
write-host  -ForegroundColor white		Information                                                                                          
write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
write-host  -ForegroundColor white  	"The following command look for all the Mailboxs that dont use Pacific Standard Time zone" 
write-host  -ForegroundColor white  	"and set the set the Time zone to: Pacific Standard Time"                                                              
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
write-host
write-host


#Section 2: PowerShell Command

$mymailboxes = get-mailbox 
ForEach ($examinedmailbox in $mymailboxes){ 
$regionalconfig = get-MailboxRegionalConfiguration identity $examinedmailbox.identity 
if ($regionalconfig.timezone -ne "Pacific Standard Time"){ 
Set-MailboxRegionalConfiguration -identity $examinedmailbox.identity -TimeZone "Pacific Standard Time" -confirm:$False 
} 
}

	

#Section 3:  Indication 


write-host 
if ($lastexitcode -eq 1)
{
	write-host "The command Failed :-(" -ForegroundColor red
}
else
{
		
	write-host -------------------------------------------------------------
	write-host -ForegroundColor Yellow	"The command complete successfully !" 
	write-host
	write-host -ForegroundColor Yellow	"ALL Mailboxes Time Zone was set to:   "
	write-host -ForegroundColor White	"Pacific Standard Time" 
	write-host -------------------------------------------------------------
	
}

# End of Indication 


	

#Section 4: Display Information

write-host
write-host
write-host ----------------------------------------------------------------------------------------
write-host -ForegroundColor white	  Display information about Time zone settings for all users 
write-host ----------------------------------------------------------------------------------------


$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
$users  | Get-MailboxRegionalConfiguration   | Out-String



#Section 5: End the Command

write-host
write-host
Read-Host "Press Enter to continue..."
write-host
write-host

}






#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#Section C: Display Information about Time Zone and Language
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<



7{


###########################################################
# Display a list of time zones you can use
#################################################################

# Section 1: information 

clear-host

write-host
write-host
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
write-host  -ForegroundColor white		Information                                                                                          
write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
write-host  -ForegroundColor white  	This command will display a list of time zones you can use:                                                             
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
write-host
write-host
write-host
write-host

#Section 2: PowerShell Command

write-host ---------------------------------------------------------------------------
write-host -ForegroundColor white	 Display a list of time zones you can use:
write-host ---------------------------------------------------------------------------

Get-ChildItem "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Time zones" | FL pschildname  | Out-String

#Section 3: End the Command

write-host
write-host
Read-Host "Press Enter to continue..."
write-host
write-host


}







8{


###########################################################
# Display information about Time Zone and Language for a specific user 
#################################################################

# Section 1: information 

clear-host

write-host
write-host
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
write-host  -ForegroundColor white		Information                                                                                          
write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
write-host  -ForegroundColor white  	This command will Display the Time Zone and Language settings for $UserName Mailbox                                                                
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
write-host
write-host


					# Section 2: user input	
					
					write-host -ForegroundColor white	'User input '
					write-host -ForegroundColor white	---------------------------------------------------------------------------- 
					write-host -ForegroundColor Yellow	"You will need to provide 2 parameters:"  
					write-host
					write-host -ForegroundColor Yellow	"1. Mailbox name of user name  "  
					write-host -ForegroundColor Yellow	"For example:  John@o365info.com ( Manager Mailbox )"
					write-host
					$UserName  = Read-Host "Type the Mailbox name of user that you want to assign Full Access permission "
					write-host
					write-host


						#Section 3: PowerShell Command

						write-host ---------------------------------------------------------------------------
						write-host -ForegroundColor white	Time Zone for $UserName  mailbox 
						write-host ---------------------------------------------------------------------------

						get-MailboxRegionalConfiguration -identity $UserName  | Out-String


						#Section 4: End the Command

						write-host
						write-host
						Read-Host "Press Enter to continue..."
						write-host
						write-host


}



9{


###########################################################
# Display Time zone and Language settings for all users 
#################################################################

# Section 1: User notification

clear-host

write-host
write-host
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                        
write-host  -ForegroundColor white		Information                                                                                          
write-host  -ForegroundColor white		--------------------------------------------------------------------                                                           
write-host  -ForegroundColor white  	Display Time zone and Language settings for all users                                                            
write-host  -ForegroundColor Magenta	ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo                                         
write-host
write-host
write-host
write-host


#Section 4: Display Information

write-host
write-host
write-host ----------------------------------------------------------------------------------------
write-host -ForegroundColor white	  Display information about: Time zone and Language settings for all users 
write-host ----------------------------------------------------------------------------------------


$users = Get-Mailbox -ResultSize unlimited -Filter {(RecipientTypeDetails -eq 'UserMailbox')}
$users  | Get-MailboxRegionalConfiguration   | Out-String



#Section 5: End the Command

write-host
write-host
Read-Host "Press Enter to continue..."
write-host
write-host


}




		
						
				 
				#+++++++++++++++++++
				# Step -05 Finish  
				##++++++++++++++++++
				 
				 
				10{

				##########################################
				# Disconnect PowerShell session  
				##########################################


				write-host -ForegroundColor Yellow Choosing this option will Disconnect the current PowerShell session 

				Function Disconnect-ExchangeOnline {Get-PSSession | Where-Object {$_.ConfigurationName -eq "Microsoft.Exchange"} | Remove-PSSession}
				Disconnect-ExchangeOnline -confirm

				write-host
				write-host

				# Indication 

				if ($lastexitcode -eq 0)
				{
					write-host -------------------------------------------------------------
					write-host "The command complete successfully !" -ForegroundColor Yellow
					write-host "The PowerShell session is disconnected" -ForegroundColor Yellow
					write-host -------------------------------------------------------------
				}
				else

				{
					write-host "The command Failed :-(" -ForegroundColor red
					
				}

				# End of Indication 


				}




				11{

				##########################################
				# Exit  
				##########################################


				$Loop = $true
				Exit
				}

				}


				}
