Automated deployment using VMware powercli - powershell

We are having build environment where we did not use any tools like Cruise control , TFS or buildforge.
We are purely depend upon Msbuild and powershell. We decided to automate the deployment process.
As we are using VMWare ESXi to meet our Virtual machine needs. We decided to use VMWare powercli to automate deployment process.
After build is over , VMware powercli will revert the snapshot of VM to fresh state and we tried using Invoke-VMScript to do automated deployment.
But as our deployment has UI , this is nearly impossible as Powercli try to invoke UI in session 0 and it doesn't support UI application.
Does any body overcome this problem and installed your application successfully in Virtual machine?

I have some experience in the area. I use PowerCLI and Windows Remote to get the job done. I have a machine with VMWare snapshot where windows remoting is activated and configured and then I use PowerCLI to revert to snapshot and power the machine on and then I call Invoke-Command. Not sure if it will survive the UI thing, but worth a try. First make sure that you can execute your task from PowerShell and if yes - then windows remouting will most probably be able to do it as well. You can read how to configure Windows Remouting here:
http://amarchuk.blogspot.com/2011/10/windows-remoting-and-powershell.html

Related

How to automate the configuration process of Windows Server 2016?

I need to setup and configure some Windows Server 2016 VMs. The tasks include:
Execute c:\windows\system32\sysprep\sysprep\sysprep.exe
Configure the administrator password
Rename the guest VM
Set fixed IP address
Add it into a domain
Install some software in the VMs
Right now I have to do all the steps manually which is boring and error-prone. I can use PowerShell to automate some steps but some tasks require a reboot of the OS so I don't know whether it it possible to automate the whole process. Can someone point me in the right direction? I've heard of some configuration management tools like Ansible or Chef etc, but I don't have experience in those. Can they solve my problem?

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

Best practice for uninstalling software with PowerShell

Like a lot of other applications out there the BlueJeans Desktop App MSI comes in two flavours: Per User MSI & Per Machine MSI.
Today, it is possible to have both installed on the same machine, but I have an increasing number of customers who have users with both installed and want to be able to clean it up. I have put together a cleanup script that handles uninstalling our application, but what I need to know from the community is whether I should utilize PowerShell to connect to each machine and run the script remotely or deploy the script via SCCM, IBM BigFix etc. to each machine and run the script locally?
A copy of my script can be found here: https://github.com/stuartminch/powershell/blob/master/cleanup_utility.ps1
If you have two separate MSI installers (User MSI & Per Machine MSI) the easiest way would be to use MSI {GUID} to uninstall them.
example msiexec.exe /x {GUID} /q
If you have them installed on a machine you can find uninstall string with GUID under
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{GUID}\UninstallString
You can then configure it in SCCM.
Best practice would be to configure the deployment along with uninstall so if you deployed it through SCCM just add Uninstall commands there.

FailoverClusters module is not getting listed while running the cmdlet Get-Module -ListAvailable

I tried below command
Get-Module -ListAvailable
But it did not showed me "FailoverClusters" in the list
From where I can download this module? Do I have to install any SDK?
Note: I do not want to install Azure SDK. Is there any other way?
Update
I am using my local windows 10 to remote connect to the Azure Virtual Machine (Windows Server 2012 R2). I do want to manage all configurations using powershell from my local windows 10 machine.
As jisaak already explained, the FailoverClusters module is installed when you install the Failover Clustering feature on a Windows Server.
If, however, you want to manage a cluster from a computer without the Failover Clustering feature installed, this is what you do:
Download the appropriate version of Remote Server Administration Tools
Run the installer
Navigate to the Programs and Features control panel pane (run appwiz.cpl)
Choose "Turn Windows Features on or off"
Find the "Failover Cluster Management" feature under Remote Server Administration Tools
Enable it
Voila
The FailoverClusters Windows PowerShell module is installed on the
computer with the Failover Clustering feature
Source
Install the Failover Clustering Feature

how to install operating system on a virtual machine programatically

It may be a duplicate question but i could not find it anywhere.
Anyway, my goal to install operating system(both linux and windows) programatically on a virtual machine running on vmware hosts.
Although my search, I am quite lost about where to start.
Is there a framework or project you can suggest?
You could use templates; i.e. create a VM, install the Linux distribution of your choice and make the VM a template. Then don't create VMs but deploy the template.
Alternatively, google for the Linux distribution of your choice and something like "network installation". You'll need a DHCP server and probably a TFTP and/or web server.
Working with Templates and Clones
Creating VMware Virtual Machine Templates
Try having a look at Vagrant: http://www.vagrantup.com/. It allows you to install/uninstall a predefined VM from the command line.