Zitrox GmbH Blog

Zitrox GmbH Technology Blog

Archives for Microsoft

Powershell: Bulk list configured DNS Servers Script

Folgendes Powershell Script kann verwendet werden, um die DNS Einstellungen auf der Netzwerkverbindung auszulesen

Get-Content C:\temp\serverlist.txt |
ForEach-Object {
Get-WMIObject Win32_NetworkAdapterConfiguration -Computername $_ | `
Where-Object {$_.IPEnabled -match “True”} | `
Select-Object -property DNSHostName,DNSServerSearchOrder }

Powershell Bulk change DNS Settings, DNS Einstellungen Modifizieren

Um DNS Einstellungen mit Powershell zu modifizieren, müsst Ihr Euch eine Liste mit den Servernamen unter z.B. c:\temp\servers.txt ablegen. Die Namen müssen Zeile für Zeile gelistet sein, z.B:

server1
server2
server3

Danach muss folgendes PowerShell Script ausgeführt werden:

function Set-DNSWINS {
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $_ -Filter 'IPEnabled=TRUE'

foreach($NIC in $NICs) {
$DNSServers = "192.168.88.26","192.168.88.29"
$NIC.SetDNSServerSearchOrder($DNSServers)
$NIC.SetDynamicDNSRegistration('TRUE')
}
}


function Get-FileName {
$computer = Read-Host 'Path to Filename of computer names?'
return $computer
}


$f = Get-FileName
Get-Content $f | foreach {Set-DNSWINS}

Netzwerk Verbindungen schnell Anzeigen in Windows Server 2008

Folgendes Kommando öffnet direkt die Netzwerkverbindungen bei einem Windows Server 2008:
ncpa.cpl
(NetworkConnectionPanel)

How to restore Exchange 2010 Mailbox Database mit Dataprotector

1. Restore Datenbank mit Dataprotector zu temporärer alternativen location. Zum Beispiel h:\extemp\
2. Logfiles aus dem Subolder in den Hauptfolder moven wo die die Datenbank (.edb) liegt. (z.B. h:\extemp\exchange\dbit zu h:\extemp\exchange
3. Nachdem die Datenbank komplett zurückgespeichert wurde, muss eine Recovery Datenbank angelegt werden (über Powershell auf dem tangierten Mailboxserver)
New-MailboxDatabase -Recovery -Name DBIT_Restore -Server MBxsv001 -EdbFilePath “H:\extemp\exchange\dbit.edb” -LogFolderPath “H:\extemp\exchange”
4. Den Status der Datenbank kontrollieren und überprüfen ob alle Logs vorhanden sind welche benötigt werden, dazu mit Powershell in das Verzeichnis welchseln wo die DB (.edb) liegt.
danach eseutil.exe -mh dbit.edb
5. Damit die Datenbank konsitent wird, müssen die Logs eingepsielt werden: eseutil /R E00 /I /D
6. Danach kann die Datenbank gemounted werden: mount-database “DBIT_Restore”
7. Mit: get-mailboxstatistics-database “DBIT_Restore” kann ausfindig gemacht werden, welche Mailboxen in der Datenbank vorhanden sind.
8. Nun kann die gewünschte Mailbox gerestored werden:
Restore-Mailbox -Identity “red3it” -RecoveryDatabase “DBIT_Restore”
9. Falls die Mailbox einem anderen User als Zusätzlicher Ordner gerestored werden soll, kann folgendes Kommando ausgeführt werden:

Restore-Mailbox -Identity Administrator -RecoveryDatabase “DBIT_Restore” -RecoveryMailbox redit3 -TargetFolder Recovery_redit3

How to remove Public Folder Replicas Exchange 2007

If you want to uninstall Exchange 2007, you will probably get an error message, indicating that you still have public folder replicas.

User following cmdlet to remove the Public Folder and Public Folder Replicas:

Get-PublicFolder -server SERVERNAME “\” -Recurse -ResultSize:Unlimited | Remove-PublicFolder -server coroico -Recurse -ErrorAction:SilentlyContinue
Get-PublicFolder -Server SERVERNAME “\Non_Ipm_Subtree” -Recurse -ResultSize:Unlimited | Remove-PublicFolder -Server coroico -Recurse -ErrorAction:SilentlyContinue

How to delete Outlook Adress list cache

Delete the .nk2 file. This is located in:

Vista:
%USERPROFILE%\AppData\Roaming\Microsoft\Outlook\*.nk2
XP:
%USERPROFILE%\Anwendungsdaten\Microsoft\Outlook\*.nk2

You can also create a GPO to remove this file.

Exchange 2007/ 2010: Unable to relay 5.7.1

If you have applications which need to send emails through the Exchange 2007 Receive Connecter, even if you allow the anonymous user on the Permission Groups of the connecter, the anonymous user is not allowed to relay to Email Adresses outside the corporation.

Therefore you get following error:

550 5.7.1 Unable to relay

5.7.1: The sender is not authorized to send e-mail messages to this e-mail address. Possible causes: 1)The session is not authenticated and does not have the ‘ms-Exch-SMTP-Submit’ permission. 2)The session is authenticated but does not have the ‘ms-Exch-SMTP-Submit’ permission. 3)The ‘MAIL FROM’ command specified an address at an authoritative domain and the session does not have the ‘ms-Exch-SMTP-Accept-Authoritative-Domain-Sender’ permission. 4)The authenticated user does not have permission to submit on behalf of the sender address specified in the header of the message and the session does not have the ‘ms-Exch-SMTP-Accept-Any-Sender’ permission. 5)The recipient domain does not match any of the accepted domains and the session does not have the ‘ms-Exch-SMTP-Accept-Any-Recipient’ permission. 6)The recipient domain is rejecting all mail from this server using a block list.

