예제 #1
0
        void OpenRemoteSession()
        {
            UI.ConnectionDialog dialog = new UI.ConnectionDialog("New remote interactive");
            if (!dialog.Show())
            {
                return;
            }

            string       computerName = (dialog.ComputerName.Length == 0 || dialog.ComputerName == ".") ? "localhost" : dialog.ComputerName;
            PSCredential credential   = null;

            if (dialog.UserName.Length > 0)
            {
                credential = NativeMethods.PromptForCredential(null, null, dialog.UserName, string.Empty, PSCredentialTypes.Generic | PSCredentialTypes.Domain, PSCredentialUIOptions.Default);
                if (credential == null)
                {
                    return;
                }
            }

            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, computerName, 0, null, null, credential);

            EnsureHost();

            Runspace = RunspaceFactory.CreateRunspace(FarHost, connectionInfo);
            RunspaceOpen();

            Editor.Title = "PS " + computerName + " session " + Path.GetFileName(Editor.FileName);

            InvokeProfile("Profile-Remote.ps1", true);
        }
예제 #2
0
        void OpenRemoteSession()
        {
            UI.ConnectionDialog dialog = new UI.ConnectionDialog("New Remote Editor Console");
            if (!dialog.Show())
                return;

            string computerName = (dialog.ComputerName.Length == 0 || dialog.ComputerName == ".") ? "localhost" : dialog.ComputerName;
            PSCredential credential = null;
            if (dialog.UserName.Length > 0)
            {
                credential = NativeMethods.PromptForCredential(null, null, dialog.UserName, string.Empty, PSCredentialTypes.Generic | PSCredentialTypes.Domain, PSCredentialUIOptions.Default);
                if (credential == null)
                    return;
            }

            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, computerName, 0, null, null, credential);

            EnsureHost();

            Runspace = RunspaceFactory.CreateRunspace(FarHost, connectionInfo);
            RunspaceOpen();

            Editor.Title = computerName + " session: " + Path.GetFileName(Editor.FileName);

            InvokeProfile("Profile-Remote.ps1");
        }