Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
PopRunspaceCommand.cs41 linesDownload Raw Back to commands
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4using System;5using System.Management.Automation;6using System.Management.Automation.Host;7using System.Management.Automation.Remoting;8 9using Dbg = System.Management.Automation.Diagnostics;10 11namespace Microsoft.PowerShell.Commands12{13    /// <summary>14    /// Exit-PSSession cmdlet.15    /// </summary>16    [Cmdlet(VerbsCommon.Exit, "PSSession", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=2096787")]17    public class ExitPSSessionCommand : PSRemotingCmdlet18    {19        /// <summary>20        /// Process record.21        /// </summary>22        protected override void ProcessRecord()23        {24            // Pop it off the local host.25            IHostSupportsInteractiveSession host = this.Host as IHostSupportsInteractiveSession;26            if (host == null)27            {28                WriteError(29                    new ErrorRecord(30                        new ArgumentException(GetMessage(RemotingErrorIdStrings.HostDoesNotSupportPushRunspace)),31                        nameof(PSRemotingErrorId.HostDoesNotSupportPushRunspace),32                        ErrorCategory.InvalidArgument,33                        null));34                return;35            }36 37            host.PopRunspace();38        }39    }40}41