{"id":191,"date":"2013-01-23T15:23:32","date_gmt":"2013-01-23T15:23:32","guid":{"rendered":"http:\/\/www.eXchange-Profis.de\/?p=191"},"modified":"2020-04-15T07:31:21","modified_gmt":"2020-04-15T07:31:21","slug":"nutzliche-powershellcommandos-und-tools","status":"publish","type":"post","link":"http:\/\/exchange-profis.de\/?p=191","title":{"rendered":"N\u00fctzliche Powershellcommandos und Tools"},"content":{"rendered":"<p>Version aller Exchangeserver auslesen:<\/p>\n<p>Get-ExchangeServer | Sort-Object Name | ForEach {Invoke-Command -ComputerName $_.Name -ScriptBlock {Get-Command ExSetup.exe | ForEach{$_.FileVersionInfo}}} | Format-Table -Auto<\/p>\n<p>ActiveSync Auswertung als HTML:<\/p>\n<p>Get-ActiveSyncDevice | select userdisplayname,deviceaccessstate,deviceid,deviceuseragent | ConvertTo-Html | Out-File &#8220;$($pwd.path)\\ActiveSyncDevices_$(get-date -f dd\/mm\/yyyy).html&#8221;<\/p>\n<p>Zu Arrays etwas hinzuf\u00fcgen oder k\u00fcrzen:<\/p>\n<p>Set-DistributionGroup &#8220;Sample&#8221; -GrantSendOnBehalfTo @{remove=&#8217;dom10\\user1&#8242;}<br \/>\nSet-DistributionGroup &#8220;Sample&#8221; -GrantSendOnBehalfTo @{add=&#8217;dom10\\user1&#8242;,&#8217;dom10\\user2&#8242;}<\/p>\n<p>Ausgabelimit f\u00fcr Shell Commandos eliminieren:<\/p>\n<p>$FormatEnumerationLimit =-1<\/p>\n<p>Gel\u00f6schte Mailboxen per Powershell in Exchange 2010 finden:<\/p>\n<p>Get-MailboxServer exsrv* | Get-MailboxStatistics | ?{$_.disconnectdate -ne $null -and $_.displayname -like &#8220;userxy*&#8221;} | ft displayname,servername,disconnectdate<\/p>\n<p>&nbsp;<\/p>\n<p>Datenbanken nach Activationprefenz auf DAG Server verteilen:<\/p>\n<p>[PS] C:\\Program Files\\Microsoft\\Exchange Server\\V14\\scripts&gt;.\\RedistributeActiveDatabases.ps1 -DagName myDAG -BalanceDbsByActivationPreference -Confirm:$false<\/p>\n<p>&nbsp;<\/p>\n<p>Mailboxstatistik erzeugen und per Mail verschicken<\/p>\n<p>&nbsp;<\/p>\n<p>$rootou = [ADSI](&#8220;LDAP:\/\/ou=corp,dc=corp,dc=net&#8221;)<\/p>\n<p>&nbsp;<\/p>\n<p>$ous = ($rootou.psbase.children | Where-Object {$_.psBase.schemaClassName -eq &#8220;OrganizationalUnit&#8221;} |Select-Object -expand Name)<\/p>\n<p>&nbsp;<\/p>\n<p>#foreach ($ou in $ous) {Get-Mailbox -OrganizationalUnit &#8220;ou=$ou,ou=corp,dc=dom,dc=local&#8221;\u00a0 -resultsize unlimited | Get-MailboxStatistics | sort-object Totalitemsize -descending | select-object displayname,totalitemsize | ConvertTo-Html | Out-File C:\\inetpub\\wwwroot\\stats\\$ou-sizes.html}<\/p>\n<p>&nbsp;<\/p>\n<p>$smtpclient = new-object system.net.mail.smtpClient<\/p>\n<p>$mailmessage = new-object system.net.mail.mailmessage<\/p>\n<p>$smtpclient.host = &#8220;smtphost.dom.local&#8221;<\/p>\n<p>$mailmessage.from =&#8221;<a href=\"mailto:andre.gloeckner.extern@brose.com\">sender@dom.local<\/a>&#8221;<\/p>\n<p>#$mailmessage.to.add(&#8220;<a href=\"mailto:mario.stibitz@brose.com\">someone@dom.local<\/a>&#8220;)<\/p>\n<p>$mailmessage.subject =&#8221;Mailboxsize Statistics&#8221;<\/p>\n<p>$mailmessage.isbodyhtml = $true<\/p>\n<p>&nbsp;<\/p>\n<p>foreach ($ou in $ous) {$filename = &#8220;c:\\inetpub\\wwwroot\\stats\\$ou-sizes.html&#8221;;$att = new-object Net.Mail.Attachment($filename);$mailmessage.Attachments.Add($att)}<\/p>\n<p>$mailmessage.Body = &#8220;Attached you find the mailboxstatistics&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>##for ($i=0;$i -le 1;$i++){<\/p>\n<p>##$i<\/p>\n<p>#$smtpclient.send($mailmessage)<\/p>\n<p>##}<\/p>\n<p>&nbsp;<\/p>\n<p>Durchschnittliche Mailboxgr\u00f6\u00dfe ermitteln:<\/p>\n<p>Get-Mailbox -OrganizationalUnit &#8220;ou=corp,dc=corp,dc=net&#8221;\u00a0 -resultsize unlimited | Get-<\/p>\n<p>MailboxStatistics | %{$_.totalitemsize.value.tomb()} |measure-object \u2013average<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Version aller Exchangeserver auslesen: Get-ExchangeServer | Sort-Object Name | ForEach {Invoke-Command -ComputerName $_.Name -ScriptBlock {Get-Command [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-191","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":9,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":234,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/234"}],"wp:attachment":[{"href":"http:\/\/exchange-profis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/exchange-profis.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}