Can I install WIndows Management Framework 3 on WS 2008 r2 using PowerShell - powershell

Can I use PowerShell to script an install of this? I already use module PSWindowsUpdate and would like to install KB2506143-x86 but it is not available as an update in get-WUInstall -KBArticleID. Need to run this on hundreds of machines and would like to avoid manually updating each from a browser.
Many thanks,

I think this is not possible due to
Close all Windows PowerShell windows.
paragraph in install instructions.

Microsoft makes a supported product to correctly deal with your problem, why are you trying to solve it with a homebrewed script?

Related

Packer - Windows Server 2012R2 - Install PowerShell 5

I'm having trouble with installing PowerShell 5 on Windows Server 2012 R2 using Packer.
To install PowerShell 5.1, I'm using chocolatey
powershell
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
choco install PowerShell -y
I need to to do this for two packer builder:
Amazon Web Services EC2 AMI.
Hyper-V Vagrant.
With the Amazon Web Services EC2 AMI I've tried executing the above from the following locations
As part of the user_data_file script.
As an inline provision script.
I've added the windows-restart provision in the flow after the execution of the fragment.
Similarly I've tried the same with the Hyper-V Vagrant both as part of the Autounattend flow and as an inline provision.
In both cases the installation fails because the user profile is not created. At least I think that is the problem. As a reference, I've faced the exact same problem when installing sql server express.
Has anyone managed to accomplish this flow and what is your recommendation?
PowerShell package uses MSU (Windows Update file). There are a couple of considerations here:
Ensure Windows Updates Service is turned on. Chocolatey doesn't do that yet, although there is an issue filed.
MSUs must be run locally from the machine. So if you are running over WinRM, you instead need to have it set up a scheduled task to call choco install and then run it that way.
Yes, that second point is accurate. No, it is not Chocolatey's fault. That's a Microsoft design decision with MSU files. It's a real PITA.
FYI - BoxStarter handles it appropriately, and it can be used with Packer. You will find less pain if you look there.
HTH

Is there a Chocolatey Alternative for using with Windows XP

I would like to use Chocolatey with some Windows XP VMs. Unfortunately, Chocolatey requirements tell that we need at least Windows 7. (https://chocolatey.org/install#requirements)
I would like to know if there is an alternative solution which could work on Windows XP ?
You can try:
Npackd
Zeroinstall
Ninite
JustInstall
Chocolatey IMO has no real alternative at the moment.

How to change the culture of system in Windows Server 2008 R2?

I have tried using Set-Culture, but I found that this module is not available in powershell. I have have tried upgrading powershell, but this module is still not available.
Can anyone help me find another solution without using Set-Culture?

Manage web farms from powershell v3.0

I have been searching for a way to create new web farms add add servers to it with PowerShell.
I stumbled on this link http://www.iis.net/learn/web-hosting/microsoft-web-farm-framework-20-for-iis-7/web-farm-framework-20-for-iis-cmdlets-for-windows-powershell which says that you should add a snapin called WebFarmSnapin.
But this does not seem to work at all in powershell v3.0 because it only says:
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 3.
Does anyone know how to manage web farms in PowerShell v3.0?
At last I found a way to do this!
http://brentdacodemonkey.wordpress.com/2014/02/12/automating-arr-configuration/
You can generate a script from the Configuration Editor in IIS Manager. But the funny thing is that on my Windows 7 machine I could not generate PowerShell scripts. I had to do it directly on the 2012 server.

How can I change features in Windows Vista programatically?

I'm looking for a way to programatically change features ("Programs and Features" -> "Turn Windows Features on or off") in Windows Vista (and newer Redmond OS, e.g. Server 2008).
Ideal solution would be in the form of a Powershell script (Get-Features, Set-Features), however any pointers to MSDN/other documentation would be very welcome! (my initial quick Google/StackOverflow search came up empty).
Having an automatic way to turn features on or off would allow me to automate computer setup for different scenarios. For example, to develop ASP.NET applications using IIS a bunch of IIS features need to be installed that are not installed by default. My current process of "make sure at least the features shown in this screenshot are checked" leaves a lot to be desired.
I just found an extension that works for Windows 7. "PowerShell module to Add/Remove Windows 7 features" - https://psclientmanager.codeplex.com/
in windows server 2008, there is the ServerManagerCmd command. This can install IIS with or without the subfeatures you want. You can also install/uninstall most of the major Windows features.
You can setup your server the way you want then run ServerManagerCmd -query template.xml. This exports the configuration to an Xml file.
You need to transform the file to prepare it for use on other servers
Copy the transformed file to the server you want to configure and run ServerManagerCmd -inputPath transformTemplate.xml
The way to do this in Vista and Windows 2008 is with the PKGMGR command line tool. Search MSDN for this tool to find a list of features/packages.
It looks live Powershell V2 on Server 2008 R2 (Beta) has a module that does exactly this. Let's hope Windows 7 will have this functionality as well...
For more details, see Managing Server Features with PowerShell Cmdlets on Windows 2008 Server R2 Beta
There's unfortunately not a set of cmdlets, yet, nor is there anything in WMI or any other easily-accessible area. Interestingly, Server Core's script-based role management features will only work on Server Core :). Windows 7 may bring some relief in this regard - but it also might not. In the meantime, you're pretty much left with the native Win32 APIs mentioned in the other answer.
As an aside, I should point out that MS deliberately doesn't want applications installing major OS features due to the security considerations. Adding IIS isn't something done lightly, and it brings with it security considerations and responsibilities. Witness MS' own application setups, which check for pre-reqs like that, but do not offer to install them for you. While I understand wanting to make your app setup as painless as possible, there's also damage to be done in putting major functionality into the OS under someone's nose :). I personally would prefer that apps err on the side of caution, tell me what they need, and let me make the decisions about how and what to install things - especially major functionality that will open ports and be able to execute arbitrary code, like IIS.