imRegistry | where (((RegistryKey contains "\\Control\\Terminal Server\\" or RegistryKey contains "\\Windows NT\\Terminal Services\\") and RegistryKey endswith "\\Shadow" and (RegistryValueData in~ ("DWORD (0x00000001)", "DWORD (0x00000002)", "DWORD (0x00000003)", "DWORD (0x00000004)"))) or ((RegistryKey contains "\\Control\\Terminal Server\\" or RegistryKey contains "\\Windows NT\\Terminal Services\\") and (RegistryKey endswith "\\DisableRemoteDesktopAntiAlias" or RegistryKey endswith "\\DisableSecuritySettings" or RegistryKey endswith "\\fAllowUnsolicited" or RegistryKey endswith "\\fAllowUnsolicitedFullControl") and RegistryValueData =~ "DWORD (0x00000001)") or ((RegistryKey contains "\\Control\\Terminal Server\\InitialProgram" or RegistryKey contains "\\Control\\Terminal Server\\WinStations\\RDP-Tcp\\InitialProgram" or RegistryKey contains "\\Terminal Server\\WinStations\\RDP-Tcp\\SecurityLayer" or RegistryKey contains "\\Windows NT\\Terminal Services\\InitialProgram") or RegistryKey endswith "\\services\\TermService\\Parameters\\ServiceDll")) and (not(((RegistryKey endswith "\\SecurityLayer" and RegistryValueData =~ "DWORD (0x00000002)") or (RegistryKey endswith "\\services\\TermService\\Parameters\\ServiceDll" and (RegistryValueData in~ ("%%SystemRoot%%\\System32\\termsrv.dll", "%%SystemRoot%%\\SysWOW64\\termsrv.dll", "%%windir%%\\System32\\termsrv.dll", "%%windir%%\\SysWOW64\\termsrv.dll", "%SystemRoot%\\System32\\termsrv.dll", "%SystemRoot%\\SysWOW64\\termsrv.dll", "%windir%\\System32\\termsrv.dll", "%windir%\\SysWOW64\\termsrv.dll", "C:\\Windows\\System32\\termsrv.dll", "C:\\Windows\\SysWOW64\\termsrv.dll"))) or ((RegistryKey contains "\\Control\\Terminal Server\\InitialProgram" or RegistryKey contains "\\Control\\Terminal Server\\WinStations\\RDP-Tcp\\InitialProgram" or RegistryKey contains "\\Windows NT\\Terminal Services\\InitialProgram") and (RegistryValueData in~ ("(Empty)", "")))))) and (not(((ActingProcessName startswith "C:\\Windows\\System32\\" or ActingProcessName startswith "C:\\Windows\\SysWOW64\\" or ActingProcessName startswith "C:\\Windows\\WinSxS\\") and ActingProcessName endswith "\\containerworker.exe" and RegistryKey contains "\\Windows\\Containers\\Layers\\")))