powershell upgrade to 6.2 doesnt upgrade anything (except my mode) - powershell

I have run the script below
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"
The msi below gets downloaded and I run it, the wizard finishes without any remarks
https://github.com/PowerShell/PowerShell/releases/download/v6.2.0/PowerShell-6.2.0-win-x64.msi
The only problem is that when I run
"$PSVersionTable.PSVersion"
It still says
Major Minor Build Revision
----- ----- ----- --------
5 1 17763 316
and a require-statement in another script also says that I have v5.1...
(yes, I have restarted my machine:))
Any ideas?

Related

Terraform - Unable to intiate terraform

I am trying to initiate terraform on visual studio code - insiders.
Points:
I have downloaded the terraform executable file and i am able to launch it on command prompt.
When to run the command terraform init command on visual studio code - insider i get the following error message. Please find the error message below and also the location of the terraform index.
PS F:\terraform> terraform.exe init
Fatal error in launcher: Unable to create process using
'"c:\python38\python.exe" "c:\Python38\Scripts\terraform.exe" init':
the system cannot find the file specified.
PS F:\terraform> ls
Directory: F:\terraform
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 18-09-2021 22:21 .terraform
-a--- 18-09-2021 22:33 1035 .terraform.lock.hcl
-a--- 18-09-2021 22:48 219 main.tf
-a--- 18-09-2021 22:48 41 provider.tf
----- 18-09-2021 23:44 80807800 terraform.exe
I have tried to run the same code ps core 6 i get the above error message in the command prompt it works perfectly.
I really your inputs on what can be done.
Please help
Regards
Sudlo
Here the steps which I performed to fix the issue.
I launched PS core prompt went into the directory in my case
f:\terrform and passed the command terraform init I got the same error message.
went into the location C:\Python38\Scripts and located the terraform executable file deleted the file and copied it again and performed initialization command. This time there was no error.
Hope this helps

How do I pipe input to a command using powershell in a Dockerfile?

I'm trying to write a Dockerfile to build a windows image containing the android sdk.
During the installation of the sdk, the sdkmanager requires you to enter 'y' several times to accept licenses before continuing. I've been able to automate this in a normal powershell outside docker with the following line:
"y`n" * 8 | & '.\bin\sdkmanager.bat' --licenses
However, when I try to put this in the Dockerfile, it doesn't work. The sdkmanager ignores the input and just exits immediately at the first prompt.
Dockerfile (the triple quotes seem necessary to prevent them being stripped):
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2016
RUN iwr -UseBasicParsing https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip -OutFile sdk-tools.zip
RUN Expand-Archive sdk-tools.zip 'C:\Program Files (x86)\Android\android-sdk'
RUN """y`n""" * 8 | & 'C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat' --licenses
RUN & 'C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat' tools platform-tools
Output:
Step 7/14 : RUN iwr -UseBasicParsing https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip -OutFile sdk-tools.zip
---> Using cache
---> dfb0b47e99b8
Step 8/14 : RUN Expand-Archive sdk-tools.zip 'C:\Program Files (x86)\Android\android-sdk'
---> Using cache
---> a87ab84f86d0
Step 9/14 : RUN """y`n""" | & 'C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat' --licenses
---> Running in b5caf5584ba3
Warning: File C:\Users\ContainerAdministrator\.android\repositories.cfg could not be loaded.
7 of 7 SDK package licenses not accepted. 100% Computing updates...
Review licenses that have not been accepted (y/N)?
Removing intermediate container b5caf5584ba3
---> 2d88d3c72d9a
Step 10/14 : RUN & 'C:\Program Files (x86)\Android\android-sdk\tools\bin\sdkmanager.bat' tools platform-tools
---> Running in 27e8f5e804e9
I assume this is maybe a docker build limitation where it doesn't wait for user input. Is there any way around this?

vscode install failed with "install failed error" on windows7

I try to install vscode on windows7 and get "install failed error", no detailed information, is there someone get the same error? It is crazy that vscode can not be installed on windows.
Use something like 7Zip to extract the archived files to a VSCodeSetup folder, with the resulting files:
Mode LastWriteTime Length Name
---- ------------- ------ ----
----- 4/22/2015 8:28 AM 140782 background.gif
----- 4/27/2015 6:22 PM 60255967 Code-0.1.0-full.nupkg
----- 4/27/2015 6:22 PM 74 RELEASES
-a--- 4/30/2015 9:25 AM 1911 SquirrelSetup.log
----- 4/24/2015 11:12 AM 1492992 Update.exe
Then open PowerShell (a CMD window would also work). I cd'd into the VSCodeSetup folder and ran the following command:
PS>.\Update.exe --install=.
(You may need to run PS or the CMD window as Administrator)
Referenced post: VSCode Installation Failed - Failed to extract installer

