本文整理汇总了C#中PowerShell.ImportCredentials方法的典型用法代码示例。如果您正苦于以下问题:C# PowerShell.ImportCredentials方法的具体用法?C# PowerShell.ImportCredentials怎么用?C# PowerShell.ImportCredentials使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PowerShell
的用法示例。
在下文中一共展示了PowerShell.ImportCredentials方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupPowerShellEnvironment
public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials)
{
powerShell.RemoveCredentials();
string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);
Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
powerShell.ImportCredentials(credentialFile);
foreach (string key in this.environment.Keys) powerShell.AddEnvironmentVariable(key, environment[key]);
foreach (string key in this.PowerShellVariables.Keys) powerShell.SetVariable(key, PowerShellVariables[key]);
}
示例2: ImportCredentails
public static void ImportCredentails(PowerShell powerShell, string credentialFile)
{
powerShell.RemoveCredentials();
powerShell.ImportCredentials(credentialFile);
}
示例3: SetupPowerShellEnvironment
public void SetupPowerShellEnvironment(PowerShell powerShell, string credentials, string profile)
{
powerShell.RemoveCredentials();
string profileFile = Path.Combine(this.downloadDirectoryPath, profile);
if (File.Exists(profileFile))
{
string dest = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, profile);
powerShell.AddScript(string.Format("Copy-Item -Path '{0}' -Destination '{1}' -Force", profileFile, dest));
powerShell.AddScript("[Microsoft.WindowsAzure.Commands.Utilities.Common.WindowsAzureProfile]::Instance.Load()");
}
else
{
string credentialFile = Path.Combine(this.downloadDirectoryPath, credentials);
Assert.IsTrue(File.Exists(credentialFile), string.Format("Did not download file {0}", credentialFile));
Console.WriteLine("Using default.PublishSettings for setting up credentials");
powerShell.ImportCredentials(credentialFile);
}
foreach (string key in this.environment.Keys) powerShell.AddEnvironmentVariable(key, environment[key]);
foreach (string key in this.PowerShellVariables.Keys) powerShell.SetVariable(key, PowerShellVariables[key]);
}