powershell

How to pass powershell variable from one session to another or from one stage to another in terms of Jenkinsfile

只愿长相守 提交于 2021-02-11 12:29:37
问题 Every time I close the powershell session or window all the variable created in there is destroyed. Is there any command or way to create a variable which does not gets destoryed evenafter the session is closed. I know using script works but my situation is that my jenkins stage opens one window and creates a variable and the stage is closed which closes the session and in the next stage the new session is opened but all the initial variables are lost. I tried using jenkins environment

How to exclude data from json file to convert into csv file powershell

夙愿已清 提交于 2021-02-11 12:20:14
问题 I want to convert my json file into csv - { "count": 28, "value": [ { "commitId": "65bb6a911872c314a9225815007d74a", "author": { "name": "john doe", "email": "john.doe@gmail.com", "date": "2020-06-09T17:03:33Z" }, "committer": { "name": "john doe", "email": "john.doe@gmail.com", "date": "2020-06-09T17:03:33Z" }, "comment": "Merge pull request 3 from dev into master", "changeCounts": { "Add": 6, "Edit": 0, "Delete": 0 }, "url": "https://dev.azure.com/", "remoteUrl": "https://dev.azure.com/" },

Extract email:password

不羁岁月 提交于 2021-02-11 12:03:11
问题 I'm curious if there's a way to extract email:password from a big list. It is listed in the text in that format but with a few other unuseable parts in front (such as name, last name). The format is mostly: xx:Mxx:Support:xx:support@xx.com:x19000 But sometimes can be like this as well: xxxx::gexrge@xxnt.com:111111 I have tried with EmEditor and if I search for (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09

Powershell - Delete Everything After a Delimiter - In Text files Found in Folder

99封情书 提交于 2021-02-11 11:53:06
问题 I would like to delete content from a bunch of text files. In each text file - Delete Everything After the ****** $Path = "C:\Users\Desktop\Delete\*.txt" # Folder Containing Text files $OutPath = "C:\Users\Desktop\Files\" Get-Content c.txt | Where { $_ -notmatch "*****" } | Set-Content $OutPath I have seen this powershell delete everything after character for every line in a file I couldn't get it to work I am a newbie with power shell do please forgive my code. Thank you 回答1: You can use the

Powershell - Delete Everything After a Delimiter - In Text files Found in Folder

China☆狼群 提交于 2021-02-11 11:53:00
问题 I would like to delete content from a bunch of text files. In each text file - Delete Everything After the ****** $Path = "C:\Users\Desktop\Delete\*.txt" # Folder Containing Text files $OutPath = "C:\Users\Desktop\Files\" Get-Content c.txt | Where { $_ -notmatch "*****" } | Set-Content $OutPath I have seen this powershell delete everything after character for every line in a file I couldn't get it to work I am a newbie with power shell do please forgive my code. Thank you 回答1: You can use the

How to Display Modified Time and Modified By Fields Correctly with Powershell

大憨熊 提交于 2021-02-11 07:21:41
问题 I have a script that outputs to CSV all items/files from all Lists and Libraries. In addition, it displays the current and previous versions of an item/file. This also displays which user modified the file for each version and also displays the date/time the file was modified for every version: function Get-DocInventory([string]$siteUrl) { $web = Get-SPWeb "http://contoso.com/sites/Depts3/HBG" foreach ($list in $web.Lists) { foreach ($item in $list.Items) { foreach($version in $item.Versions)

How to Display Modified Time and Modified By Fields Correctly with Powershell

别说谁变了你拦得住时间么 提交于 2021-02-11 07:21:26
问题 I have a script that outputs to CSV all items/files from all Lists and Libraries. In addition, it displays the current and previous versions of an item/file. This also displays which user modified the file for each version and also displays the date/time the file was modified for every version: function Get-DocInventory([string]$siteUrl) { $web = Get-SPWeb "http://contoso.com/sites/Depts3/HBG" foreach ($list in $web.Lists) { foreach ($item in $list.Items) { foreach($version in $item.Versions)

Merge 2 CSV Files with Powershell using Import-Excel

泄露秘密 提交于 2021-02-11 07:01:58
问题 I have 2 CSV Files that contain different information. There is one column which is similar in both files. I want to merge the two files by checking the ID Column to get a new file with all information from both files. So it should be like this: File A Column 1 = ID Column 2 = Text Column 3 = other Text File B Column 1 = ID Column 2 = some other text I want to merge them now using powershell and "import-excel" module to get one new csv: File C Column 1 = ID Column 2 = Text Column 3 = other

How can I optimize this Powershell script, converting JSON to CSV?

拜拜、爱过 提交于 2021-02-11 06:55:28
问题 I have a very large JSON Lines File with 4.000.000 Rows, and I need to convert several events from every row. The resulted CSV File contains 15.000.000 rows. How can I optimize this script? I'm using Powershell core 7 and it takes around 50 hours to complete the conversion. My Powershell script: $stopwatch = [system.diagnostics.stopwatch]::StartNew() $totalrows = 4000000 $encoding = [System.Text.Encoding]::UTF8 $i = 0 $ig = 0 $output = @() $Importfile = "C:\file.jsonl" $Exportfile = "C:\file

How to create a powershell script / or windows .bat file for ffmpeg

守給你的承諾、 提交于 2021-02-11 06:31:34
问题 So, I want to create a Powershell or Batch file (whichever works best for the task), that I can paste in a folder and after executing it, will start to use FFmpeg to encode all videos The part that works (in .bat): for %%a in ("*.mkv") do( ffmpeg -i "%%a" -c:v libx265 -c:a copy -x265-params crf=25 "%%a [encoded].mkv" pause) This works, but in some folders, I already have [encoded] files. I'd like for the script to skip these files. I asked in reddit and received the following script: for %%a