powershell

Execute batch file in Powershell

為{幸葍}努か 提交于 2021-02-19 04:01:35
问题 I want to execute the following from a batch file: "C:\OpenCover\tools\OpenCover.Console.exe" -register:user -target:"%VS110COMNTOOLS%..\IDE\mstest.exe" -targetargs:"/testcontainer:\"C:\Develop\bin\Debug\MyUnitTests.dll\" ... " PAUSE Now I would like to log the output of the process to a file for which I came across the quite handy powershell usage of powershell "dir | tee output.log" but this does not take my batch file as first argument ( powershell "my.bat | tee output.log" ) because it is

Import-Module with -force removes imported module function?

限于喜欢 提交于 2021-02-19 03:38:04
问题 I have "ModuleA" that imports functions from modules "ADAutoDeployUtilities" and "Common_LoggingNotifications" using the code below. However, I keep receiving the exception (listed below) when I try to import Common_LoggingNotifications using -force. If I do not load Common_LoggingNotifications, only the ADAutoDeployUtilities functions are imported (which doesn't include writeJobLog) and everything runs fine, although I get the indicated exception when running on the server. I have also

Passing double quotes through PowerShell + WinRM

我的梦境 提交于 2021-02-19 03:08:31
问题 I am using this code to execute remote code (MSI installs) on a server. Passing double quote through the script is just not working. I tried two variations as given below (#3 and #4) along with the outputs. Input #1 (Simple case to test double quotes in the command) powershell.exe -inputformat none -File client.ps1 -target 1.2.3.4 -port 5985 -password "pass" -username "user" -command "echo hello" Output (Works) hello Input #2 (Understandable, this won't work) powershell.exe -inputformat none

Passing double quotes through PowerShell + WinRM

六月ゝ 毕业季﹏ 提交于 2021-02-19 03:07:12
问题 I am using this code to execute remote code (MSI installs) on a server. Passing double quote through the script is just not working. I tried two variations as given below (#3 and #4) along with the outputs. Input #1 (Simple case to test double quotes in the command) powershell.exe -inputformat none -File client.ps1 -target 1.2.3.4 -port 5985 -password "pass" -username "user" -command "echo hello" Output (Works) hello Input #2 (Understandable, this won't work) powershell.exe -inputformat none

Passing double quotes through PowerShell + WinRM

╄→гoц情女王★ 提交于 2021-02-19 03:04:46
问题 I am using this code to execute remote code (MSI installs) on a server. Passing double quote through the script is just not working. I tried two variations as given below (#3 and #4) along with the outputs. Input #1 (Simple case to test double quotes in the command) powershell.exe -inputformat none -File client.ps1 -target 1.2.3.4 -port 5985 -password "pass" -username "user" -command "echo hello" Output (Works) hello Input #2 (Understandable, this won't work) powershell.exe -inputformat none

Best way to get file type association in Windows 10 from command line?

别来无恙 提交于 2021-02-19 01:54:45
问题 I am aware that I can use assoc and ftype on the command line to get the file type assocation. So when i do: I am under the impression that .html files are opened with iexplorer. However html files are opening with chrome since chrome has been set as the default app for html files. Why is ftype giving me iexplorer when indeed the program opens with chrome? 回答1: It seems that ftype and assoc are pretty useless on systems running Windows 8 or later. This is due to the fact that Microsoft

Adding leading zeros to a file name using PowerShell

纵饮孤独 提交于 2021-02-18 22:20:46
问题 I have about 1500 files that name with number.jpg. for example, 45312.jpg or 342209.jpg or 7123.jpg or 9898923.jpg or 12345678.jpg Total number before the extension should be 8 digits. So I need to add leading zeros for if it less than 8 digit to make 8 digits file name. 00001234.jpg 00012345.jpg 00123456.jpg 01234567.jpg I tried this powershell script but it's complaining. I tried this but output is same $fn = "92454.jpg" "{0:00000000.jpg}" -f $fn OR $fn = "12345.jpg" $fn.ToString("00000000

In PowerShell, everytime I execute the script the array gets bigger

╄→гoц情女王★ 提交于 2021-02-18 19:11:28
问题 So I'm starting with PowerShell and this is odd to me. I put a breakpoint in the last line and when I run the script $newArray is "abc" then it pauses in Write-Output and I stop the debugger. If I run it again, $newArray is "abcabc" and so on. For one, I think I'm doing something wrong as this behavior is so weird to me, like it stores in memory despite of stopping the debugger. And secondly I would expect $newArray to be an array and not a single string with the values concatenated. Any

Start-Process with PowerShell.exe exhibits different behavior with embedded single quotes and double quotes

喜你入骨 提交于 2021-02-18 19:00:44
问题 First, in case anyone wonders why we're invoking PowerShell in this way, I ran into this behavior with a more complex command we were building, but the behavior can be exhibited using a more simple example as shown below. In practice, we are running a command under 32-bit PowerShell as admin with additional variables rendered in the string (hence why I don't simply use single-quotes for the outer portion), but that doesn't seem to factor into the behavior below. When I invoke PowerShell

Start-Process with PowerShell.exe exhibits different behavior with embedded single quotes and double quotes

耗尽温柔 提交于 2021-02-18 18:59:38
问题 First, in case anyone wonders why we're invoking PowerShell in this way, I ran into this behavior with a more complex command we were building, but the behavior can be exhibited using a more simple example as shown below. In practice, we are running a command under 32-bit PowerShell as admin with additional variables rendered in the string (hence why I don't simply use single-quotes for the outer portion), but that doesn't seem to factor into the behavior below. When I invoke PowerShell