de-DEen-GB
 
rss

Just can't get enough of IT

This blog is about mostly anything in IT. But the primary focuses are Microsoft Technologies like Exchange, Office 365, Azure and Cloud Security.
On November 29, 2017
0 Comment
73 Views

An update to the PowerShell script (Set-ReceiveConnectorIpAddress) to add or remove remote IP address ranges to/from Exchange Server receive connectors is available.

A new parameter to provide a comment on why an IP address is added or removed has been added to the script.

# EXAMPLE 
.\Set-ReceiveConnectorIpAddress.ps1 -ConnectorName MyConnector -IpAddress 10.10.10.1 -Action Remove -ViewEntireForest $true -Comment 'Personal request of upper management'

Get the most recent version at Github

 

Read More »
On November 17, 2017
0 Comment
158 Views
Last updated: 2017-11-28

Exchange Server 2013Exchange Server 2016Description

This script adds or removes IP addresses or IP address ranges to/from existing Receive Connectors.

The input file can contain more than one IP address (range), one entry per line. The IP address parameter can be used to add a single IP address.

The script creates a new sub directory beneath the current location of the script. The script utilizes the directory as a log directory to store the current remote IP address ranges prior modification.

A log is written to the \log subfolder utilitzing the GlobalFunctions Logger object.

Requirements

  • Registered GlobalModules PowerShell module, http://scripts.granikos.eu
  • Windows Server 2016, Windows Server 2012 R2, Windows Server 2008 R2 SP1
  • Exchange ManagementShell 2013+
  • Optionally, a txt file containing new remote IP address ranges, one per line
    Example:
    192.168.1.1
    192.168.2.10-192.168.2.20
    192.168.3.0/24

 

Examples

# Example 1
# Add all IP addresses stored in D:\Scripts\ip.txt to a receive connector named RelayConnector

.\Set-ReceiveConnectorIpAddress.ps1 -ConnectorName RelayConnector -FileName D:\Scripts\ip.txt -Action Add
# Example 2
# Remove IP address 10.10.10.1 from a receive connector nameds MyConnector from all Exchange Servers in the forest

.\Set-ReceiveConnectorIpAddress.ps1 -ConnectorName MyConnector -IpAddress 10.10.10.1 -Action Remove -ViewEntireForest $true

Version History

  • 1.0, Initial community release
  • 1.1, Comment parameter added

Links

Follow

Read More »
On November 2, 2017
0 Comment
103 Views

You want to know about the right on-premises Exchange Server architecture? A blog post about this topic has been published on the ESE blog yesterday.

The right Exchange Architecture

Read the full blog post at ENow's ESE blog.

Enjoy reading.

Read More »

The PowerShell script to purge Exchange Server and IIS log files has been updated to version 2.1.

The function Copy-LogFiles has been slightly rewritten and there has been a change in the cmdlet parameters.

When using ArchiveMode CopyAndZip or CopyZipAndDelete all copied log files in the EXCHANGESERVER\LOGS folder are added to a compressed archive. The script creates a separate archive for IIS and Exchange logs.

Example of compressed archive files

 Code updated

