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(
                [
                    "Import-Module " in event.deep_get("CommandLine", default=""),
                    "ipmo " in event.deep_get("CommandLine", default=""),
                ]
            ),
            not all(
                [
                    any(
                        [
                            ":\\Program Files\\WindowsApps\\Microsoft.WindowsTerminal_"
                            in event.deep_get("ParentImage", default=""),
                            ":\\Windows\\System32\\cmd.exe"
                            in event.deep_get("ParentImage", default=""),
                        ]
                    ),
                    ":\\Program Files\\Microsoft Visual Studio\\"
                    in event.deep_get("CommandLine", default=""),
                    "Tools\\Microsoft.VisualStudio.DevShell.dll"
                    in event.deep_get("CommandLine", default=""),
                ]
            ),
        ]
    ):
        return True
    return False
