Stack Overflow,
I am working on a PowerShell script to setup a developer environment for my team. I want to have it so that a user can click a shortcut and have the necessary developer tools downloaded and installed for them. These installations should be global and on the PATH. I already have the shortcut that calls the script working. The script itself is what I am having issues with.
I am using chocolatey to try and install node on the developers machine's.
Here is the code I have written so far
devEnv.ps1
echo "Installing Chocolatey package manager, check version with choco"
$env: ChocolateyInstall="$Home/chocolatey"
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
echo "Chocolatey installed. Installing NodeJS and NPM via Chocolatey."
Start-Process powershell.exe -argument "-NoExit -Command ./nodejs.ps1"
echo "Installation complete."
Write-Host -NoNewLine 'Press any key to continue...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
I am able to install chocolatey successfully, however I am not able to install node. I created another script that I call on line 5 of devEnv.ps1
I was hoping that the new PowerShell instance would have access to the choco command. It does not. Below I have included the second script.
nodejs.ps1
Invoke-Expression -Command "choco install nodejs.install"
Error Returned
choco : The term 'choco' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:1
+ choco install nodejs.install
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (choco:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException