使用C#进入Enter-pssession [英] Enter-pssession using c#

查看:179
本文介绍了使用C#进入Enter-pssession的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何使用C#代码执行enter-pssession命令.
我已经使用以下命令在Powershell控制台中运行它.

Hello All,

I would like to know how I can execute enter-pssession command using c# code.
I have used following command to run it in powershell console.

$secpasswd = ConvertTo-SecureString "123$" -AsPlainText -Force 
$mycreds = New-object -typename System.Management.Automation.PSCredential("WIN-APRJ2923AV5.abc.com\Administrator",$secpasswd)
Enter-pssession 192.168.1.194 –credential $mycreds


但是我想使用c#代码来完成它,任何帮助将不胜感激.

问候
SEbastian


But I want to do it using c# code, any help would be appreciated.

Regards
SEbastian

推荐答案

secpasswd = ConvertTo-SecureString "
secpasswd = ConvertTo-SecureString "123


" -AsPlainText -Force
" -AsPlainText -Force


mycreds =新对象-类型名System.Management.Automation.PSCredential( WIN-APRJ2923AV5.abc.com \ Administrator"
mycreds = New-object -typename System.Management.Automation.PSCredential("WIN-APRJ2923AV5.abc.com\Administrator",


这篇关于使用C#进入Enter-pssession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