function Copy-LogFiles {
  [CmdletBinding()]
  param(
    [string]$SourceServer,
    [string]$SourcePath,
    $FilesToMove,
    [string]$ArchivePrefix = ''
  )

  if($SourceServer -ne '') { 

    # path per SERVER for zipped archives
    $ServerRepositoryPath = Join-Path -Path $RepositoryRootPath -ChildPath $SourceServer

    # subfolder used as target for copying source folders and files
    $ServerRepositoryLogsPath = Join-Path -Path $ServerRepositoryPath -ChildPath $LogSubfolderName

    $ServerRepositoryPath = Join-Path -Path $RepositoryRootPath -ChildPath $SourceServer

    if(!(Test-Path -Path $ServerRepositoryPath)) {

      # Create new target directory for server, if does not exist
      $null = New-Item -Path $ServerRepositoryPath -ItemType Directory -Force -Confirm:$false

    }

    foreach ($File in $FilesToMove) {
      # target directory
      $targetDir = $File.DirectoryName.Replace($TargetServerFolder, $ServerRepositoryLogsPath)

      # target file path
      $targetFile = $File.FullName.Replace($TargetServerFolder, $ServerRepositoryLogsPath)
      
      # create target directory, if not exists
      if(!(Test-Path -Path $targetDir)) {$null = mkdir -Path $targetDir}

      # copy file to target
      $null = Copy-Item -Path $File.FullName -Destination $targetFile -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue

    }    
    
    if($ZipArchive) {
      # zip copied log files
      
      $Archive = Join-Path -Path $ServerRepositoryPath -ChildPath ('{0}-{1}' -f $ArchivePrefix, $ArchiveFileName)
      $logger.Write(('Zip copied files to {0}' -f $ArchiveFileName))
      
      # delete archive file, if already exists
      if(Test-Path -Path $Archive) {Remove-Item -Path $Archive -Force -Confirm:$false}

      try {
        # create zipped asrchive
        Add-Type -AssemblyName 'System.IO.Compression.FileSystem'
        [IO.Compression.ZipFile]::CreateFromDirectory($ServerRepositoryLogsPath,$Archive)
      }
      catch {
        $logger.Write(('Error compressing files from {0} to {1}' -f $ServerRepositoryLogsPath, $Archive),3)      
      }
      finally {

        # cleanup, if compression was successful
        if($DeleteZippedFiles) {

          $logger.Write(('Deleting folder {0}' -f $ServerRepositoryLogsPath))
          $null = Remove-Item -Path $ServerRepositoryLogsPath -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue

        }
      }
    } 
  }  
}

 

Note

Links

Social

 

 

Read More »

When you run the following cmdlet to prepare Active Directory for the installation of an Exchange Server Cumulative Update (in this case CU17) you might encounter a System.UnauthorizedAccessException

D:\tmp\Cu17>setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms

Microsoft Exchange Server 2013 Cumulative Update 17 Unattended Setup


Unhandled Exception: System.UnauthorizedAccessException: Access to the path 'C:\
Windows\Temp\ExchangeSetup\ExSetup.exe' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.SetAttributes(String path, FileAttributes fileAttributes)
   at Microsoft.Exchange.Setup.CommonBase.SetupHelper.DeleteDirectory(String pat
h)
   at Microsoft.Exchange.Bootstrapper.Setup.BootstrapperBase.CopySetupBootstrapp
erFiles()
   at Microsoft.Exchange.Bootstrapper.Setup.Setup.Run()
   at Microsoft.Exchange.Bootstrapper.Setup.BootstrapperBase.MainCore[T](String[
] args)
   at Microsoft.Exchange.Bootstrapper.Setup.Setup.Main(String[] args)

 

There is a simple reason for the the System.UnauthorizedAccessException:

  • .NET Framework Optimization Service 

The required .NET Framework 4.6.2 had been installed just minutes before executing setup.exe. Preparation of the Active Directory schema ran without any issues. But when the /PrepareSchema call finished, the temporary folder in C:\Windows\Temp\ExchangeSetup could not be fully cleaned up, as mscorsvw.exe had an open file handle on ExSetup.exe.

Additionally, when you run Setup.exe and the folder C:\Windows\Temp\ExchangeSetup exists, the setup will not try to copy required installation files. Regardless if the folder files exists in the folder or not.

.NET Optimization process running

Solution

  • End both mscorsw.exe processes or wait until both process have finished optimizing your .NET Framework applications
  • Manully delete the folder C:\Windows\Temp\ExchangeSetup
  • Run the required Exchange setup step again
D:\tmp\Cu17>setup.exe /PrepareAD /IAcceptExchangeServerLicenseTerms

Microsoft Exchange Server 2013 Cumulative Update 17 Unattended Setup

Copying Files...
File copy complete. Setup will now collect additional information needed for
installation.

Performing Microsoft Exchange Server Prerequisite Check

    Prerequisite Analysis                                     COMPLETED

Configuring Microsoft Exchange Server

    Organization Preparation                                  COMPLETED

The Exchange Server setup operation completed successfully.

 

Enjoy Exchange!

 

 

 

 

 

 

Read More »