Archiv der Kategorie: Powershell

Duplicate items in „sent“ for shared mailboxes

Now test these two things. When you are sending email as some non-problematic shared mailbox. Do you see an email in the Sent Item of the shared mailbox as well as in your Personal-Sent Items as well. What do you see if you send email from a problematic shared mailbox, do you still see the user(actual sender) copy. Run the Get-MailboxSentItemsConfiguration against the working shared mailboxes and let me know if the settings are same. Check if your Outlook is configured to be running in Cached Mode. If yes try switching to Online and see if still the issue re-occurs. Is DelegateSentItemsStyle registry key present or set with a value.Key: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\PreferencesName: DelegateSentItemsStyleAlso on the problematic shared mailbox, change the settings as below and let me know the results.

Set-MailboxSentItemsConfiguration "Customer Support Feedback" -SendAsItemsCopiedTo Sender

Quelle: Duplicate items in „sent“ for shared mailboxes

Used maildomain list

Report for all uses mail domains in Exchange mailbox address list with accepted domains and an example. Also helpful to find wrong entries 🙂

$acceptedDomains = $(Get-AcceptedDomain).DomainName
$aDomains = [String]::Join(„,@“,$acceptedDomains).Split(„,“)
$aDomains[0] = „@$($aDomains[0])“
$domains=@()
$domains.Clear()
$a = New-Object -TypeName psobject
$a | Add-Member Noteproperty Name „@myinternaldomain.local“
$a | Add-Member Noteproperty Count 0
$a | Add-Member Noteproperty Primary 0
$a | Add-Member Noteproperty Firstentry „“
$a | Add-Member Noteproperty FirstPrimary „“
$a | Add-Member Noteproperty AcceptedDomain „1“
$domains += $a
$x = Get-Mailbox -ResultSize Unlimited$y = $x.EmailAddresses | ?{$_ -like „*@*“}
foreach($z in $y){
$i = $z.IndexOf(„@“)
$d = $z.Substring($i).ToLower()
$isPrimary = $z.StartsWith(„SMTP:“)
if($domains.Name.Contains($d)){
$domains[$domains.Name.Indexof($d)].Count ++
}else{
$a = New-Object -TypeName psobject
$a | Add-Member Noteproperty Name $d
$a | Add-Member Noteproperty Count 1
$a | Add-Member Noteproperty Primary 0
$a | Add-Member Noteproperty Firstentry $z
$a | Add-Member Noteproperty FirstPrimary „“
if($aDomains.Contains($d)){
$a | Add-Member Noteproperty AcceptedDomain „1“
}else{
$a | Add-Member Noteproperty AcceptedDomain „0“
}
$domains += $a
}
if($isPrimary){
$domain = $domains[$domains.Name.Indexof($d)]
$domain.Primary ++
if($domain.FirstPrimary.Length -eq 0){$domain.FirstPrimary = $z}
}
}
$domains | Out-GridView

Connecting to Office 365/Exchange

…..a script with a set of functions to allow me connect to each individual Office 365 service or Exchange Online: Connect-AzureActiveDirectory: Connects to Azure Active Directory Connect-AzureRMS: Connects to Azure Rights Management Connect-ExchangeOnline: Connects to Exchange Online Connect-SkypeOnline: Connects to Skype for Business Online Connect-EOP: Connects to Exchange Online Protection Connect-ComplianceCenter: Connects to Compliance Center Connect-SharePointOnline: Connects to SharePoint Online Connect-MSTeams: Connects to Microsoft Teams Get-Office365Credentials: Gets Office 365 credentials Connect-ExchangeOnPremises: Connects to Exchange On-Premises Get-OnPremisesCredentials: Gets On-Premises credentials Get-ExchangeOnPremisesFQDN: Gets FQDN for Exchange On-Premises Get-Office365Tenant: Gets Office 365 tenant name (SharePoint) Set-Office365Environment: Configures Uri’s and region to use…..

Quelle: Connecting to Office 365/Exchange | EighTwOne (821)

Mailflow issue from Exchange On-Prem to Office 365 – Lalit Bisht Blogs

You are on Exchange Hybrid environment and sending emails to Office 365 via specific SendConnector which has TlsCertificateName attribute configured and EOP is doing certificate validation for Inbound SMTP connections.

You might see any of the following errors in the queue/Protocol Logs.
–> 454 4.7.5 The certificate specified in TlsCertificateName of the SendConnector could not be found.
–> TLS negotiation failed with error NoCredentials.
–> „421 4.4.1 Connection timed out.“ Attempted failover to alternate host, but that did not succeed. Either there are no alternate hosts, or delivery failed to all alternate hosts

It may be because of the following issues:
–> You changed the third party SMTP certificate but didn’t update the TlsCertificateName attribute on the send connector.
–> Third party certificate is not assigned to the SMTP services.
–> Status of that third party certificate shows „INVALID“ or „RevocationCheckFailure“.

Please perform the following to resolve the issue.
–> Update the TLSCertificateName attribute on the Office 365 SendConnector.

