def rule(event):
    if 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(
                [
                    all(
                        [
                            " -e" in event.deep_get("CommandLine", default=""),
                            any(
                                [
                                    " JAB" in event.deep_get("CommandLine", default=""),
                                    " SUVYI" in event.deep_get("CommandLine", default=""),
                                    " SQBFAFgA" in event.deep_get("CommandLine", default=""),
                                    " aQBlAHgA" in event.deep_get("CommandLine", default=""),
                                    " aWV4I" in event.deep_get("CommandLine", default=""),
                                    " IAA" in event.deep_get("CommandLine", default=""),
                                    " IAB" in event.deep_get("CommandLine", default=""),
                                    " UwB" in event.deep_get("CommandLine", default=""),
                                    " cwB" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                    any(
                        [
                            ".exe -ENCOD " in event.deep_get("CommandLine", default=""),
                            " BA^J e-" in event.deep_get("CommandLine", default=""),
                        ]
                    ),
                ]
            ),
            not " -ExecutionPolicy remotesigned " in event.deep_get("CommandLine", default=""),
        ]
    ):
        return True
    return False
