Custom generalized VHD is struck in activation key prompt in Azure - windows

I have hyper-v VHD uploaded to azure by following this link.
VHD image is generalized before uploading to azure. after uploading, trying to create a VM using the uploaded VHD image and VM is not completing the provision after timeout. looking at Boot Diagnosis of the VM the VM is stuck in product key entering prompt.
.
The following error is logged:
New-AzureRmVM : Long running operation failed with status 'Failed'. Additional Info:'OS Provisioning for VM 'PSTACBUI'
did not finish in the allotted time. The VM may still finish provisioning successfully. Please check provisioning
state later. Also, make sure the image has been properly prepared (generalized).
* Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
* Instructions for Linux: https://azure.microsoft.com/documentation/articles/virtual-machines-linux-capture-image/ '
ErrorCode: OSProvisioningTimedOut
ErrorMessage: OS Provisioning for VM 'PSTACBUI' did not finish in the allotted time. The VM may still finish
provisioning successfully. Please check provisioning state later. Also, make sure the image has been properly prepared
(generalized).
* Instructions for Windows: https://azure.microsoft.com/documentation/articles/virtual-machines-windows-upload-image/
* Instructions for Linux: https://azure.microsoft.com/documentation/articles/virtual-machines-linux-capture-image/
StartTime: 2/2/2018 11:04:08 PM
EndTime: 2/2/2018 11:50:59 PM
OperationID: 0a4f1ac8-9274-4fa8-b396-71c8eb690653
Status: Failed
At line:1 char:1
+ New-AzureRmVM -VM $vm -ResourceGroupName tacoud -Location $location
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand
How I can skip product activation prompt for multiple VM deployment?

This generally happens when the VHD is either not properly generalized (missing a step) or if it is turned back on prior to being uploaded to Azure.
Make sure you select each of the steps during the generalization process:
Then make sure that the VM is not turned back on again prior to uploading to Azure.
Also check this link to ensure you get all the proper pre-sysprep steps correct:
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image

Related

Docker for Windows - Install certificates using sn.exe / Strong Name utility

