【发布时间】:2013-10-09 21:25:45
【问题描述】:
我只是坐在 windows cmd shell 前面并通过 powershell 打开一个 COM 端口以将一些信息发送到外部设备。如果我在 shell 中输入以下代码,一切正常:
powershell
$port=new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one
$port.open(
$port.WriteLine("Hello world")
$port.Close()
但现在我想向端口发送日期和时间,所以我想我只需要更改第 5 行:
$port.WriteLine(Get-Date)
或
$port.WriteLine($Get-Date)
但这不起作用(外壳用红色字母告诉我一些奇怪的东西),到目前为止我不知道如何做到这一点...... 谁能帮帮我?
【问题讨论】:
标签: powershell time send