While trying to synchronize a new device with an Exchange mailbox, you receive an error with your new mobile phone partnership.
The Exchange Server 2010 Default Throttling Policy is configured to accept 10 ActiveSync devices per mailbox only.
You can validate this setting by using EMS
Get-ThrottlingPolicy def* | Select Name,EASMaxDevices
Use a scheduled PowerShell script to delete old ActiveSync Device partnerships that have not been used for a defined period of time.
Find the most recent version on TechNet Gallery and Github, following the links provided in the Links section.
Modifiy the script path variables to fit your requirements. The variables are configured in the ### BEGIN Variables section.
Steps being executed:
<# .SYNOPSIS Remove Exchange Server 2010 ActiveSync Device Partnerships Sebastian Rubertus / Thomas Stensitzki THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER. Send comments and remars to: support@granikos.eu Version 1.0, 2015-04-09 .LINK More information can be found at http://www.rubertus.net/Blog/tabid/85/EntryId/41/Scripted-removing-of-ActiveSync-Device-Partnerships.aspx .DESCRIPTION THis script removes ActiveSync device association from user mailboxes that have been inactive for more than 150 days. .NOTES Requirements - Exchange Server 2010 - Windows Server 2008 R2 SP1, Windows Server 2012 or Windows Server 2012 R2 Revision History -------------------------------------------------------------------------------- 1.0 Initial community release .EXAMPLE Remove-ActiveSyncDevicePartnership #> ### BEGIN SnapIns ------------------------------------------------------------- # Add Exchange SnapIn if not already loaded if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue if ( (Get-PSSnapin -Name Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "Microsoft.Exchange.Management.PowerShell.Admin could NOT be loaded!" -ForegroundColor Red Write-Host "Verify that the Exchange 2010 Management is installed on this computer!" -ForegroundColor Red } } ### END SnapIns --------------------------------------------------------------- ### BEGIN Variables | EDIT ACCORDING TO YOUR NEEDS ---------------------------- # ScriptPath $scriptPath = "C:\Scripts\Remove-ActiveSync-Devices\" # Logfile $logfile = "C:\Scripts\Remove-ActiveSync-Devices\Logs\$(get-date -format yyyy-MM-dd___HH-mm-ss)___Logname.log" ### END Variables ------------------------------------------------------------- ### BEGIN Functions ----------------------------------------------------------- Function Log { Param ([string]$logstring) Add-content $logfile -value "$(get-date -format yyyy-MM-dd___HH-mm-ss) $logstring " } ### END Functions ------------------------------------------------------------- ### BEGIN Main ---------------------------------------------------------------- # Create a new log file Write-Host Write-Host "Script started, creating Log File." Log "Script started." Write-Host # Query User Mailboxes and Device Statistics Write-Host "Querying User Mailboxes, please wait a few seconds..." -ForeGroundColor green Log "Querying User Mailboxes." Write-Host $Mailboxes = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited -WarningAction SilentlyContinue $NumberOfMailboxes = $Mailboxes.count Write-Host "Number of Mailboxes: $NumberOfMailboxes " Log "Number of Mailboxes: $NumberOfMailboxes " Write-Host # Iterate each User Mailbox ForEach ($Mailbox in $Mailboxes) { $MailboxAlias = $Mailbox.Alias Write-Host Write-Host "=================================================================================" Write-Host Write-Host "Getting ActiveSync Devices from user $MailboxAlias..." Log "Getting ActiveSync Devices from user $MailboxAlias. " $AllDevicesFromSpecificUser = Get-ActiveSyncDevice -Mailbox $MailboxAlias -Result Unlimited -WarningAction SilentlyContinue | Get-ActiveSyncDeviceStatistics -WarningAction SilentlyContinue $AllDevicesFromSpecificUserNotSynchronizedSince150Days = Get-ActiveSyncDevice -Mailbox $MailboxAlias -Result Unlimited -WarningAction SilentlyContinue | Get-ActiveSyncDeviceStatistics -WarningAction SilentlyContinue | Where {$_.LastSuccessSync -le (Get-Date).AddDays("-150")} Write-Host $CountAllDevicesFromSpecificUser = $AllDevicesFromSpecificUser.Count $CountAllDevicesFromSpecificUserNotSynchronizedSince150Days = $AllDevicesFromSpecificUserNotSynchronizedSince150Days.Count If ($CountAllDevicesFromSpecificUser -lt 5) { Write-Host "User $MailboxAlias has only $CountAllDevicesFromSpecificUser ActiveSync Devices. Nothing to delete!" -ForegroundColor Green Log "User $MailboxAlias has only $CountAllDevicesFromSpecificUser ActiveSync Devices. Nothing to delete!" } If (($CountAllDevicesFromSpecificUser -gt 4) -and ($CountAllDevicesFromSpecificUserNotSynchronizedSince150Days -gt 1)) { Write-Host "User $MailboxAlias has $CountAllDevicesFromSpecificUser devices. $CountAllDevicesFromSpecificUserNotSynchronizedSince150Days have not synced for more than 150 days." -ForegroundColor Red Log "User $MailboxAlias has $CountAllDevicesFromSpecificUser devices. $CountAllDevicesFromSpecificUserNotSynchronizedSince150Days have not synced for more than 150 days." ForEach ($Device in $AllDevicesFromSpecificUserNotSynchronizedSince150Days) { $DeviceType = $Device.DeviceType $DeviceFriendly = $Device.FriendlyName $DeviceID = $Device.DeviceID $DeviceFirstSyncTime = $Device.FirstSyncTime $DeviceLastSuccessSync = $Device.LastSuccessSync Write-Host Write-Host "ActiveSync Device 2 delete Properties: " Write-Host "-------------------------------------- " Write-Host "Type : $DeviceType " Write-Host "Friendly Name: $DeviceFriendly " Write-Host "ID : $DeviceID " Write-Host "Last Sync : $DeviceLastSuccessSync " -ForegroundColor Red Log "Removing Device $DeviceType with ID $DeviceID ..." Write-Host Write-Host "Removing Device $DeviceID ..." -ForegroundColor Red $Device | Remove-ActiveSyncDevice -WarningAction SilentlyContinue } } } # Script finished Write-Host Write-Host "Script finished!" Write-Host Log "Script finished!" ### END Main ------------------------------------------------------------------
You need assistance with your Exchange Server setup? You have questions about your Exchange Server infrastructure and going hybrid with Office 365? Contact us at office365@granikos.eu or visit our website http://www.granikos.eu.
Der Start mit Microsoft 365 ist nicht immer so einfach. Im Internet findet man ein Vielzahl an Informationen, weiß jedoch nicht sofort, welche Quellen "gute" Quellen sind und welche eher "nebulösen" Charakter haben.
Die folgenden Links sollen Ihnen den Einstieg in das Thema Microsoft 365 und in die Verwaltung der Clouddienste erleichtern.
Folgende PowerShell Module benötigen Sie für die Verwaltung von Microsoft 365.
# Import des PowerShell-Modules Install-Module -Name AzureAD # Aufbau einer Verbindung zu Azure AD des globalen Office 365 Angebotes Connect-AzureAD # Aufbau einer Verbindung zu Azure AD des globalen Office 365 Angebotes (solange noch verfügbar) Connect-AzureAD -AzureEnvironmentName AzureGermanyCloud
# Direkte Installation über die PowerShell Gallery Install-Module -Name Microsoft.Online.SharePoint.PowerShell # Import des SharePoint Online PowerShell-Modules Import-Module -Name Microsoft.Online.SharePoint.PowerShell # Festlegung des UPN-Anmeldenamen des SharePoint-Administrators $UPN = 'user@varunagroup.de' # Beispiel UPN # Festlegung des Office 365 Tenant-Namen $SPOOrgName = 'VARUNAGROUP' # Beispiel Organisation # Festlegung der Anmeldedaten # Bei NUtzung von MFA muss das App-Kennwort verwendet werden $Credential = Get-Credential -UserName $UPN -Message "Geben Sie Ihr Kennwort ein." # Aufbau der Verbindung zu SharePoint Online OHNE MFA Connect-SPOService -Url "https://$($SPOOrgName)-admin.sharepoint.com" -Credential $Credential
# Aufbau der Verbindung zu SharePoint Online MIT MFA Connect-SPOService -Url "https://$($SPOOrgName)-admin.sharepoint.com"
# Installation des PowerShell-Modules Install-Module -Name ExchangeOnlineManagement # Aufbau einer Verbindung zu Exchange Online # Nach der Verbindung können Sie V2-Cmdlets und ältere EXO-Cmdlets nutzen Connect-ExchangeOnline -UserPrincipalName admin@varunagroup.de
Hinweis
Mit dem PowerShell Cmdlet Connect-EXOPSSession können Sie sich auch in der Azure Cloud Shell mit Exchange Online verbinden und wie gewohnt verwalten. (Mehr erfahren)
# Aufbau der Verbindung zu Exchange Online mit dem EXO MFA PowerShell-Modul V1 # zum globalen Office 365 Angebot Connect-EXOPSSession -UserPrincipalName admin@varunagroup.de # Beispiel UPN # zum deutschen Office 365 Angebot, solange verfügbar Connect-EXOPSSession -UserPrincipalName admin@varunagroup.de -ConnectionUri https://outlook.office.de/PowerShell-LiveID -AzureADAuthorizationEndPointUri https://login.microsoftonline.de/common # Beispiel UPN
# Import des PowerShell-Modules Import-Module -Name MicrosoftTeams # Aufbau einer Verbindung zu Microsoft Teams im globalen Office 365 Angebot Connect-MicrosoftTeams
Der Skype for Business Connector ist abgekündigt. Nutzen Sie das Microsoft Teams PowerShell Modul für alle Konfiguration rund um Teams und Enterprise Voice. Weitere Information finden Sie in diesem Artikel: Move from Skype for Business Online Connector to the Teams PowerShell module
# Verbindung zu Skype for Business Online # Dieses PowerShell-Modul wird auch zur Verwaltung von Microsoft Teams Funktionen verwendet # Import des Skype for Business PowerShell-Modules Import-Module -Name SkypeOnlineConnector # Administrator-Anmeldeinformation $Credential = Get-Credential # Erstellung einer neuen Skype for Business Online Session $SfBSession = New-CsOnlineSession -Credential $userCredential # Import der SfBSession in die aktuelle PowerShell-Session Import-PSSession SfBSession
# Import des Graph PowerShell-Modules Import-Module -Name Microsoft.Graph.Intune # Akzeptieren der administrativen Zugriffsberechtigungen (einmalig notwendig) Connect-MSGraph -AdminConsent # Aufbau einer Verbindung zu Microsoft Graph $UPN = 'admin@varunagroup.de' # Beispiel UPN $password = Read-Host -AsSecureString -Prompt "Enter password for $UPN" $Credential = New-Object System.Management.Automation.PSCredential ($UPN, $password) $Connection = Connect-MSGraph -PSCredential $Credential
Für eine vereinfachte administrative Anmeldung empfehle ich Ihnen das PowerShell-Skript Connect-O365.ps1 von Chris Goosen aus der TechNet Gallery.
# Installation des PowerShell-Modules Install-Module -Name MSCommerce # Import des PowerShell-Modules Import-Module -Name MSCommerce # Aufbau einer Verbindung zu Microsoft Commerce im globalen Office 365 Angebot Connect-MSCommerce
# Installation des PowerShell-Modules Install-Module O365ServiceCommunications # Import des installierten PowerShell-Modules Import-Module O365ServiceCommunications # Aufbau einer neuen PowerShell-Session # Funktioniert nur mit Basic Authentication, nicht mit MFA $cred = Get-Credential $session = New-SCSession -Credential $cred -Locale de-de # Beispiel der Serviceinformationen im zugeordneten Office 365-Mandanten Get-SCServiceInfo -SCSession $session
PowerShell Gallery: https://www.powershellgallery.com/packages/PSServicePrincipal
Projektseite: https://github.com/dgoldman-msft/PSServicePrincipal
Nachfolgend finden Sie eine Empfehlungsliste für Blogs, die ich regelmäßig als Informations- und Lernquelle nutze. Ebenso finden Sie Links zu Webseiten von Office 365-Experten, die interessante Informationen, jenseits von Blogartikeln, bereithalten.
Weitere technische Links finden Sie im Artikel Troubleshooting Links für Exchange, Office 365 und mehr.
Viel Spaß mit Microsoft 365.
The following PowerShell scripts have been published by our Exchange and Office 365 experts to the technical community at TechNet Gallery. Please use the GitHub repositories to report issues or to file feature requests.
Please send comments, wishes, and ideas to support@granikos.eu.
Enjoy!
Need assistance with your Exchange Server Organization? You plan to upgrade your Exchange Server Organization? You plan to migrate to Office 365? Contact us: info@granikos.eu
Update 2020-10-05: Fetch all remote SMTP servers from Exchange receive connector logs added Update 2020-05-25: TechNet Gallery links removed due to end of TechNet Gallery in mid-2020 Update 2020-02-07: Report for enabled client protocols, Exchange Environment Report - v2, Set thumbnailPhoto for AzureAD guest users added Update 2019-05-07: Export mailbox delegates and SMTP forwarding information added Update 2018-09-04: Add remote IP-address ranges to a receive connector added Update 2018-06-16: Manage Master Category List for Shared Mailboxes and Teams added Update 2018-04-29: Convert Word documents using PowerShell and Set Mailbox Item Private Flag added Update 2018-01-24: Create a new Room Mailbox with Security Groups added Update 2017-11-11: Export all user mailbox permissions added Update 2017-09-22: Remove Out-Of-Office rules from user mailbox added Update 2017-05-20: Parse email messages content for further processing and Update OWA vDir config across multiple servers added Update 2017-03-18: Fetch recently created public folders and Clear Private Flag on Mailbox Messages added Update 2017-02-22: Remove Orphaned HealthMailbox and SystemMailbox Accounts from MESO Container added Update 2017-02-17: Test Office 365 Domain Availability added Update 2017-02-13: Connect to Exchange Server 2013+ using remote PowerShell added Update 2017-02-07: Create Exchange internal/external Url based certificate requests, Create a scheduled task for Exchange Server 2013 added Update 2017-01-24: Gather Exchange Configuration Data added Update 2017-01-05: Export Messages from Transport Queue added Update 2016-11-29: Clean legacy public folder ACL added, Scripts categorized Update 2016-11-28: Add multiple legacy public folder replicas added Update 2016-08-18: Simple import of multiple PST files for a single user added Update 2016-07-28: Change IIS Log File settings Github Url added, Create a new Team Mailbox with Security Groups added Update 2016-06-04: GlobalFunctions added Update 2015-06-18: Copy-ReceiveConnector updated Update 2015-06-01: Exchange 2010 Public Folder Replication Report (UTF8 support) Update 2015-05-21: Copy anti-virus pattern to Exchange 2010/Exchange 2013 servers added Update 2014-12-10: Copy a receive connector from one Exchange Server to multiple Exchange Servers added
Viele Administratoren verzichten auf die digitale Signierung von eigene PowerShell-Skripten. Um solche PowerShell-Skripte in der lokalen IT-Infrastruktur ausführen zu können wird daher die PowerShell-Ausführungsrichtlinie auf Unrestricted konfiguriert. Diese Konfiguration ist ein großes Sicherheitsrisiko für das gesamte Unternehmen.
Unrestricted
Wenn das digitale Zertifikat zur Code-Signierung in Ihrem persönlichen Zertifikatsspeicher hinterlegt ist, ist die Signierung besonders einfach.
Wechseln Sie in einer PowerShell_Session in das Verzeichnis, das die zu signierende PowerShell-Datei enthält und signieren Sie die Datei mit den folgenden Befehlen. In diesem Beispiel wird die Datei MyPowerShellScript.ps1 signiert.
MyPowerShellScript.ps1
# Lesen des Signatur-Zertifikates aus dem persönlichen Zertifikatspeicher # des Anwenders, der die Signierung durchführt $cert=Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert # Lesen eines exportierten Signatur-Zertifikates aus einer PFX-Datei # Wenn der Export mit einem Kennwort geschützt ist, werden Sie nach # dem Kennwort gefragt $cert = Get-PfxCertificate -FilePath C:\SCRIPTS\CERTS\CodeSigningVarunagroup.pfx # Digitale Signierung der Datei MyPowerShellScript.ps1 Set-AuthenticodeSignature -FilePath MyPowerShellScript.ps1 -Certificate $cert
Wissenswert ist, dass das Cmdlet Get-PfxCertificate, im Gegensatz zur Dokumentation bei Microsoft Docs, keinen Parameter -Password verfügt, um das Kennwort als SecureString zu übergeben.
Get-PfxCertificate
-Password
Konfigurieren Sie nach der Signierung Ihrer PowerShell-Skripte die Ausführungsrichtlinie für Ihre Systeme mit Hilfe einer Gruppenrichtlinie.
Viel Spaß mit PowerShell!
In der heutigen Zeit ist die skriptbasierte Verwaltung von Server-Softwarelösungen aus der Arbeitswelt von Administratoren nicht mehr wegzudenken. Immer mehr Produkte und cloudbasierte Dienste lassen sich nur per PowerShell und individuelle Skripte sinnvoll administrieren. Gerade Office 365 ist hier ein unrühmliches Beispiel, da jeder Dienst über eine individuelle PowerShell-Schnittstelle verfügt.
Dieser Umstand hat zur Folge, dass Sie als Administrator oft Skripte zur Verwaltung komplexer Umgebungen einsetzen müssen, die Sie nicht selbst geschrieben haben. Die Skripte werden entweder von externen Dienstleister programmiert oder einfach aus dem Internet heruntergeladen. Hierbei implementiert jedes Skript, im Idealfall, eine eigene Protokollierung der ausgeführten Aktionen.
Die PowerShell-Skripte sind in den meisten Fällen für die individuelle Ausführung durch einen Administrator konzipiert und weniger für die regelmäßige und vollautomatische Ausführung. Als Administrator möchten Sie sich aber um wichtiger Dinge kümmern, als z.B. die Anlage von Benutzerkonten im Active Directory, die E-Mail-Aktivierung von Konten oder die Erstellung von SharePoint Team-Sites.
Sie stehen u.a. vor folgenden Problemen:
Sie kommen mit der Nutzung der Windows Bordmitteln, wie dem Task Scheduler, schon recht weit. Aber Sie werden mir zustimmen, dass dieses Tool nicht gerade die bequemste Art ist, um PowerShell-Skripte sinnvoll und sicher zu automatisieren.
Ein Lösung für dieses Dilemma ist die Nutzung einer Softwarelösung, die uns ein Trennung zwischen dem ausführenden Skript-Kontext und dem Kontext des Anwenders, der ein Skript startet, bietet. Mit einem Rollen- und Berechtigungssystem kann ein Skript, in Abhängigkeit der Rollenzuweisung, unterschiedlich ausgeführt werden.
WIr benötigen also ein Lösung, die uns folgende Funktionen bietet:
Mit ScriptRunner steht eine professionelle Softwarelösung zur Verfügung, die uns all diese Möglichkeiten bietet. ScriptRunner ist ein sehr umfangreiches und leistungsfähiges Produkt zur PowerShell-Automatisierung. Aus meiner Sicht ist das Sicherheitskonzept, das für die Delegierung der Skript-Ausführungen eingesetzt wird, einer der Hauptgründe für das Produkt.
Das folgende Schaubild vereutlicht die Isoliserung von ScriptRunner für die sichere Ausführung von PowerShell-Skripten.
Grafik © ScriptRunner
Die einzelnen Schritte sind:
Die Automatisierung und die wiederkehrende Ausführung führt zu einer Reduzierung der Betriebsrisiken und minimiert kostenintensive manuelle Nacharbeiten. Dies gelingt durch die hohe Reproduzierbarkeit der immer gleichen Aufgaben (Stichwort: Erstellung von Benutzern mit unterschiedlichen Attributen, je nach Fachabteilung). Durch ein Zonenmodell und die strikte Trennung der Ausführungsberechtigungen (Anwender, Automatisiserungsdienst, Skript-Credentials) erreichen Sie ein Maximum an Betriebssicherheit.
Mit solch einer Aufteilung können Sie die Ausführung von Skripten nicht nur an das Helpdesk-Team delegieren, sondern sogar an DV-Ansprechpartner in Fachabtielungen. Die Weboberfläche ist intuitiv bedienbar und führt den Anwender sucher durch alle konfigurierten Eingabe- und Auwahlschritte.
Ab Q1 2019 werden Sie speziell für Exchange Server, Exchange Online und Office 365 entwickelte Skripte zur Nutzung mit ScriptRunner in diesem Blog finden.
Viel Spaß bei der Automatisierung!
Am 12. Februar fand das erste Treffen der neu gegründeten PowerShell User Group Berlin (PSUGB) in den Räumlichkeiten der commehr GmbH statt. Die neue User Group wurde von Evgenij Smirnov ins Leben gerufen. Damit hat auch die Hauptstadt endlich eine User Group, in der sich PowerShell Begeisterte regelmäßig treffen und austauschen können. Evgenij ist im Community-Leben Berlins nicht unbekannt, da er auch die Windows Server User Group (WSUG-B) und die Exchange User Group (EXUSG) führt.
Die PSUGB trifft sich in der Regel alle zwei Monate. Bei den gibt es immer einen Themenvortrag rund um PowerShell und den festen Tagesordnungspunkt "Bring Your Own Script". Bei BYOS kann jederzeit ein persönliches Power-Skript vorgestellt werden, das man schon immer gerne einmal mit der Community teilen wollte oder zu dem man Tipps aus der Community benötigt.
Auf der Webseite der PSUGB findest du weitere Infos, wie z.B. die Präsentationen, vergangenen Treffen.
Die Community und die PowerShell User Group Berlin lebt vom Mitmachen. Einfach bei Meetup zum nächsten User Group Treffen anmelden.
Die PSUGB ist natürlich auch bei Twitter aktiv: @psugbde. Es lohnt sich, dem Account zu folgen.
Viel Spaß in der PowerShell-Community!
When you try to connect to SharePoint Online using PowerShell you receive an Access Denied error as follows:
PS C:\> Connect-SPOService -Url https://tenant-admin.sharepoint.com -credential $credential Connect-SPOService : Cannot contact web site 'https://tenant-admin.sharepoint.com/' or the web site does not support SharePoint Online credentials. The response status code is 'Unauthorized'. The response headers are 'X-SharePointHealthScore=0, SPRequestGuid=310ce59d-002b-3000-ef1a-70e5fe7eaf72, request-id=310ce59d-002b-3000-ef1a-70e5fe7eaf72, X-MSDAVEXT_Error=917656; Acces s+denied.+Before+opening+files+in+this+location%2c+you+must+first+browse+to+the +web+site+and+select+the+option+to+login+automatically.,
Connecto to the SPO Service without the previously entered credentials ($credential) and enable the LegacyAuthProtocolsEnabled attribute.
Set-SPOTenant -LegacyAuthProtocolsEnabled $True
Enjoy SharePoint Online.