diff --git a/src/command_modules/azure-cli-feedback/azure/cli/command_modules/feedback/custom.py b/src/command_modules/azure-cli-feedback/azure/cli/command_modules/feedback/custom.py index a222758e3ac..3d0b3edfff1 100644 --- a/src/command_modules/azure-cli-feedback/azure/cli/command_modules/feedback/custom.py +++ b/src/command_modules/azure-cli-feedback/azure/cli/command_modules/feedback/custom.py @@ -377,8 +377,10 @@ def _get_parent_proc_name(): parent = psutil.Process(os.getpid()).parent() if parent: # powershell.exe launches cmd.exe to launch the cli. - if parent.parent() and parent.name().lower().startswith("powershell"): - return parent.parent().name() + grandparent = parent.parent() + if grandparent and grandparent.name().lower().startswith("powershell"): + return grandparent.name() + # if powershell is not the grandparent, simply return the parent's name. return parent.name() return None