$cert = Get-ExchangeCertificate -Thumbprint
$TLSCert = (‘<I>’+$cert.issuer+'<S>’+$cert.subject)
Set-SendConnector -Identity -TLSCertificateName $TLSCert
–>Make sure required certificate is assigned to the SMTP service and certificate Status shows VALID.

Quelle: Mailflow issue from Exchange On-Prem to Office 365 – Lalit Bisht Blogs

Konten im Active Directory entsperren oder aktivieren mit PowerShell | WindowsPro

Ein Tipp von meinem lieben Kollegen Rainer:

Search-ADAccount -LockedOut -UsersOnly -SearchBase „OU=IT,DC=contoso,DC=com“

Search-ADAccount -AccountExpired -UsersOnly

Search-ADAccount -AccountExpiring -TimeSpan „10“7

Unlock-ADAccount -Identity amueller

Set-ADAccountExpiration -DateTime 30.04.2017

Quelle: Konten im Active Directory entsperren oder aktivieren mit PowerShell | WindowsPro

ADFS 2012 R2 now supports Password Change (not reset) across all devices – samueld

Enabling Change Password in ADFS

By default, this functionality is disabled in ADFS. Change password looks just like another endpoint in ADFS and all you need to do is enable the endpoint. You can use the MMC snapin to enable this.

You can also do this via PSH using the Set-AdfsEndpoint cmdlet.

Once enabled, users can always access the change password page via https://adfs.contoso.com/adfs/portal/updatepassword/. It would look like this

Quelle: ADFS 2012 R2 now supports Password Change (not reset) across all devices – samueld

have i been pwned? Test all users of your domain

Aus einem Powershell-Beispiel von „IT Pro blog“ weiterentwickelt
https://infracloud.wordpress.com/2015/10/29/have-you-been-pwned-use-powershell-to-find-out/
Get-Pwned.ps1

Import-Module „C:\adm\custom\BasicTools.psm1“
$Global:CheckURI = „https://haveibeenpwned.com/api/v2/breachedaccount“
$global:OutputPath = „C:\“
$global:results = @()
Function ValidateAddress($Emailaddress){
try{
$Request = Invoke-WebRequest -Uri „$global:CheckURI/$Emailaddress“
$Response = ConvertFrom-Json $Request
Return $Response
}
catch [exception]
{
Return $null
}
}
Function IsValidEMail($email){
    $EmailRegex = ‚^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$‘;
    return ($email -match $EmailRegex)
}
Function IsValidDomain($mailaddress){
$domain = $mailaddress.Substring($mailaddress.IndexOf(„@“)+1)
$obj = Get-AcceptedDomain -Identity $domain -ErrorAction SilentlyContinue
if ($obj -eq $null){
$result = $false
}else{
$result = $true
}

return $result
}
Function ConvertHaveibeenpwnedObject($obj,$mailaddress,$username){
Set-ToolsLogAddLine -LogTXT „Compromised account $username, $mailaddress“
$result = New-Object -TypeName PSObject
$result | Add-Member -MemberType NoteProperty -Name username -Value $username
$result | Add-Member -MemberType NoteProperty -Name mailaddress -Value $mailaddress
$result | Add-Member -MemberType NoteProperty -Name HIBPAddedDate -Value $obj.AddedDate
$result | Add-Member -MemberType NoteProperty -Name HIBPBreachDate -Value $obj.BreachDate
$result | Add-Member -MemberType NoteProperty -Name HIBPDataClasses -Value ([system.String]::Join(„;“,$obj.DataClasses))
$result | Add-Member -MemberType NoteProperty -Name HIBPDescription -Value $obj.Description
$result | Add-Member -MemberType NoteProperty -Name HIBPDomain -Value $obj.Domain
$result | Add-Member -MemberType NoteProperty -Name HIBPIsSensitive -Value $obj.IsSensitive
$result | Add-Member -MemberType NoteProperty -Name HIBPIsVerified -Value $obj.IsVerified
$result | Add-Member -MemberType NoteProperty -Name HIBPLogoType -Value $obj.LogoType
$result | Add-Member -MemberType NoteProperty -Name HIBPName -Value $obj.Name
$result | Add-Member -MemberType NoteProperty -Name HIBPPwnCount -Value $obj.PwnCount
$result | Add-Member -MemberType NoteProperty -Name HIBPTitle -Value $obj.Title
return $result
}
Function main{
Set-ToolsLogCreate -LogFilePath „C:\adm\custom\logs\“ -LogPrefix „CompromisedAccounts“
Remove-ToolsLog -olderThenDays 21
Set-ToolsLogAddLine -LogTXT „Collect accounts“

$users = Get-ADUser -LDAPFilter „(mail=*)“ -Properties mail, proxyaddresses -ResultSetSize $null

$i = ($users).Count
Set-ToolsLogAddLine -LogTXT „Test $i accounts“
$i = 0
foreach($user in $users){
$i ++
if($i/100 -is [int]){Set-ToolsLogAddLine -LogTXT „$i accounts tested“}
$proxymail = „“
$usermail = „“
$usermail = $user.mail.ToLower()
$output = „“
if (IsValidEMail($usermail)){
if (isValidDomain($usermail)){
$obj = ValidateAddress($usermail)
if ($obj -ne $null){
$global:results += ConvertHaveibeenpwnedObject -obj $obj -mailaddress $usermail -username $user.SamAccountName
}
}
}
Foreach($proxyAddress in $user.proxyaddresses){
$proxymail = $proxyAddress.ToLower()
if ($proxymail.StartsWith(„smtp:“)){
$proxymail = $proxymail.Substring($proxymail.IndexOf(„smtp:“)+5)
if (IsValidEMail($proxymail)){
if ($proxymail -ne $usermail){
if (isValidDomain($proxymail)){
$obj = ValidateAddress($proxymail)
if ($obj -ne $null){
$global:results += ConvertHaveibeenpwnedObject -obj $obj -mailaddress $usermail -username $user.SamAccountName
}
}
}
}
}
}
}
Set-ToolsLogAddLine -LogTXT „Finish“ -foregroundcolor „green“ -backgroundcolor „darkgray“
$global:results | Export-csv „$global:OutputPath\CompromisedAccounts.csv“
}

main