powershell

How to continuously read Serial COM port in Powershell and occasionally write to COM port

与世无争的帅哥 提交于 2021-02-07 14:46:51
问题 I need to know how I can continuously read data in from the COM port and dump it to a file using Windows Powershell. While I am reading data in, I also need to monitor the data being read in and, depending on what the last line that was read, write data to the COM port. To open the COM port in Powershell, I am doing this: [System.IO.Ports.SerialPort]::getportnames() $port= new-Object System.IO.Ports.SerialPort COM3,115200,None,8,one $port.open() To read data in to the COM port, I am doing

How to continuously read Serial COM port in Powershell and occasionally write to COM port

偶尔善良 提交于 2021-02-07 14:44:25
问题 I need to know how I can continuously read data in from the COM port and dump it to a file using Windows Powershell. While I am reading data in, I also need to monitor the data being read in and, depending on what the last line that was read, write data to the COM port. To open the COM port in Powershell, I am doing this: [System.IO.Ports.SerialPort]::getportnames() $port= new-Object System.IO.Ports.SerialPort COM3,115200,None,8,one $port.open() To read data in to the COM port, I am doing

Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working correctly

微笑、不失礼 提交于 2021-02-07 14:38:39
问题 I must warn you I don't use powershell much. I am trying to turn off windows defender real time protection via powershell I found the command Set-MpPreference -DisableRealtimeMonitoring $true and tried it in admin privileges only to get this Set-MpPreference : Operation failed with the following error: 0x800106ba. Operation: Set-MpPreference. Target: DisableRealtimeMonitoring. At line:1 char:1 + Set-MpPreference -DisableRealtimeMonitoring $true + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`more.com` returns “Not enough memory.”

早过忘川 提交于 2021-02-07 14:37:49
问题 Environment details: x64 Win7 SP1 Enterprise Windows PowerShell v5.0 Without any profiles loaded, my local powershell sessions are returning Not enough memory. when I try to execute help or man . This occurs whether I'm using the native powershell.exe or conemu. Strangely, I am able to execute any other aliases I've tried, and it doesn't add to the $Error variable, so I have no idea where to start troubleshooting (I've tried -ErrorAction Stop and $ErrorActionPreference = 'Stop' ). As a

Powershell Set-MpPreference -DisableRealtimeMonitoring $true not working correctly

て烟熏妆下的殇ゞ 提交于 2021-02-07 14:37:46
问题 I must warn you I don't use powershell much. I am trying to turn off windows defender real time protection via powershell I found the command Set-MpPreference -DisableRealtimeMonitoring $true and tried it in admin privileges only to get this Set-MpPreference : Operation failed with the following error: 0x800106ba. Operation: Set-MpPreference. Target: DisableRealtimeMonitoring. At line:1 char:1 + Set-MpPreference -DisableRealtimeMonitoring $true + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`more.com` returns “Not enough memory.”

天大地大妈咪最大 提交于 2021-02-07 14:32:50
问题 Environment details: x64 Win7 SP1 Enterprise Windows PowerShell v5.0 Without any profiles loaded, my local powershell sessions are returning Not enough memory. when I try to execute help or man . This occurs whether I'm using the native powershell.exe or conemu. Strangely, I am able to execute any other aliases I've tried, and it doesn't add to the $Error variable, so I have no idea where to start troubleshooting (I've tried -ErrorAction Stop and $ErrorActionPreference = 'Stop' ). As a

PowerShell — Accessing a JArray inside a JObject

ε祈祈猫儿з 提交于 2021-02-07 14:24:20
问题 I have a Json object { "ProjectDirectory": "C:\\Main", "SiteName": "RemoteOrder", "ParentPath": "/Areas//Views", "VirtualDirectories": [ { "Name": "Alerts", "Path": "\\Areas\\RemoteOrder\\Views\\Alerts" }, { "Name": "Analytics", "Path": "\\Areas\\RemoteOrder\\Views\\Analytics" }, { "Name": "Auth", "Path": "\\Areas\\RemoteOrder\\Views\\Auth" } ] } that I created by $config = [Newtonsoft.Json.Linq.JObject]::Parse($file) I can access things like $config["ProjectDirectory"] $config[

Is there a way to convert tables of text into a PowerShell Object

☆樱花仙子☆ 提交于 2021-02-07 14:15:44
问题 There are many tools that output their data in in a table format. One such example is diskpart. Shaving off some extraneous output, you would get something like this. Disk ### Status Size Free Dyn Gpt -------- ------------- ------- ------- --- --- Disk 0 Online 136 GB 0 B Disk 1 Offline 136 GB 136 GB Disk 2 Reserved 1027 MB 0 B * Disk 3 Reserved 500 GB 0 B * Disk 4 Reserved 500 GB 0 B * Disk 5 Reserved 10 GB 0 B * Disk 6 Reserved 13 GB 0 B * Disk 7 Reserved 4102 MB 0 B * Disk 8 Reserved 7169

Powershell How to Overload Array Index Operator?

只谈情不闲聊 提交于 2021-02-07 14:14:50
问题 In Powershell, how do you overload the indexing of an array operator? Here is what I am doing now: class ThreeArray { $myArray = @(1, 2, 3) [int] getValue ($index) { return $this.myArray[$index] } setValue ($index, $value) { $this.myArray[$index] = $value } } $myThreeArray = New-Object ThreeArray Write-Host $myThreeArray.getValue(1) # 2 $myThreeArray.setValue(2, 5) Write-Host $myThreeArray.getValue(2) # 5 And, I want to do this: $myThreeArray = New-Object ThreeArray Write-Host $myThreeArray[1

Call Powershell Script from VBA(with Parameter)

感情迁移 提交于 2021-02-07 13:25:44
问题 I want to call a Powershell-Script from Excel VBA and pass 1 Parameter. Without VBA the Script works perfectly and does what it supposed to do.. As soon as the Call works, i would like to add 1 parameter, but first the successfull call... But i cant manage to call it within Excel VBA. First ill show you my Powershell-Script: #param([string]$server) $server = "chvmes01" $BasicPath = Split-Path $script:MyInvocation.MyCommand.Path write-host $BasicPath Invoke-Command -FilePath $BasicPath