powershell

Object Relational Mapping from CSV with PowerShell?

最后都变了- 提交于 2021-01-28 10:49:49
问题 "How to iterate through CSV data from PowerShell ?" would perhaps be an alternate question title. This output is fine: PS /home/nicholas> PS /home/nicholas> $flat Date Region New_Tests Total_Tests Positivity Turn_Around ---- ------ --------- ----------- ---------- ----------- 2020-01-23 BC 2 2 0 32 2020-01-23 Fraser 0 0 0 0 2020-01-23 Interior 0 0 0 0 2020-01-23 Northern 0 0 0 0 2020-01-23 Unknown 0 0 0 0 2020-01-23 Vancouver Coastal 2 2 0 32 2020-01-23 Vancouver Island 0 0 0 0 .. but I'd be

Generate HMAC SHA256 signature Powershell

女生的网名这么多〃 提交于 2021-01-28 10:48:31
问题 For 3commas I tried to generate a HMAC SHA256 signature in Powershell with the example parameters from the documentation: $secret = 'NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j' $message = '/public/api/ver1/accounts/new?type=binance&name=binance_account&api_key=XXXXXX&secret=YYYYYY' $hmacsha = New-Object System.Security.Cryptography.HMACSHA256 $hmacsha.key = [Text.Encoding]::ASCII.GetBytes($secret) $signature = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($message

Is it possible to change the directory of a windows console from an app?

こ雲淡風輕ζ 提交于 2021-01-28 10:45:45
问题 My goal is to write an app that lets you quickly assign aliases to long directory paths and change to them. I wrote an app that manages them in a file in the user's appdata directory, but I can't find a way to change the directory of the shell I run the program in from my app. My goal is to have it work from git bash, cmd.exe, and powershell. I want something like this: cd /c/vsts/some-long-project-name-reports g -a reports Now I have an alias 'reports' for that directory. What I want to do

How to configure a VSCode Task to run a powershell script in the integrated terminal

纵饮孤独 提交于 2021-01-28 10:40:44
问题 In such a way that it is not in a sub shell. I need it to be able to prepare the environment...set environment variable. "version": "0.1.0", "command": "${workspaceFolder}/Invoke-Task.ps1", /*"command": "powershell", creates subshell so doesn't work*/ "isShellCommand": false, "args": [], "showOutput": "always", "echoCommand": true, "suppressTaskName": true, "tasks": [ { "taskName": "task1", "args": ["task1"] }, { "taskName": "task2", "args": ["task2"] } ] 回答1: This has been doable since 2017,

PowerShell date format mmddyy

偶尔善良 提交于 2021-01-28 09:08:47
问题 I know I can set a date to a variable in PowerShell using $a = Get-Date It works great, but when looking through the documentation on formatting the date, there wasn't one for MMDDYY . How do I accomplish this? 回答1: Because $a is effectively a System.DateTime. You can do: $a = Get-Date Write-Host $a.ToString('MMddyy') Full details on custom Date and Time Format Strings are in Custom Date and Time Format Strings . 回答2: You just have to get creative with the -UFormat options. To get exactly

powershell word to pdf

☆樱花仙子☆ 提交于 2021-01-28 09:07:28
问题 I modified what someone else had on this forum, based on a successful use of powershell Excel to pdf with no success. Any ideas on my failing in the following code? My goal is to be able to convert an entire folder of doc and docx documents to pdf without opening the native applications. Thanks in advance: # Acquire a list of DOC files in a folder $Word = New-Object -ComObject word.application $path = "c:\Users\Desktop\Test" $formats = "Microsoft.Office.Interop.Word.WdFixedFormatType" -as

ForEach-Object -Parallel Parameter set cannot be resolved

痞子三分冷 提交于 2021-01-28 09:02:28
问题 When using powershell and following this article running the following example throws an error. Example: 1..5 | ForEach-Object -Parallel { "Hello $_"; sleep 1; } -ThrottleLimit 5 Error: ForEach-Object : Parameter set cannot be resolved using the specified named parameters. Removing the body of the loop does not resolve the issue. It is present whenever using the -Parallel keyword. The article is from last year which makes me think the feature must still be present in powershell. Am I missing

Select-Object -First affects prior cmdlet in the pipeline

风格不统一 提交于 2021-01-28 08:50:02
问题 The PowerShell Strongly Encouraged Development Guidelines that cmdlets should Implement for the Middle of a Pipeline but I suspect that isn't doable for a parameter as -Last for the Select-Object. Simply because you can't determine the last entry upfront. In other words: you will need to wait for the input stream to finish until you define the last entry. To prove this, I wrote a little script: $Data = 1..5 | ForEach-Object {[pscustomobject]@{Index = "$_"}} $Data | ForEach-Object { Write-Host

powershell word to pdf

怎甘沉沦 提交于 2021-01-28 08:41:11
问题 I modified what someone else had on this forum, based on a successful use of powershell Excel to pdf with no success. Any ideas on my failing in the following code? My goal is to be able to convert an entire folder of doc and docx documents to pdf without opening the native applications. Thanks in advance: # Acquire a list of DOC files in a folder $Word = New-Object -ComObject word.application $path = "c:\Users\Desktop\Test" $formats = "Microsoft.Office.Interop.Word.WdFixedFormatType" -as

Compare-Object cmdlet wont work with “<!--” in a txt file

风流意气都作罢 提交于 2021-01-28 08:40:57
问题 I am building another web server "web2", which must have the same configuration as web server "web1" So after installing some software I need to edit the "web.config" on the "web2" server to match the one in the "web1" server I am doing this from my laptop, so I copied both "web.config" files to my laptop running these commands: $w1="web1.server.local" $w2="web2.server.local" $myCred=(Get-Credential -credential "myAD\myUser") $file="C:\path\to\my\web.config" Invoke-Command -ComputerName $w1