def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("\\powershell.exe"),
                    event.deep_get("Image", default="").endswith("\\pwsh.exe"),
                ]
            ),
            any(
                [
                    " -e " in event.deep_get("CommandLine", default=""),
                    " -en " in event.deep_get("CommandLine", default=""),
                    " -enc " in event.deep_get("CommandLine", default=""),
                    " -enco" in event.deep_get("CommandLine", default=""),
                    " -ec " in event.deep_get("CommandLine", default=""),
                ]
            ),
            not any(
                [
                    " -Encoding " in event.deep_get("CommandLine", default=""),
                    any(
                        [
                            "C:\\Packages\\Plugins\\Microsoft.GuestConfiguration.ConfigurationforWindows\\"
                            in event.deep_get("ParentImage", default=""),
                            "\\gc_worker.exe" in event.deep_get("ParentImage", default=""),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