Using Powershell to find the right PIDs to kill

I've hacked together a solution that allows me to commit changes to my Go language application to Azure Websites, compile into a Go binary, and then update the Web.Config to have the httpPlatformHandler use the newly created binary. This allows me to easily deploy changes to my Go app and have them (almost) instantly available on my Azure website. It's a neat prototype, and you can check it out here: https://github.com/wadewegner/azure-website-go-builder/
If you look at the last line of the deploy.cmd you'll see that I use Powershell to kill a w3wp.exe process. This forces it to restart and use the updated Web.Config.
powershell "stop-process (Get-Process w3wp | Sort-Object ws | Select -first 1).Id"
This is a hack and not ideal. In a default scenario there are two w3wp.exe processes running - one for our website and one for the SCM website (which is a management website). It will not work if we have more than one instance of our Azure website running. It also assumes that the right process to kill is the one with the smaller memory footprint - this is a bad assumption to make.
In Azure Websites we don't have a lot of facilities at our disposal for finding and killing processes.
When I run Get-Process w3wp ... I get this kind of output today:
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
364 40 7196 16032 85 0.55 5516 w3wp
667 77 61972 77372 350 5.72 3448 w3wp
However, with two instances of my website, it could be:
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
364 40 7196 16032 85 0.55 5516 w3wp
364 40 7196 16032 85 0.55 5517 w3wp
667 77 61972 77372 350 5.72 3448 w3wp
(Manually updated to make my point.)
So, the question is, what's the right way to choose the two processes I want to kill? I don't want to kill 3448.
Additionally, how do I find a better heuristic to choose the right processes?
I uploaded tlist.exe to run tlist -t and get this output:
D:\home\site\wwwroot>tlist -t
AdjustTokenPrivileges failed with 1300
w3wp.exe (5516)
20150107_070323.exe (4936)
w3wp.exe (3448)
cmd.exe (1976)
tlist.exe (5868)
This makes it clear that 5516 is the PID I want to kill.
Is there a way in Powershell to run Get-Process but if it somehow inspect child processes and filter out the w3wp.exe PID with the cmd.exe process?
Thank you!

Chain psexec and nunit is not working (psexec exit with code 1 and nunit is crashed)

Sorry for unclear subject but i really don't understand where problem.
I use a system for autotests c#+webdriver for chrome + nunit (2.6) + cc.net ( 1.6.7981.1)
And my tests is run on remote machine (Windows XP SP 2 x86)via psexec which start bat file on remote machine
bat file includes 2 commands:
run msbuild
run nunit-console
Well, psexec has next arguments
/accepteula \MachineName -u Login -p Pass -s Path\start.bat
Bat file has next command
nunit-console-x86.exe "%PROJECT_FOLDER%\Path\Tests.dll" "/xml=%TEST_RESULT_PATH%"
When cc.net launch psexec tests is started and the tests work during some time. Unexpected, psexec exit with code 1
message level="Error">Path\start.bat exited on MachineName with error code 1. message
But nunit-console on remote machine is continue working
And after some time console is crashed with error
szAppName : nunit-console-x86.exe szAppVer : 2.6.0.12051
szModName : kernel32.dll szModVer : 5.1.2600.2180 offset :
0001eb33
Message from Event log
Application: nunit-console-x86.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.IOException Stack: at
System.IO._Error.WinIOError(Int32, System.String) at
System.IO._ConsoleStream.Write(Byte[], Int32, Int32) at
System.IO.StreamWriter.Flush(Boolean, Boolean) at
System.IO.StreamWriter.Write(Char[], Int32, Int32) at
System.IO.TextWriter.WriteLine(System.String) at
System.IO.TextWriter.WriteLine(System.String, System.Object) at
System.IO.TextWriter+SyncTextWriter.WriteLine(System.String,
System.Object) at System.Console.WriteLine(System.String,
System.Object) at NUnit.ConsoleRunner.Runner.Main(System.String[])
at NUnit.ConsoleRunner.Class1.Main(System.String[])
If run nunit locally than no problem(nunit-console works fun).
Some time ago system worked, and i don't know what is changed (This is most bad case)
How can i resolve this problem?
Thanks!
This problem is resolved!
Now system is working