当前位置: 首页>>代码示例>>C#>>正文


C# PowerShell.AddArgument方法代码示例

本文整理汇总了C#中PowerShell.AddArgument方法的典型用法代码示例。如果您正苦于以下问题:C# PowerShell.AddArgument方法的具体用法?C# PowerShell.AddArgument怎么用?C# PowerShell.AddArgument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PowerShell的用法示例。


在下文中一共展示了PowerShell.AddArgument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachPipeline

        private void AttachPipeline(PowerShell ps)
        {
            foreach (string cmd in pipeLine)
            {
                if (cmd.Length > 0 && cmd[0] == '$')
                {
                    ps.AddScript(cmd);
                }
                else
                {
                    string[] cmdOpts = cmd.Split(' ');
                    string cmdName = cmdOpts[0];
                    ps.AddCommand(cmdName);

                    string opts = string.Empty;
                    bool skip = false;
                    for (int i = 1; i < cmdOpts.Length; i++)
                    {
                        if (skip)
                        {
                            skip = false;
                            continue;
                        }

                        if (cmdOpts[i].IndexOf("-") != 0)
                        {
                            ps.AddArgument(cmdOpts[i]);
                        }
                        else
                        {
                            if (i + 1 < cmdOpts.Length && cmdOpts[i + 1].IndexOf("-") != 0)
                            {
                                ps.AddParameter(cmdOpts[i].Substring(1), cmdOpts[i + 1]);
                                skip = true;
                            }
                            else
                            {
                                ps.AddParameter(cmdOpts[i].Substring(1));
                                skip = false;
                            }
                        }
                    }

                    //add storage context for azure storage cmdlet
                    //It make sure all the storage cmdlet in pipeline use the same storage context
                    if (cmdName.ToLower().IndexOf("-azurestorage") != -1)
                    {
                        AddCommonParameters(ps);
                    }
                }
            }
        }
开发者ID:bryanhunter,项目名称:azure-sdk-tools,代码行数:52,代码来源:PowerShellAgent.cs

示例2: RunScript

	    private async Task<bool> RunScript(string path)
	    {
            PowerShellInstance = PowerShell.Create();

            PowerShellInstance.AddScript(LoadScript(path));

            PowerShellInstance.AddArgument(CredentialHelper.GetFormRegistery(CredentialHelper.SourceRepoUserName));
            PowerShellInstance.AddArgument(CredentialHelper.GetFormRegistery(CredentialHelper.SourceRepoPassword));
            PowerShellInstance.AddArgument(CredentialHelper.GetFormRegistery(CredentialHelper.TargetRepoUserName));
            PowerShellInstance.AddArgument(CredentialHelper.GetFormRegistery(CredentialHelper.TargetRepoPassword));

            PSDataCollection<PSObject> outputCollection = new PSDataCollection<PSObject>();
            outputCollection.DataAdded += outputCollection_DataAdded;

            PowerShellInstance.Streams.Error.DataAdded += Error_DataAdded;

            IAsyncResult result = PowerShellInstance.BeginInvoke<PSObject,PSObject>(null, outputCollection);

	        while (result.IsCompleted == false)
	        {
                await Task.Delay(100);
	        }
	        return PowerShellInstance.HadErrors;
	    }
开发者ID:Orckestra,项目名称:C1-Packages,代码行数:24,代码来源:Form1.cs


注:本文中的PowerShell.AddArgument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。