def rule(event):
    if all(
        [
            any(
                [
                    event.deep_get("Image", default="").endswith("\\powershell.exe"),
                    event.deep_get("Image", default="").endswith("\\powershell_ise.exe"),
                    event.deep_get("Image", default="").endswith("\\pwsh.exe"),
                ]
            ),
            any(
                [
                    event.deep_get("TargetFilename", default="").endswith(".bat"),
                    event.deep_get("TargetFilename", default="").endswith(".chm"),
                    event.deep_get("TargetFilename", default="").endswith(".cmd"),
                    event.deep_get("TargetFilename", default="").endswith(".com"),
                    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(".jar"),
                    event.deep_get("TargetFilename", default="").endswith(".js"),
                    event.deep_get("TargetFilename", default="").endswith(".ocx"),
                    event.deep_get("TargetFilename", default="").endswith(".scr"),
                    event.deep_get("TargetFilename", default="").endswith(".sys"),
                    event.deep_get("TargetFilename", default="").endswith(".vbe"),
                    event.deep_get("TargetFilename", default="").endswith(".vbs"),
                    event.deep_get("TargetFilename", default="").endswith(".wsf"),
                ]
            ),
            not any(
                [
                    all(
                        [
                            event.deep_get("TargetFilename", default="").startswith("C:\\Users\\"),
                            "\\AppData\\Local\\Temp\\"
                            in event.deep_get("TargetFilename", default=""),
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").endswith(".dll"),
                                    event.deep_get("TargetFilename", default="").endswith(".exe"),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").startswith(
                                        "C:\\Windows\\Temp\\"
                                    ),
                                    event.deep_get("TargetFilename", default="").startswith(
                                        "C:\\Windows\\SystemTemp\\"
                                    ),
                                ]
                            ),
                            any(
                                [
                                    event.deep_get("TargetFilename", default="").endswith(".dll"),
                                    event.deep_get("TargetFilename", default="").endswith(".exe"),
                                ]
                            ),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("TargetFilename", default="").startswith("C:\\Users\\"),
                            "\\WindowsPowerShell\\Modules\\"
                            in event.deep_get("TargetFilename", default=""),
                            event.deep_get("TargetFilename", default="").endswith(".dll"),
                        ]
                    ),
                    all(
                        [
                            event.deep_get("TargetFilename", default="").startswith(
                                "C:\\Program Files\\PackageManagement\\ProviderAssemblies\\nuget\\"
                            ),
                            event.deep_get("TargetFilename", default="").endswith(
                                "\\Microsoft.PackageManagement.NuGetProvider.dll"
                            ),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