Use following cmdlet to enable relaying for anonymous user:

Get-ReceiveConnector “Default ex1″ | Add-ADPermission -User “NT Authority\Anonymous logon” -ExtendedRights “ms-Exch-SMTP-accept-Any-Recipient”

Exchange 2007: After ADMT Migration, some mailboxes are marked as linked mailbox

If you have used ADMT and PowerShell for a cross domain migration, some mailboxes are listed as linked mailbox.

I have searched a whole fuc..ing night to figure out what caused this linked mailbox behavior!

Here the Solutions:

Make sure, that on the source server, no unmatched SID on the advanced Exchange Security Permission and Owner TAB are listed!

On SOURCE Server

- Show Advanced Features in ADUC

Open the user with the mailbox migrated as linked mailbox => Click on Exchange – Advanced => Click on Mailbox rights, Make sure no unmatched SID is listed

Also open Advanced => Owner and Make sure the Owner still exists and has also been migrated to the targed Host!

Exchange 2007: After migration, mailbox is shown as legacy mailbox

If you migrated a mailbox from another Exchange System (2000/2003) mailboxes are sometimes migrated as legacy mailbox.

To fix this issue, user following cmdlet in PowerShell:

Set-Mailbox -Identity mailboxname -ApplyMandatoryProperties

Active Directory How to export / import Contacts

It is not possible to migrate contact objects with ADMT (3.1)

To export contacts from active directory, you can simply use followin command

ldifde -f contacts.ldf -d “ou=Contacts,dc=testlab,dc=corp” -r (“objectClass=contact”) -l objectClass,sn,givenName,displayName,proxyaddresses,importedFrom,targetAddress,mailNickname,name,mail

This would export all contacts from the OU Contacts. If you want to export all contact objects, simply use following command:

ldifde -f contacts.ldf -d “dc=testlab,dc=corp” -r (“objectClass=contact”) -l objectClass,sn,givenName,displayName,proxyaddresses,importedFrom,targetAddress,mailNickname,name,mail

You can import the contacts.ldf with following command:

ldifde -i -f contacts.ldf

This will only work, if you import the contacts to the same AD Structure.

If you want to import the contacts on another AD Domain, you have to modify the contacts.ldf with an Editor and replace the LDAP Path to your needs. E.g:

dn: CN=Contact1,OU=MigrateContacts,DC=testlab2,DC=corp
changetype: add
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: contact
givenName: Contact1

displayName: Contact1

proxyAddresses: SMTP:

digital@testlab.ch

Diese E-Mail-Adresse ist gegen Spambots geschützt! JavaScript muss aktiviert werden, damit sie angezeigt werden kann.


proxyAddresses: smtp:

contact1@testlab.de

Diese E-Mail-Adresse ist gegen Spambots geschützt! JavaScript muss aktiviert werden, damit sie angezeigt werden kann.


proxyAddresses: smtp:

contact1@testlab.at

Diese E-Mail-Adresse ist gegen Spambots geschützt! JavaScript muss aktiviert werden, damit sie angezeigt werden kann.


proxyAddresses:
X400:c=CH;a= ;p=Testlab;o=Testlab;s=Contact1?CH;ou1=TestOU;
targetAddress: SMTP:

digital@testlab.ch

Diese E-Mail-Adresse ist gegen Spambots geschützt! JavaScript muss aktiviert werden, damit sie angezeigt werden kann.


mailNickname: ContactH
name: Contact_CH
mail:

digital@testlab.ch

Page 1 of 2:1 2 »