PowerShell PackageManagement (OneGet) - Install Apps from Command Line
-
Thanks very much for your testing and help. I'll keep watch for further developments.
Rich
Kari,
Tried my hand with a short script and different approach and was successful. This is what I did:
<#
# $MyPackages is array of packages to be installed
#>
$MyPackages = "audacity", "ccleaner", "cdburnerxp", "classic-shell", "defraggler", "everything", "firefox -RequiredVersion 37.0.1", "googleearth", "opera-beta", "lastpass", "malwarebytes", "picasa", "revouninstallerpro", "skype", "speccy", "teamviewer","thunderbird", "treesizefree", "utorrent", "vlc", "windirstat"
foreach ($item in $MyPackages)
{$item
Install-Package $item -WhatIf
}
-
That's interesting to know!
-
@rmonroe36, this WaitHandles bug seems to be fixed in Build 10074, at least I am no longer getting the error when installing 12 to 15 apps with one command.
If you test it, please let me know if it works for you.
-
-

Note
There were a bug in PowerShell in last builds making changing the script execution policy impossible, therefore the OneGet did not work properly.
The bug was fixed in Build 10158 and OneGet works again exactly as told in this tutorial.
:) Kari
-

Note
There were a bug in PowerShell in last builds making changing the script execution policy impossible, therefore the OneGet did not work properly.
The bug was fixed in Build 10158 and OneGet works again exactly as told in this tutorial.
:) Kari
Yes, I had experienced that bug and had me crazy for a while. Some research led me to Gpedit. I forgot the details but a policy change fixed that bug. But no need for that now - all is well with my script that you previously helped with.
Rich
-
-
Well, first thing I seem to get wrong is that when I run PowerShell ISE as Admin, instead of saying PS C:\Users\myid> it gives me PS C:\WINDOWS\System 32.
Does this make a difference?
-
Well, first thing I seem to get wrong is that when I run PowerShell ISE as Admin, instead of saying PS C:\Users\myid> it gives me PS C:\WINDOWS\System 32.
Does this make a difference?
No, that is normal. Whenever you run an admin (elevated) Command Prompt, PowerShell or PowerShell ISE, the default working folder is C:\Windows\System32. The CD command works in PowerShell exactly as in Command promt; assuming that your user profile folder would be C:\Users\Wynona you can "jump" to it with CD C:\Users\Wynona.
The default working folder in normal (not elevated) Command Prompt, PowerShell or PowerShell ISE is the user profile folder.
The instructions in tutorial are valid both when using an admin or normal PowerShell, with one difference: To get the full script execution rights in admin PowerShell the cmdlet Set-ExecutionPolicy Unrestricted is enough. When doing this in normal non-elevated PowerShell, you need to tell PowerShell that the rights should be granted to current user by adding the -Scope switch with CurrentUser parameter.
Like this:
- Execution rights when using elevated PowerShell:
Code:
Set-ExecutionPolicy Unrestricted
- Execution rights when using non-elevated PowerShell:
Code:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
-
When I type Get-Command -Module OneGet, I don't get the list of cmdlets you show. 
Should I?
-
No, that is normal. Whenever you run an admin (elevated) Command Prompt, PowerShell or PowerShell ISE, the default working folder is
C:\Windows\System32. The
CD command works in PowerShell exactly as in Command promt; assuming that your user profile folder would be
C:\Users\Wynona you can "jump" to it with
CD C:\Users\Wynona.
The default working folder in normal (not elevated) Command Prompt, PowerShell or PowerShell ISE is the user profile folder.
The instructions in tutorial are valid both when using an admin or normal PowerShell, with one difference: To get the full script execution rights in admin PowerShell the cmdlet
Set-ExecutionPolicy Unrestricted is enough. When doing this in normal non-elevated PowerShell, you need to tell PowerShell that the rights should be granted to current user by adding the
-Scope switch with
CurrentUser parameter.
Like this:
- Execution rights when using elevated PowerShell:
Code:
Set-ExecutionPolicy Unrestricted
- Execution rights when using non-elevated PowerShell:
Code:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Should I set the Execution Policy before I enter Get-Command -Module OneGet or afterwards?
-
Should I set the Execution Policy before I enter Get-Command -Module OneGet or afterwards?
The tutorial was written almost a year before Windows 10 was released, in October 2014. Quite a lot have been changed, I realize I have to edit the tutorial and bring it up-to-date.
Everything still works as told in tutorial, but there are some minor changes. One of these changes is the change of the module name: OneGet commands are now listed in module PackageManagement.
Use Get-Command -Module PackageManagement to get list of OneGet commands.