We have a Docker image that we use to build our Visual Studio solutions. This works great. Now we have some solutions that require a key. To install the key you use sn.exe, but Microsoft has gone through great lengths to make sure human input is needed, namely the password..
The image is based off FROM microsoft/dotnet-framework:3.5
I tried several tricks, especially from this Stack Overflow thread: Auto-entering Password In Sn.exe
The last answer is mine (Thomas Rijsewijk). At least I have a working way to install the key automatically, but somehow SendWait doesn't work in Docker, or Docker for Windows, or microsoft/dotnet-framework:3.5 docker image.
# ---------
# Import all certificates in C:\keys
# ---------
[void][System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("hello")
When I run this I get "Access Denied":
Exception calling "SendWait" with "1" argument(s): "Access is denied"
At K:\install-certificates.ps1:51 char:1
+ [System.Windows.Forms.SendKeys]::SendWait("hello")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Win32Exception
As an alternative I tried SendKeys() from WScript.Shell:
$wshell = New-Object -com wscript.shell;
Sleep 5;
$wshell.sendkeys("test");
Again, this works perfectly on my machine (Windows 10 up to date) and an up to date Windows 2016 server. But NOT inside the docker image: nothing happens, no error but it's not entering "test" either.
Lot of talks about automating powershell, but basically I don't really care HOW I install the certificate when building my docker image, I just want it installed. I install the certificate locally using
Start-Process "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -ArgumentList "-i `"D:\key.pfx`" VS_KEY_XXXXXXXX" -NoNewWindow;
At this point, it asks for a password which makes it impossible to use with docker build.
I did a whole lot of searching on Google and SO, I'm surprised to see that nobody else tried to install a key using sn.exe.
PS: Yes, I know VS_KEY_XXXXXXXX is not a valid VS_KEY. I already have a working mechanism for extracting the right VS_KEY, but that's out of scope of this question.
PPS: Yes, I know I could manually running the docker, install the certificate and manually commit and push the changes. But naturally, I want it to originate from my Dockerfile

Windows AWS EC2 Instance User Data PowerShell do not load Powershell Modules for System Account level

I have created a PowerShell script to run in the user data of an AWS Windows instance. If I manually execute the script as Administrator, it runs successfully and does work.
But when I send the script in user data (during instance creation) it throws an exception. This happens during the installation of the module from System Account
PowerShell Version on EC2 Windows 2012 R2 = v4.0
Cannot bind argument to parameter 'Path' because it is an empty string.
2017-04-10T18:24:25.004Z: Ec2HandleUserData: Message: Executing C:Windowssystem32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted . 'C:\Program Files\Amazon\Ec2ConfigService\Scripts\UserScript.ps1' from System account
2017-04-10T18:24:25.006Z: Ec2HandleUserData: Message: Executing User Data with PID: 1084
2017-04-10T18:24:34.639Z: Ec2HandleUserData: Message: ExitCode of User Data with PID: 1084 is 1
2017-04-10T18:24:34.642Z: Ec2HandleUserData: Message: The errors from user scripts: iex : Cannot bind argument to parameter 'Path' because it is an empty string.
At C: Program Files Amazon Ec2ConfigService Scripts UserScript.ps1:5 char:79
+ (new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1")
| ie ...
+
~~
+ CategoryInfo : InvalidData: (:) [Invoke-Expression], ParameterB
indingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl
lowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand
2017-04-10T18:24:34.642Z: Ec2HandleUserData: Message: The output from user scripts:
2017-04-10T18:24:34.642Z: Background plugin complete: Ec2HandleUserData
Work Around /Solution : This is more of PsGet Module issue, not EC2 issue
https://github.com/psget/psget/issues/208
At System Account level PsGet Module was setting Path InCorrectly.
As of now I have Modified PsGet.ps1 to read my custom path $env:PSModulePath, and it works with no issues.
PsGet.Ps1 Line 1615
Comment the line #Add-PathToPSModulePath -PathToAdd:$Destination -PersistEnvironment:$PersistEnvironment -Global:$Global
Added : [Environment]::SetEnvironmentVariable("PSModulePath", ";C:{DirectoryIwantModulesToBe}\Modules", "Machine")
It works , at System Account level with no Issues
Thanks Alex for help.
I would advice to use specific paths. The userdata block executes under the windows system account and as such it doesn't have a profile directory nor a temp path.
For example [System.IO.Path]::GetTempFileName() fails when executing with this user.
This is the same when code-deploy packages execute.
If you have to work often with AWS-EC2 then it's best to try to replicate the environment as much as possible locally because an EC2 takes minimum 6 minutes to launch and that can be a major slow down in your troubleshooting efforts. For this reason, I've decided to setup a vagrant box with the matching operating system and on that box I execute/test what I need. When things get tough and I'm suspicious of the System user's special characteristics, I use psexec to launch my processes. This is a good starting point How to: become the LOCAL SYSTEM account with PsExec

Windows container quickstart: Install-ContainerHost.ps1 fails with message "Image NanoServer not found after 5 minutes"

Note: This issue has already been reported on GitHub here without any solution so far.
Platform info: Hyper-V enabled Windows 2016 Server TP4 guest on ESX 6.0 with 6GB of RAM and a 80GB hard-disk.
I followed the "Deploy a Windows Container Host to a New Hyper-V Virtual Machine" quickstart but the process always fails as listed below:
PS C:\Windows\system32> powershell.exe -NoProfile c:\New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacenterCore -Hyperv
cmdlet New-ContainerHost.ps1 na posição de comando 1 do pipeline
Forneça valores para os seguintes parâmetros:
Password: ********
Before installing and using the Windows Server Technical Preview 4 with Containers virtual machine you must:
1. Review the license terms by navigating to this link: http://aka.ms/tp4/containerseula
2. Print and retain a copy of the license terms for your records.
By downloading and using the Windows Server Technical Preview 4 with Containers virtual machine you agree to such license terms. Please confirm you have accepted and agree to the license terms.
[N] No [Y] Yes [?] Ajuda (o padrão é "N"): y
Using VHD path C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks
Using external switch vmxnet3 Ethernet Adapter - Virtual Switch
The latest ServerDatacenterCore VHD is already present on this system.
ServerDatacenterCore Container OS Image (WIM) is already present on this system.
Creating VHD files for VM testcont...
VHD mount must be synchronized with other running instances of this script. Waiting for exclusive access...
Mounting ServerDatacenterCore VHD for offline processing...
Enabling Containers feature on drive F...
Enabling Hyper-V feature on drive F...
Copying Docker into ServerDatacenterCore VHD...
Copying NSSM into ServerDatacenterCore VHD...
This script uses a third party tool: NSSM. For more information, see https://nssm.cc/usage
Downloading NSSM...
Extracting NSSM from archive...
Writing default unattend.xml...
Copying Install-ContainerHost.ps1 into ServerDatacenterCore VHD...
Dismounting VHD...
Creating VM testcont...
Configuring VM testcont...
Connecting VM to switch vmxnet3 Ethernet Adapter - Virtual Switch
AVISO: A virtualização aninhada é um recurso de visualização sem suporte. Os hipervisores que não forem o hipervisor do
Hyper-V em execução em uma máquina virtual convidada provavelmente falharão. Além disso, alguns recursos do Hyper-V
são incompatíveis com a virtualização aninhada, como memória dinâmica, pontos de verificação e salvar/restaurar.
Starting VM testcont...
Waiting for VM testcont to boot...
Connected to VM testcont Heartbeat IC.
Waiting for specialization to complete (this may take a few minutes)...
Executing Install-ContainerHost.ps1 inside the VM...
Completing container install...
Querying status of Windows feature: Containers...
Feature Containers is already enabled.
Querying status of Windows feature: Hyper-V...
Feature Hyper-V is already enabled.
Waiting for Hyper-V Management...
Enabling container networking...
Creating container switch (NAT)...
Creating NAT for 172.16.0.0/24...
Installing Container OS image from D:\WindowsServerCore.wim (this may take a few minutes)...
Container base image install complete. Querying container images...
C:\Install-ContainerHost.ps1 : Image NanoServer not found after 5 minutes
At line:1 char:1
+ C:\Install-ContainerHost.ps1 -PSDirect -NATSubnetPrefix 172.16.0.0/24 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-ContainerHost.ps1
C:\New-ContainerHost.ps1 : Install-ContainerHost.ps1 failed in the VM
No linha:1 caractere:1
+ c:\New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacen ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-ContainerHost.ps1
I'm helpless. Any help would be appreciated.
I just had to get past this issue myself so I can tell you what I had to do...
The issue's with a line in Install-ContainerHost.ps1 which is a file run by New-ContainerHost.ps1
You can get that Install file from here
Inside it there's the following line that needs to be replaced to stop that error occurring:
$newBaseImages = Get-InstalledContainerImage $BaseImageName
That line can be replaced with the line below:
$newBaseImages = Get-ContainerImage
Having done that and saved it (I saved mine alongside New-ContainerHost.ps1 in C:), you can then tell the New-ContainerHost.ps1 file to make use of it by including a -ScriptPath option in the command you're running:
powershell.exe -NoProfile c:\New-ContainerHost.ps1 -VMName testcont -WindowsImage ServerDatacenterCore -Hyperv -ScriptPath C:\Install-ContainerHost.ps1
One other thing to look out for - you may need to temporarily amend your execution policy with Set-ExecutionPolicy or sign that modified ps1 file before Powershell will allow you to run it, depending on what your system's Execution Policy is currently set as.
That was it for me. Hope it helps you.

Can't setup up Windows Server Containers on Windows Server 2016 TP4

I'm trying to setup up Windows Server Containers on Windows Server 2016 TP4.
I'm following the guideline from MS, but it does not work. It always fails with the following error:
Getting Container OS image (WindowsServerCore) version 10.0.10586.0 from OneGet (this may take a few minutes)...
C:\Install-ContainerHost.ps1 : Unable to download.
In Zeile:1 Zeichen:1
+ C:\Install-ContainerHost.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-ContainerHost.ps1
I could find out that the Install-ContainerHost.ps1 script tries to download the WindowsServerCore image from here. Calling this URL manually returns "BlobNotFound".
I am not sure if this is some fault from me or they just have a problem with the server. I have tried to run the script already several times today. Yesterday it worked on another VM..
Edit: Seemed to be a problem from Micrsoft with the download server, which was fixed now.
OK this is what we did go to your ISO for TP4, and open the ISO.
Inside there's a folder for "NanoServer" in which you can find the wim File (image).
Copy this image locally, or where you prefer on the internet. Get the URL, you're going to use it to hack the Powershell script.
Run these commands in Powershell
Install-Package ContainerProvider
Verify the Package has been installed by running:
Find-ContainerImage
Notepad Open: C:\Program Files\WindowsPowerShell\Modules\ContainerProvider\0.5.2\ContainerProvider\ContainerProvider.psm1
Go to line: 508 and modify the Variable $downloadURL: (notice how I used my own url)
$downloadURL = "http://10.0.2.2:8000/NanoServer.wim"
After this: Just run
Install-ContainerImage -Name NanoServer
The image will be installed

Can't start Portal Express 7 on Windows 2003

I have a Windows 2003 SP2 Virtual Box guest in which I'm trying to install Portal Express 7.
During the installation there's a prompt that said that the Server couldn't start and I have to that manually. When I try to start it using startServer.bat I get every time this message:
ADMU3011E: Server launched but failed initialization. startServer.log,SytemOut.log(or job log in zOS) and other log files under C:\IBM\WebSphere\AppServer/profiles\default\logs\server1 should contain failure information.
ADMU7704E: Failed while trying to start the Windows Service associated with server: WebSphere_Portal;probable error executing WASService.exe: com.ibm.ws.management.tools.ProblemInWASServiceException: ADMU7711E: Unexpected exception associated with WASService.exe: exitCode = -1 during processing of server with name: WebSphere_Portal
In the logs I only found java.lang.NoClassDefFoundError:com/ibm/ffdc/impl/EmptyProvider$EmptyFfdc and several verbosegc.txt files. Have anyone succeeded in installing IBM WP 7 on Windows 2003?
PS: My problem is very similar to this DeveloperWorks post.
If you can start it manually but not through Windows Service, perhaps something got corrupted into the service definition. No problem, you may very simply remove it (WASService.exe -remove servicename in AppServer/bin directory ), and then add it again
I use a syntax like this one
wasservice -add "Cluster1_server1" -serverName "Cluster1_server1" -profilePath "D:\IBM\WebSphere\AppServer\profiles\AppSrv01" -wasHome "D:\IBM\WebSphere\AppServer" -stopArgs " -username youradmin-password yourpassword" -encodeParams
or you may also insert username and password into soap.client.props, so you don't need to change it all the times.

Resources