def rule(event):
    if all(
        [
            any(
                [
                    all(
                        [
                            any(
                                [
                                    event.deep_get("Image", default="").endswith("\\csrss.exe"),
                                    event.deep_get("Image", default="").endswith("\\lsass.exe"),
                                    event.deep_get("Image", default="").endswith(
                                        "\\RuntimeBroker.exe"
                                    ),
                                    event.deep_get("Image", default="").endswith("\\sihost.exe"),
                                    event.deep_get("Image", default="").endswith("\\smss.exe"),
                                    event.deep_get("Image", default="").endswith("\\wininit.exe"),
                                    event.deep_get("Image", default="").endswith("\\winlogon.exe"),
                                ]
                            ),
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").endswith(".bat"),
                                    event.deep_get("TargetFilename", default="").endswith(".dll"),
                                    event.deep_get("TargetFilename", default="").endswith(".exe"),
                                    event.deep_get("TargetFilename", default="").endswith(".hta"),
                                    event.deep_get("TargetFilename", default="").endswith(".iso"),
                                    event.deep_get("TargetFilename", default="").endswith(".ps1"),
                                    event.deep_get("TargetFilename", default="").endswith(".txt"),
                                    event.deep_get("TargetFilename", default="").endswith(".vbe"),
                                    event.deep_get("TargetFilename", default="").endswith(".vbs"),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            any(
                                [
                                    event.deep_get("Image", default="").endswith("\\dllhost.exe"),
                                    event.deep_get("Image", default="").endswith("\\rundll32.exe"),
                                    event.deep_get("Image", default="").endswith("\\svchost.exe"),
                                ]
                            ),
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").endswith(".bat"),
                                    event.deep_get("TargetFilename", default="").endswith(".hta"),
                                    event.deep_get("TargetFilename", default="").endswith(".iso"),
                                    event.deep_get("TargetFilename", default="").endswith(".ps1"),
                                    event.deep_get("TargetFilename", default="").endswith(".vbe"),
                                    event.deep_get("TargetFilename", default="").endswith(".vbs"),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
            not any(
                [
                    all(
                        [
                            event.deep_get("Image", default="")
                            == "C:\\Windows\\System32\\dllhost.exe",
                            ":\\Users\\" in event.deep_get("TargetFilename", default=""),
                            "\\AppData\\Local\\Temp\\__PSScriptPolicyTest_"
                            in event.deep_get("TargetFilename", default=""),
                            event.deep_get("TargetFilename", default="").endswith(".ps1"),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="")
                            == "C:\\Windows\\system32\\svchost.exe",
                            "C:\\Windows\\System32\\GroupPolicy\\DataStore\\"
                            in event.deep_get("TargetFilename", default=""),
                            "\\sysvol\\" in event.deep_get("TargetFilename", default=""),
                            "\\Policies\\" in event.deep_get("TargetFilename", default=""),
                            "\\Machine\\Scripts\\Startup\\"
                            in event.deep_get("TargetFilename", default=""),
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").endswith(".ps1"),
                                    event.deep_get("TargetFilename", default="").endswith(".bat"),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="")
                            == "C:\\Windows\\system32\\svchost.exe",
                            "C:\\Program Files\\WindowsApps\\Clipchamp"
                            in event.deep_get("TargetFilename", default=""),
                            ".ps1" in event.deep_get("TargetFilename", default=""),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("Image", default="")
                            in [
                                "C:\\Windows\\system32\\svchost.exe",
                                "C:\\Windows\\SysWOW64\\svchost.exe",
                            ],
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").startswith(
                                        "C:\\Program Files\\WindowsApps\\Microsoft.PowerShellPreview"
                                    ),
                                    event.deep_get("TargetFilename", default="").startswith(
                                        "C:\\Program Files (x86)\\WindowsApps\\Microsoft.PowerShellPreview"
                                    ),
                                ]
                            ),
                            event.deep_get("TargetFilename", default="").endswith(".ps1"),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
