Search all GPOs for String

$String = “Whatever you want to find”
$Domain = “contoso.internal”
$NearestDC = (Get-ADDomainController -Discover -NextClosestSite).Name
#Get a list of GPOs from the domain
$GPOs = Get-GPO -All -Domain $Domain -Server $NearestDC | sort DisplayName
#Go through each Object and check its XML against $String
Foreach ($GPO in $GPOs)  {
Write-Host “Working on $($GPO.DisplayName)”
#Get Current GPO Report (XML)
$CurrentGPOReport = Get-GPOReport -Guid $GPO.Id -ReportType Xml -Domain $Domain -Server $NearestDC
If ($CurrentGPOReport -match $String)  {
Write-Host “A Group Policy matching “”$($String)”” has been found:” -Foregroundcolor Green
Write-Host “-  GPO Name: $($GPO.DisplayName)” -Foregroundcolor Green
Write-Host “-  GPO Id: $($GPO.Id)” -Foregroundcolor Green
Write-Host “-  GPO Status: $($GPO.GpoStatus)” -Foregroundcolor Green
}
}

Remove EOL Automapping

Automapping is an Exchange & Exchange Online feature which automatically opens mailboxes with Full Access permissions in a delegate’s Outlook client.

Remove the access permissions. This also removes automapping.

Logon to Azure EOL (with MFA)

Business@contoso.ie is the mailbox being shared.
anna.grimm@contoso.ie is the account that has the access rights.

In EOL PowerShell

Remove-MailboxPermission -Identity “Business@contoso.ie” -User “anna.grimm@contoso.ie” -AccessRights FullAccess                                                   

Confirm

Are you sure you want to perform this action?

Removing mailbox permission Identity:”Business@contoso.ie” for user “anna.grimm@contoso.ie” with access rights “‘FullAccess'”.

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is “Y”): select A

You might get this error
WARNING

Can’t remove the access control entry on the object “User” for the user account because the ACE doesn’t exist on the object.

So use

Remove-MailboxPermission -Identity “Business@contoso.ie” -User “anna.grimm@contoso.ie” -AccessRights FullAccess –Confirm:$false –BypassMasterAccountSid

Re-add the permissions but without Automapping

Add-MailboxPermission -Identity “Business@comtoso.ie” -User “anna.grimm@contoso.ie” -AccessRights FullAccess -AutoMapping:$false

Outlook with MFA keeps asking for password following AD password change

Problem

  • Outlook is disconnected
  • “Needs Password” shown in lower right side of client
  • No folders updated
  • When you click on “Needs Password” M365 sends you a text code. You input it, nothing happens and this loops.

Reason

By default, Microsoft Office 365 ProPlus (2016 version) uses Azure Active Directory Authentication Library (ADAL) framework-based authentication. Starting in build 16.0.7967, Office uses Web Account Manager (WAM) for sign-in workflows on Windows builds that are later than 15000 (Windows 10, version 1703, build 15063.138). There are generally two problems we see WAM causing:

Users unable to authenticate (particularly after a password reset)

WAM introduces new requirements for Identity Providers (IdP) used to federate Microsoft 365 (O365) logins. When a Windows 10 workstation is joined to an on-premise Active Directory, WAM/M365 requires the IdP to support the WS-Trust protocol. Currently this is not supported in the Duo Access Gateway (DAG). When a user’s access/refresh tokens become invalid, such as after a password reset, the WAM framework tries to re-authenticate the user. The expected end-user experience is a popup window showing the login page of the IdP asking the user to re-authenticate. When the IdP is the DAG, this process will fail causing the user to be unable to re-connect to M365 with applications such as Microsoft Outlook. The user will see the authentication window open briefly then immediately close while Outlook continues to show the message “Need Password”.

Solution

  • Log out of all O365 related web pages
  • Close Outlook
  • Open Registry and add the following 2 dwords

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity]
DisableADALatopWAMOverride=dword:00000001

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Common\Identity]
DisableAADWAM=dword:00000001

Cannot install Roles & Features (Windows 2016)

Error
Sometimes when building a Domain Controller The new roles will not install and you’ll get the error below
The referenced assembly could not be found. Error: 0x80073701

Log
Navigate to C:\Windows\Logs\CBS\CBS.log and search for STATUS_SXS_ASSEMBLY_MISSING

Quick fix
Get a new image and start over

Geek Way
Run these commands at elevated cmd

  • Dism.exe /Online /Cleanup-Image /CheckHealth
  • Dism.exe /Online /Cleanup-Image /ScanHealth
  • Dism.exe /online /cleanup-image /analyzecomponentstore
  • Dism.exe /Online /Cleanup-Image /restoreHealth
  • sfc.exe /scannow
  • powershell.exe “Get-TroubleshootingPack -path C:\Windows\diagnostics\system\WindowsUpdate | Invoke-TroubleshootingPack

If that doesn’t work get a new image

Enable Windows Debug Logs

Netlogon Debug Log
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters] “DBFlag”=dword:2080ffff   (hexadecimal value)
Then open a cmd and type net stop netlogon && net start netlogon to enable the debugging mode. The Debug logging writes to C:\Windows\Debug\netlogon.log

Winlogon.Log
After fresh installation of Windows Server domain controller you could see that you have no winlogon.log file which is useful to debugging AD GPO’s.
For example when you need to troubleshot SceCli events. Event ID 1202 tells you to use: FIND /I “Cannot find”  %SYSTEMROOT%\Security\Logs\winlogon.log

To create it, go to regedit and go to following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}
Click the key ExtensionDebugLevel and enter 2 as a Data.

After refreshing AD policies with GPUpdate you should see your winlogon.log file

“User profile was not loaded correctly” – TEMP profile created on logon

  1. Log on as different user. Make sure the different user account is a administrator (added to the Administrators group).
  2. Open Windows Explorer and open C:\Users. Delete the directory of “problematic” user profile and “Temp” directory, it may or may not exist.
  3. Run the registry editor (RedEdit.exe)
  4. Go to the following location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
  5. You need to find the correct SID and delete it. To make sure you are deleting the right one, check the key ProfileImagePath which has the profile path. Delete the .bak key as well.
  6. Reboot the computer and logon on as the user as before.

Get IPv4 DHCP Reservations in a CSV file

Copy code below and save as Get-DHCPReservations.ps1

Get-DHCPServerV4Scope | ForEach {Get-DHCPServerv4Lease -ScopeID $_.ScopeID | where {$_.AddressState -like ‘*Reservation’} | Select-Object ScopeId,IPAddress,HostName,ClientID,AddressState | Export-Csv “C:\temp\DHCPReservations.csv” -NoTypeInformation 

Clematis x cartmanii ‘Early Sensation’

Clematis x cartmanii ‘Early Sensation’

Early (April – May) flowering evergreen clematis with glossy finely divided leaves and masses of 7.5 cm (3″) white flowers with green centers. Supposedly scented, I couldn’t smell anything from the flowers. Some people say the whole plant has a citrus smell but again I couldn’t get anything.

Grows to about 2 meters and can be grown in a large pot. Requires a west or south facing wall with protection from wind. You can grow it up trellis or as just let it sprawl.