i want to create New vm's from muliple template's like windows 8,7 and more like that, also want to choose how many i need of that vm.
the full code is here:
link to pastebin
but the thing is i want to do multiple templates at once how can i do that?
i was thinking about an foreach($template in $template){do that}
then im doing template1,template2 but its giving me the error that its just template1,template2 instead of 2 diffrent templates dont know how to seperate that. i thought about the , but i dont know then.
This is not possible, you have to specify one (and only one) template to create a new from template.
You can verify that by running the following command :
Get-Help New-VM -Parameter Template
-Template <Template>
Specifies the virtual machine template you want to use for the creation of the new virtual machine. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.
Required? true
Position? 2
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true
As you can see , this -Template parameter takes only one object of the type [Template].
If it were able to take several, we would see :
-Template <Template[]>
But it is the same in the GUI anyway : in the vSphere client you have to choose only one template to create a VM from it.
Related
I am currently writing a Powershell script to create teams in Microsoft Teams.
Is there a way to use a template when creating a team in Powershell?
Thanks in advance.
Yes, it is possible, but not with the MicrosoftTeamsPowerShell module's New-Team. As per the docs, the -Template parameter is for Education customers:
If you have an EDU license, you can use this parameter to specify which template you'd like to use for creating your group. Do not use this parameter when converting an existing group.
Valid values are: "EDU_Class" or "EDU_PLC"
Instead, you can do this using Microsoft Graph, in particular the Create Team operation. One of the examples listed in the docs describes how to use the AdditionalProperties to specify a template, and once you know it's possible in Graph in concept, it's simply a case of finding the matching operation in the Microsoft Graph PowerShell module, in this case New-MgTeam (more info here).
For some final code, you can use the following:
Connect-MgGraph -Scopes "Team.Create"
$additionalProperties = #{
"template#odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('com.microsoft.teams.template.ManageAProject')"
}
New-MgTeam -DisplayName "SOTest" -AdditionalProperties $additionalProperties
This example using the Project Team template - here is a list of the out of box templates. For your custom templates, you can create them in the admin centre or via PowerShell, and you can read more about them here. To actually use a custom template, you use it's Guid in the form of:
$additionalProperties = #{
"template#odata.bind" = "https://graph.microsoft.com/v1.0/teamsTemplates('[your guid here]')"
}
Just a final note to be aware of - the PowerShell command executes quite quickly, and it creates the initial team pretty fast too, but it takes a few minutes to apply the template thereafter (e.g. creating the channels etc.) - give it 5 - 10 minutes and it should be fine.
I was trying this scenario but I am not able to figure out
I have a name and value in parameter store in SSM, now I am running the CF template from CLI using code pipeline, and I want the CF template take values directly from parameter store and should not prompt
on screen asking me to give the value.
I tried this but it prompt me .
AWS::SSM::Parameter::value
this is prompting when I used to upload a template in screen. how to avoid it and make the script take the value from parameter store directly
You have two choices for that:
Provide a default value for the parameter.
Use ParameterOverrides in your CodePiepline to provide the required value for the parameter.
I have lots of URL values and their keys. But there is no way to batch import the variables and the "value" controls are also not text boxes in the Variables Group page to perform chrome browser extensions assisted find and replace.
If this is possible, what is the syntax to refer to the key?
As in, I have a variable App.URL : www.contoso.com.
I am using the key to substitute value in my next variable like this Login.URL : $(App.URL)\Login and this doesn't work.
GitHub link : https://github.com/MicrosoftDocs/vsts-docs/issues/3902#issuecomment-489694654
This isn't currently available, not sure if it will be. Can you create a task early in your pipeline that sets the variables you need in subsequent tasks/steps? This gives you more control as you can store the script along with your source. You could then use a pipeline variable for the environment you're in and let your script use that to set values appropriately.
See Set variables in scripts in the MS docs.
If it's not possible to re-architect your app to concatenate the url strings in the application, what the previous commenter said about creating a simple script to do that for you would be the way to go. Ie:
#!/bin/bash
#full login url
fullLoginUrl=$APP.URL\$LOGINSUFFIX
echo "##vso[task.setvariable variable=Login.URL]$fullLoginUrl
Otherwise, perhaps playing around with the run time vs compile time variables in YAML pipelines might be worth trying.
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#understand-variable-syntax
I want to create CloudWatch alarms automatically on instance launch (via AutoScaling, CLI or whatever).
My instances are running Windows, so I created task in Task Scheduler which executes PowerShell script.
This script uses Write-CWMetricAlarm cmdlet to create CloudWatch Alarms - http://prntscr.com/e6xptj
It works good for custom Metrics like Windows/Default , but for AWS/EC2 InstanceName is required as well - http://prntscr.com/e6xq18
But there's no Dimension for InstanceName - http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ec2-metricscollected.html
.. as well as no suitable parameter for Write-CWMetricAlarm Cmdlet - http://docs.aws.amazon.com/powershell/latest/reference/Index.html
So any ideas about how this issue can be solved?
Thanks in advance!
Instance names are actually just tags (with key "Name") and the console gives them special treatment to make them appear as a first-class item. They also do not need to be unique, so using 'name' wouldn't enable CloudWatch to distinguish between different instances, making things confusing from an alarm perspective.
I think therefore that you need to be using the instance id value. In your script I notice you're using Invoke-Restmethod to obtain it - you might be interested to know you can also get this value using a cmdlet:
Get-EC2InstanceMetadata -Category InstanceId
I have spent a couple of hours search for a solution to disable my Azure Service Bus Topics using Powershell.
The background for this is we want to force a manual failover to our other region.
Obviously I could click in the Portal:
but I want to have a script to do this.
Here is my current attempt:
Any help would be great.
Assuming you're sure your $topic contains the full description, modify the status parameter in the array and then splat it back using the UpdateTopic method. I'm afraid I can't test this at present.
$topic.Status = "Disabled"
$topicdesc = $NamespaceManager.UpdateTopic($topic)
I don't think you'll need to set the entity type for the Status, nor do you require semi-colons after each line of code in your loop.
References
PowerShell Service Bus creation sample script (which this appears to be based off): https://blogs.msdn.microsoft.com/paolos/2014/12/02/how-to-create-service-bus-queues-topics-and-subscriptions-using-a-powershell-script/
UpdateTopic method: https://msdn.microsoft.com/en-us/library/azure/microsoft.servicebus.namespacemanager.updatetopic.aspx
Additional note: please don't screenshot the code - paste it in. I'd rather copy-and-paste than type things out.