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.
Related
I'm currently trying to remote to multiple servers that are on PowerShell 4.0 whereas the local computer currently runs on 5.0+. I am attempting to query servers that are Server 2016 for the Local Administrator group, but will fail for servers that are on 2012. Which upon researching the error messages for cmdlets from Microsoft.Powershell.LocalAccounts indicates that the modules don't exist for 2012.
Rather than updating the PowerShell version, or installing the modules to each server, I wondering if it's possible to execute cmdlets from the local 2016 into remote sessions of the 2012 servers.
Technically, yes, you could copy modules from the local server to one of the module directories on the remote server's $env:PSModulePath and import them in the remote session, but as #mklement0 stated there is no guarantee current modules will work with PowerShell 4.0, let alone Server 2012.
That said, Microsoft.PowerShell.LocalAccounts is a module provided by PowerShell 5.1, not the OS, and the features should still work on 2012. However, I don't have a 2012 instance I can test with. But you may be able to get your task done by upgrading your servers' PowerShell version to PowerShell 5.1 (Windows Management Framework 5.1) to leverage the additional features and built-in modules this version brings. But any modules that are shipped with later Windows versions and not PowerShell itself will remain unavailable.
$localAdminUsers = net localgroup administrators
After some talking with a colleague, I realized I had overcomplicated my script, when I could have used the command prompt. From there, I parse the string for the users I was looking for.
Thank you for your responses.
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
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?
We have a need in our project to automate the process of creating AppPools and Websites in IIS . We would like to write some batch script to get this done. From my research I found that PowerShell has commands that can be used. However when I tried to run IIS module commands in PowerShell on Windows Server 2012 , it does not recognize the commands. Is it correct that this feature was only available for Windows 7 / IIS 7 ? Is it also available now on Windows 2012 R2 / IIS 8. If so where can I find proper documentation and help ?
This feature is of course available in Windows 8/8.1 and Windows Server 2012/2012 R2.
You probably forgot to run Add-PSSnapin WebAdministration before executing other IIS cmdlets.
You can find the full documentation on the Microsoft Technet.
If you run Windows 8.1 or Windows Server 2012 R2 (i.e. you have Windows PowerShell 4.0) you can also use the new PowerShell Desired State Configuration feature with the xWebAdministration Module to create WebAppPools and Websites.
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?