def rule(event):
    if all(
        [
            any(
                [
                    all(
                        [
                            any(
                                [
                                    event.deep_get("Image", default="").endswith("\\reg.exe"),
                                    event.deep_get("OriginalFileName", default="") == "reg.exe",
                                ]
                            ),
                            "add" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                    all(
                        [
                            any(
                                [
                                    any(
                                        [
                                            event.deep_get("Image", default="").endswith(
                                                "\\powershell.exe"
                                            ),
                                            event.deep_get("Image", default="").endswith(
                                                "\\pwsh.exe"
                                            ),
                                        ]
                                    ),
                                    event.deep_get("OriginalFileName", default="")
                                    in ["powershell.exe", "pwsh.dll"],
                                ]
                            ),
                            any(
                                [
                                    "New-ItemProperty" in event.deep_get("CommandLine", default=""),
                                    "Set-ItemProperty" in event.deep_get("CommandLine", default=""),
                                    "ni " in event.deep_get("CommandLine", default=""),
                                    "sp " in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
            "\\ms-settings\\shell\\open\\command" in event.deep_get("CommandLine", default=""),
        ]
    ):
        return True
    return False
