def rule(event):
    if all(
        [
            any(
                [
                    "\\WindowsPowerShell\\Modules\\"
                    in event.deep_get("TargetFilename", default=""),
                    "\\PowerShell\\7\\Modules\\" in event.deep_get("TargetFilename", default=""),
                ]
            ),
            not any(
                [
                    any(
                        [
                            event.deep_get("Image", default="").endswith(
                                ":\\Program Files\\PowerShell\\7-preview\\pwsh.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Program Files\\PowerShell\\7\\pwsh.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\System32\\poqexec.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\SysWOW64\\poqexec.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell_ise.exe"
                            ),
                            event.deep_get("Image", default="").endswith(
                                ":\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"
                            ),
                        ]
                    ),
                    event.deep_get("Image", default="")
                    in ["C:\\Windows\\System32\\msiexec.exe", "C:\\Windows\\SysWOW64\\msiexec.exe"],
                ]
            ),
        ]
    ):
        return True
    return False
