Scripting

Reading and writing serial port data with PowerShell

List com ports To see a list of available com ports, PS C:\> [System.IO.Ports.SerialPort]::getportnames()<br /> COM1<br /> COM2<br /> COM3 Read or write data To read or write data with given details, such as port, Baudrate etc. $port= new-Object System.IO.Ports.SerialPort COM3,9600,None,8,one $port.open() $port.WriteLine("some string data") $port.ReadLine() $port.Close() Write unix time I have a clock which accepts unix time for syncing the time, so I use script below to sync the time if the clock being off for few minutes after some time.

Software installation on multiple systems with PowerShell

In this exercise, I will try to install a software on multiple systems with PowerShell, which could reduce some maintenance effort when we need to install or patch some software regularly. The way here is to copy installation file to c:\temp first to remote systems, then install it with remote session, and then check registry and see the installation details. $computers="computer1","computer2" $path="\\server1\sharefolder\TestInstall.msi" $computers | where{test-connection $_ -quiet -count 1} | ForEach-Object{ copy-item $path "\\$_\c$\temp" } Invoke-Command { dir c:\temp\TestInstall.

psake script in Visual Studio

A sample project will be set up in Visual Studio for writing psake script, Create a new Class Library Project Install Nuget Package – psake Add a default.ps1 file with some test script, or that can be copied from packages\psake.x.x.0\tools\examples default.ps1 Execute the script: Import-Module .\packages\psake.4.6.0\tools\psake.psm1 Invoke-psake .\psake\default.ps1