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(
                        [
                            any(
                                [
                                    "ToInt" in event.deep_get("CommandLine", default=""),
                                    "ToDecimal" in event.deep_get("CommandLine", default=""),
                                    "ToByte" in event.deep_get("CommandLine", default=""),
                                    "ToUint" in event.deep_get("CommandLine", default=""),
                                    "ToSingle" in event.deep_get("CommandLine", default=""),
                                    "ToSByte" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                            any(
                                [
                                    "ToChar" in event.deep_get("CommandLine", default=""),
                                    "ToString" in event.deep_get("CommandLine", default=""),
                                    "String" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                    any(
                        [
                            all(
                                [
                                    "char" in event.deep_get("CommandLine", default=""),
                                    "join" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                            all(
                                [
                                    "split" in event.deep_get("CommandLine", default=""),
                                    "join" in event.deep_get("CommandLine", default=""),
                                ]
                            ),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
