protected override void ProcessRecord()

in src/VSSetup.PowerShell/PowerShell/GetInstanceCommand.cs [74:109]


        protected override void ProcessRecord()
        {
            if (query == null)
            {
                StopProcessing();
                return;
            }

            if (AllParameterSet.Equals(ParameterSetName, StringComparison.OrdinalIgnoreCase))
            {
                foreach (var instance in GetInstances())
                {
                    WriteInstance(instance);
                }
            }
            else
            {
                var items = InvokeProvider.Item.Get(Path, true, IsLiteralPath) ?? Enumerable.Empty<PSObject>();
                foreach (var item in items)
                {
                    var path = item.GetPropertyValue<string>("PSPath");
                    var providerPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(path);

                    try
                    {
                        var instance = (ISetupInstance2)query.GetInstanceForPath(providerPath);
                        WriteInstance(instance, all: true);
                    }
                    catch (COMException ex) when (ex.ErrorCode == NativeMethods.E_NOTFOUND)
                    {
                        var message = string.Format(Resources.NoInstanceForPath_Args1, providerPath);
                        WriteWarning(message);
                    }
                }
            }
        }