powershell

Powershell replace special characters like ü

浪子不回头ぞ 提交于 2021-01-28 03:41:15
问题 (Get-Content -Path $filePath) -creplace ${find}, $replace | Add-Content -Path $tempFilePath If $find and $replace contains below values it's not replacing it ç c à a é e Please help 回答1: You need to -Encoding UTF8 to the Get-Content method, for reading the special characters correctly: (Get-Content -Path $filePath -Encoding UTF8) -creplace ${find}, $replace | Add-Content -Path $tempFilePath 回答2: If by characters like ü you mean Diacritics you can use this: function Replace-Diacritics { Param(

Run a powershell script on a remote system with elevated permissions to enable remoting

╄→гoц情女王★ 提交于 2021-01-28 03:41:14
问题 I am trying to use the following code to copy a PowerShell script to remote windows 7 machine; run it with elevated privileges on this machine to enable remoting on that system. It is copying the script file to the remote system but it is not executing the command in the remote PowerShell session because of the empty $command variable (the second line in the script below is not working). Copy-Item -Path C:\users\user1\Myscript.ps1 -Destination \\some-computer\c$\Myscript.ps1 $command =

Jira user creation via REST results in 401 - This resource requires WebSudo

自古美人都是妖i 提交于 2021-01-28 03:05:41
问题 I'm attempting to write a PowerShell script that will automate the process of adding new user accounts to our Jira instance. I've provided my code but I'm honestly not even getting to that point as I am receiving a 401 error: This resource requires WebSudo. I have seen these two posts on the Jira support forum but it's not clear to me how I could adapt the code to get and then apply it to my REST call. I would be fine with changing this to use the .Net WebClient class if that would make all

Import-Module works only when piped from Get-Module

前提是你 提交于 2021-01-28 02:35:48
问题 I wrote a simple PowerShell module. I need to keep more versions of the module. All paths to versions are added to $env:PSModulePath . I'm facing strange problem when importing the module to my session. This fails: Import-Module Contoso.PowerShell -RequiredVersion "0.0.2" Import-Module : The specified module 'Contoso.PowerShell' with version '0.0.2' was not loaded because no valid module file was found in any module directory. At line:1 char:1 + Import-Module Contoso.PowerShell

PowerShell Crashes On NavigateComplete2 Event Firing

廉价感情. 提交于 2021-01-28 02:24:48
问题 I've been trying to handle IE events from SHDocVw.Internet Explorer. To do this I added a reference to C:\windows\system32\ShDocVw.dll in a Visual Studio project, which when compiled automatically generated Interop.ShDocVw.dll I was unable to initialize SHDocVw.InternetExplorer directly in PowerShell, some more info on my issue here PowerShell Version Info PS C:\Users\chentiangemalc> $PSVersionTable Name Value ---- ----- PSVersion 5.1.14393.103 PSEdition Desktop PSCompatibleVersions {1.0, 2.0

Capture a literal string on stderr in powershell

放肆的年华 提交于 2021-01-28 01:39:18
问题 My application should write it's errors as literal JSON objects on stderr. This is proving difficult with PowerShell (5, 6 or 7) since PowerShell seems to want to prevent you from writing to stderr and, if you do succeed, it changes what you write. In all examples we are running the following from within a powershell/pwsh console: ./test.ps1 2> out.json test.ps1 Write-Error '{"code": "foo"}' out.json [91mWrite-Error: [91m{"code": "foo"}[0m PowerShell is changing my stderr output. Bad

Different file size between powershell and cmd [duplicate]

左心房为你撑大大i 提交于 2021-01-28 01:15:56
问题 This question already has answers here : Using redirection within the script produces a unicode output. How to emit single-byte ASCII text? (6 answers) Closed 2 years ago . I am using a little processconf.js tool to build a configuration.json file from multiple .json files. Here the command I am using : node processconf.js file1.json file2.json > configuration.json I was using cmd for a moment, but today I tried using Powershell and somehow from the same files and the same command I do have

Jira user creation via REST results in 401 - This resource requires WebSudo

六月ゝ 毕业季﹏ 提交于 2021-01-28 01:00:10
问题 I'm attempting to write a PowerShell script that will automate the process of adding new user accounts to our Jira instance. I've provided my code but I'm honestly not even getting to that point as I am receiving a 401 error: This resource requires WebSudo. I have seen these two posts on the Jira support forum but it's not clear to me how I could adapt the code to get and then apply it to my REST call. I would be fine with changing this to use the .Net WebClient class if that would make all

Azure DevOps: How to set the value of the Variable in Variable Group

女生的网名这么多〃 提交于 2021-01-28 00:32:04
问题 I am trying to overwrite the value of the variable from Variable Group in Azure DevOps and it's not working. It's always showing the original value. I wrote my Powershell scripts as shown by these links: Microsoft StackOverflow I added the Variable Group and Link it in my Build pipeline. I wrote the following scripts in Power Shell Script task. Write-Host "Original BPOwner = $(BPOwner)" Write-Host "Changing value of BPOwner to Bright Ran" Write-Host "##vso[task.setvariable variable=BPOwner;

Import-Module : The specified module 'msonline' was not loaded because no valid module file was found in any module directory

主宰稳场 提交于 2021-01-28 00:12:47
问题 Error : Import-Module : The specified module 'msonline' was not loaded because no valid module file was found in any module directory The error pops up when I try to load the module by typing : Import-Module MSOnline tried to install the Azure AD powershell module on my computer so I'd be able to make PSSession using the MSONLINE cmdlets. After I installed the Microsoft Online Services Sign-in Assistant (version7.250.4556.0) and then installed the latest Windows Azure AD Module for Windows