powershell

PowerShell, the syntax of help-function

让人想犯罪 __ 提交于 2021-02-08 06:31:33
问题 Exploring the difference between help and get-help I did: cd Function: get-content help all the input-parameter are defined like: [string]${Name} $ =initiate a variable, {} a hashtable?? Thanks for your help. 回答1: For the official documentation, see the conceptual about_Variables help topic (invoke it with help about_Variables ), and in particular its "Variable Names that Include Special Characters" section. Enclosing the name of a variable in {...} - e.g. ${foo} - unambiguously delimits the

Replace multiple Strings with Data from CSV

本秂侑毒 提交于 2021-02-08 06:19:14
问题 I've got a CSV (with headers) from all of our access points and want to add them to Zabbix via XML Upload. Since I don't want to create an XML file for each AP manually, I'll try to do this in PowerShell. But - how? I've tried some things with (Get-Content .\Template.xml).Replace() and ForEach-Object , but I haven't had success yet. Filenames are: AP.csv (list of APs, headers are Hostname and IP): Hostname;IP AP1;10.29.202.101 AP2;10.29.202.102 AP3;10.29.202.103 AP4;10.29.202.104 Ap5;10.29

Powershell: how to split, do math and format

核能气质少年 提交于 2021-02-08 06:14:42
问题 I am looking for a 1-liner that looks something like this: (gitversion | ConvertFrom-Json).SemVer.split('.') | [string]::Format("{0}.{1}.{2}",$_[0],$_[1] + 1,$_[2]) | git tag $_ So, right now I have 0.1.0 and I want a 1 liner that will map it to: 0.2.0 I am sure a guru in PS can make fast work of this 回答1: You can read in the entire json, use the Major, Minor and Patch number of the version and update whichever one you are interested in... patch, minor or major. I am using foreach-object to

Powershell: how to split, do math and format

陌路散爱 提交于 2021-02-08 06:14:23
问题 I am looking for a 1-liner that looks something like this: (gitversion | ConvertFrom-Json).SemVer.split('.') | [string]::Format("{0}.{1}.{2}",$_[0],$_[1] + 1,$_[2]) | git tag $_ So, right now I have 0.1.0 and I want a 1 liner that will map it to: 0.2.0 I am sure a guru in PS can make fast work of this 回答1: You can read in the entire json, use the Major, Minor and Patch number of the version and update whichever one you are interested in... patch, minor or major. I am using foreach-object to

Powershell: how to split, do math and format

旧城冷巷雨未停 提交于 2021-02-08 06:14:22
问题 I am looking for a 1-liner that looks something like this: (gitversion | ConvertFrom-Json).SemVer.split('.') | [string]::Format("{0}.{1}.{2}",$_[0],$_[1] + 1,$_[2]) | git tag $_ So, right now I have 0.1.0 and I want a 1 liner that will map it to: 0.2.0 I am sure a guru in PS can make fast work of this 回答1: You can read in the entire json, use the Major, Minor and Patch number of the version and update whichever one you are interested in... patch, minor or major. I am using foreach-object to

How to handle progress bar using PowerShell?

≡放荡痞女 提交于 2021-02-08 05:22:10
问题 I want to capture an image with this method DISM.exe /capture-ffu /imagefile=e:\WinOEM.ffu /capturedrive=\\.\PhysicalDrive0 /name:disk0 /description:"Windows 10 FFU" Reference: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/deploy-windows-using-full-flash-update--ffu in the powershell I used this way & DISM.exe /capture-ffu /imagefile=e:\WinOEM.ffu /capturedrive=\\.\PhysicalDrive0 /name:disk0 /description:"Windows 10 FFU" and It show the command window while capturing.

Questions/Problems related to set-winuserlanguagelist command

ε祈祈猫儿з 提交于 2021-02-08 05:18:35
问题 I'm building a code to fix keyboard layout situation on windows 10. With automated solution, I decided to use powershell. But the problem is that I'm pretty new in it and face certain problems. I managed to dig a script to change keyboard layouts, however it changes only to one language. As I try to create array with 2 languages: $langlist=$lang_en,$lang_ru set-winuserlanguagelist $langlist It simply returns me next error: Set-WinUserLanguageList : Cannot convert 'Microsoft

how to change PowerShell mode to fulllanguage mode from constrained mode?

陌路散爱 提交于 2021-02-08 05:10:58
问题 I open the PS or PSISE, they are both constrianedlanguage mode which I do not expect. I don't know why it's ConstrainedLanguage. Two days ago it's just the PSISE is in constrainedmode and the PS is fulllanguage mode. Now after I restart my computer, both of them is constrainedmode and it's so bothering me because I really need to use the full mode.. I've tried to start PS as admin, not working. Tried to create a new environment variable __PSLockdownPolicy and set it to 1 or 0, still not

how to change PowerShell mode to fulllanguage mode from constrained mode?

送分小仙女□ 提交于 2021-02-08 05:09:30
问题 I open the PS or PSISE, they are both constrianedlanguage mode which I do not expect. I don't know why it's ConstrainedLanguage. Two days ago it's just the PSISE is in constrainedmode and the PS is fulllanguage mode. Now after I restart my computer, both of them is constrainedmode and it's so bothering me because I really need to use the full mode.. I've tried to start PS as admin, not working. Tried to create a new environment variable __PSLockdownPolicy and set it to 1 or 0, still not

How to find and replace all occurrences of “(percentage)%” in a text file and replace with a user supplied Integer

。_饼干妹妹 提交于 2021-02-08 04:59:32
问题 I am trying to parse through a text file with regex finding percentages as strings and replacing the findings with the percentage multiplied by a user supplied integer. If the user inputs 400, then the code should return "120 x 8, 180 x 6, etc" Tried doing a replace but it replaces all findings with the same string. $body = "30% x 8, 45% x 6, 55% x 4, 60% x 2, 65% x 1, 70% x 1, 75% x 1, 80% x 1, 72.5% x 4, 70% x 4, 67.5% x 4, 65% x 4" $regex1 = "(\d+(\.\d+)?%)" $regex2 = "(\d+(\.\d+)?)"