我正在使用 C# 远程连接到 PowerShell 控制台:
using (Runspace remoteRunspace = RunspaceFactory.CreateRunspace(setUpConnection()))
{
remoteRunspace.Open();
using (PowerShell powershell = PowerShell.Create())
{
powershell.Runspace = remoteRunspace;
DateTime dateTime = GetTime(powershell); // <------ How to implement?
}
remoteRunspace.Close();
}
我想调用Get-Date PowerShell 命令并以某种方式PSObject
转换为DateTime
. 解决此问题的“通常”方法是什么?