New-AzureQuickVM not creating VM on exsisting Cloud Service? - powershell

I'm trying to run the following Azure Powershell cmdlet to provision a new Virtual Machine on a existing Cloud Service.
PS C:\> Get-AzureService | ft ServiceName
ServiceName
-----------
$AZURETEST-EUWEST0
$AZURETEST-JPWEST0
$AZURETEST-USEAST0
$AZURETEST-USWEST0
PS C:\> $image = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201505.01-en.us-127GB.vhd"
PS C:\> New-AzureQuickVM -Windows -ServiceName "$AZURETEST-USEAST0" -name "AZURESVM-USE1" -ImageName $image -Password Password1 -AdminUsername admin -WaitForBoot
New-AzureQuickVM : ResourceNotFound: The deployment name '$AZURETEST-USEAST0' does not exist.
At line:1 char:1
+ New-AzureQuickVM -Windows -ServiceName "$AZURETEST-USEAST0" -name "AZURESVM-USE1" -Im ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureQuickVM], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewQuickVM
New-AzureQuickVM : Sequence contains no matching element
At line:1 char:1
+ New-AzureQuickVM -Windows -ServiceName "$AZURETEST-USEAST0" -name "AZURESVM-USE1" -Im ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureQuickVM], InvalidOperationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.PersistentVMs.NewQuickVM
PS C:\>
What doesn't make sense is I'm getting an error that says my Cloud Service - or Deployment Name doesn't exist when you can clearly see it returned when I listed all the available Cloud Services!

First of all, admin as administrator account name will not work. It's a reserved word, once you get past the service name, it will break on this one.
Second, there's nothing wrong with your powershell command and I tested exactly with the same parameters to make sure. I can bet it's the "$" you used for the cloud service name that is being misinterpreted by the cmdlet.
Since you can't rename cloud services, create a new one without the "$" and try again to see if it works.
Update: This is what happens when i try to create CS from the portal with the "$" as first character:
"This field can contain only letters, numbers, and hyphens. The first
and last character in the field must be a letter or number.
Trademarks, reserved words, and offensive words are not allowed."

Try to enter all parameters inline without using named parameters (e.g $image). that solved it for me.
Here is a working example:
$image = "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-20160229-en.us-127GB.vhd"
$location = 'West Europe'
New-AzureQuickVM -Windows -Location $location -ServiceName "RamiSOTest1-cs" -name "RamiSOTest1-VM" -ImageName $image -Password 'RamiPass-1' -AdminUsername 'rami' -WaitForBoot

Related

Restart network PC's services using PowerShell [duplicate]

This question already has answers here:
Stopping & Restarting Services Remotely Using Set-Service
(3 answers)
Closed 3 years ago.
I need to restart services of a LAN Computer using IP Address. I have this researched:
Restart-Service -ComputerName \\10.10.11.16 -ServiceName IETCQRService dnsCache
and this is the error I get:
Restart-Service : A parameter cannot be found that matches parameter name
'ComputerName'.
At line:1 char:17
+ Restart-Service -ComputerName \\10.10.11.16 -ServiceName IETCQRServic ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Restart-Service], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RestartServiceCommand
I need to use the IP Address because the computer names are the same, they just differ on the IP Address.
EDIT
I have used the suggestion but I get this error now:
PS C:\WINDOWS\system32> Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart-Service
Get-Service : Cannot find any service with service name 'IETCQRService'.
At line:1 char:1
+ Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (IETCQRService:String) [Get-Service], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
So far as I know, there is no -ComputerName parameter on the Restart-Service command. Instead, you could use something like this:
Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart-Service
You could use both the IP address or the computer name in the Get-Service command
Note As pointed out in the comments, this option isn't viable going forward as it is being removed from PowerShell version 6+.

PowerCli Command

I am trying to use a PowerCli commandlet to create a new virtual machine
New-VM -ResourcePool vfcplvmh0009 -Version v11 -Name TestServer22 -Datastore 0031_A_Normal001 -DiskGB 100 -DiskStorageFormat EagerZeroedThick -MemoryGB 4 -NumCpu 2 -CoresPerSocket 2 -Template Win2012-STDR2_GoldenImage -Confirm $false
However it will not run and displays the following error message
New-VM : Parameter set cannot be resolved using the specified named
parameters. At line:1 char:1
+ New-VM -ResourcePool vfcplvmh0009 -Version v11 -Name TestServer22 -Da ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VM], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM
I am unsure as to why this error message is being generated as all the parameters and data for them appear to be correct.
Looks like you have a syntax error. The correct format for -Confirm in PowerCLI should be:
-Confirm:$false
This is a common mistake when using the -Confirm parameter.
Also, you cannot use the template parameter because it is a part of a different parameter set.
If you remove the -Template parameter, then you should be able to create the VM.
In VMWare, the template will already have the CPU, RAM, and HDisk information to describe the vmdk file. You have to use one or the either. Can't use both.
The correct code should be like this:
New-VM -ResourcePool vfcplvmh0009 -Version v11 -Name TestServer22 -Datastore 0031_A_Normal001 -DiskGB 100 -DiskStorageFormat EagerZeroedThick -MemoryGB 4 -NumCpu 2 -CoresPerSocket 2 -Template Win2012-STDR2_GoldenImage -Confirm:$false
You can read more about Users Requesting Confirmation here

Azure powershell: Account with name '​' does not exist

I am working with classic resources in Azure. I am running Azure powershell version 2.0.1 (updated it to see if that solved the issue below).
I was wanting to check my list of VIPS, and am running some script I had for this in powershell.
$deployment = Get-AzureDeployment -ServiceName servicenamehere
$deployment.VirtualIPs
I am now getting the error
Get-AzureDeployment : Account with name '​' does not exist.
Parameter name: accountName
At line:1 char:15
+ $deployment = Get-AzureDeployment -ServiceName servicenamehere
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureDeployment], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand
A variety of other statements return with the same error "Account with name '' does not exist." This was all executed after logging in and selecting my subscription, which works fine:
Add-AzureAccount
Select-AzureSubscription -SubscriptionName "subscriptionnamehere"​
Any ideas on what is occurring on the statements that makes them fail with this accountName issue? Unsure if this has to do with resource manager changes or anything else new added in the last few months in Azure.
Other statements fail with the same error. Example
Add-AzureVirtualIP -VirtualIPName newvipname -ServiceName servicenamehere
Gives the same error
Add-AzureVirtualIP : Account with name '​' does not exist.
Parameter name: accountName
You need to add the qouteation mark when adding a string.
Select-AzureSubscription -SubscriptionName "subnamame" -Account "acname"
This is typically required, especially when you have more then 1 parameter.

Azure Powershell - Switch-AzureMode error in version 1

Hello I am not powershell programmer and I learning right now using pluralsight and exericese file giving me error and I think it happening because or version change of Azure Powershell from 0.9.8 to version 1.0
Here is error :
c:\Pluralsight\chef\2-chef> .\Create-CourseEnvironmentARM.ps1
Switch-AzureMode : The term 'Switch-AzureMode' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At C:\Pluralsight\chef\2-chef\Create-CourseEnvironmentARM.ps1:28 char:1
+ Switch-AzureMode AzureResourceManager -Verbose
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Switch-AzureMode:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Test-AzureResourceGroup : The term 'Test-AzureResourceGroup' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Pluralsight\chef\2-chef\Create-CourseEnvironmentARM.ps1:32 char:5
+ if((Test-AzureResourceGroup -ResourceGroupName $GroupName) -eq $false){
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Test-AzureResourceGroup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
New-AzureResourceGroupDeployment : The term 'New-AzureResourceGroupDeployment' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Pluralsight\chef\2-chef\Create-CourseEnvironmentARM.ps1:44 char:1
+ New-AzureResourceGroupDeployment `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-AzureResourceGroupDeployment:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
File Name :.\Create-CourseEnvironmentARM.ps1
I was searching error in google and confirm that azure power shell
deprecate function "Switch-AzureMode AzureResourceManager -Verbose"
https://github.com/Azure/azure-powershell/wiki/Deprecation-of-Switch-AzureMode-in-Azure-PowerShell
Switch-AzureMode AzureResourceManager -Verbose
Here is code from Create-CourseEnvironmentARM.ps1
Switch-AzureMode AzureResourceManager -Verbose
### Create Resource Group ###
if((Test-AzureResourceGroup -ResourceGroupName $GroupName) -eq $false){
New-AzureResourceGroup -Name $GroupName -Location $Location -Verbose
$ResourceGroup = Get-AzureResourceGroup -Name $GroupName
}
else {$ResourceGroup = Get-AzureResourceGroup -Name $GroupName}
$parameters = #{
'newStorageAccountName'="$StorageName";
'adminUsername'="$AdminUsername";
'dnsNameForPublicIP'="$PublicDNSName"
}
New-AzureResourceGroupDeployment `
-Name $DeploymentName `
-ResourceGroupName $ResourceGroup.ResourceGroupName `
-TemplateFile azuredeploy.json `
-TemplateParameterObject $parameters `
-Verbose
Please help me to correct this code. I think author is never update course and I am in middle of course. I hope someone help me to fix this problem.
There is no more "Switch-AzureMode" since v. 1.0.0 of the Powershell.
The ARM and ASM cmdlets exists together and live together. The ASM cmdlets are with unchanged names, but the ARM cmdlets are all now with RM in their name. Like:
Add-AzureRmAccount
Both the powershell cmdlets can be installed via Web Platform Installer.
More, when on Windows 10, the ARM cmdlets can be installed via PowerShell Gallery using the ofllowing commands (under Aministrative PowerShell console):
Install-Module AzureRM
Confirm all the questions being asked. Then run the
Install-AzureRM
Then you are done with the ARM module. Just make sure that your local execution policy is at least "RemoteSigned".
At the end, you will have to edit all your PowerShell scripts to match the new cmdlets and their parameters. Like the New-AzureResourceGroup is now New-AzureRmResourceGroup: https://msdn.microsoft.com/en-us/library/mt603739.aspx

Powershell Hyper-V Scripts won't work? + Auto Installing Windows

So I have a strange problem. When I do commands such as this:
New-VM -Name "MattTest" -MemoryStartupBytes 2GB -BootDevice CD -SwitchName Lab -path c:\VMdocs -NewVHDSizeBytes 40GB –NewVHDPath c:\base.vhdx
Set-VMDvdDrive -VMName MattTest -Path C:\ISOFiles\Windows2008.
Start-VM -Name MattTest
It works fine, However if I make a script I get a TON of errors, for example the exact same thing in a script called PS.ps1 and ran through Powershell I get:
New-VM : The parameter is not valid. No switch can be found by given
criteria. At C:\Users\mrsmith\Desktop\PS.ps1:1 char:1
+ New-VM -Name "MattTest" -MemoryStartupBytes 2GB -BootDevice CD -SwitchName Lab - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Lab:String) [New-VM], VirtualizationInvalidArgumentException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.NewVMCommand
Set-VMDvdDrive : The parameter is not valid. Hyper-V was unable to
find a virtual machine with name MattTest. At
C:\Users\mrsmith\Desktop\PS.ps1:3 char:1
+ Set-VMDvdDrive -VMName MattTest -Path C:\ISOFiles\Windows2008.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MattTest:String) [Set-VMDvdDrive], VirtualizationInvalidArgumentExcept ion
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.SetVMDvdDriveCommand
Set-VMDvdDrive : The parameter is not valid. No DVD drives are found.
At C:\Users\mrsmith\Desktop\PS.ps1:3 char:1
+ Set-VMDvdDrive -VMName MattTest -Path C:\ISOFiles\Windows2008.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-VMDvdDrive], VirtualizationInvalidArgumentException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.SetVMDvdDriveCommand
Start-VM : The parameter is not valid. Hyper-V was unable to find a
virtual machine with name MattTest. At
C:\Users\mrsmith\Desktop\PS.ps1:5 char:1
+ Start-VM -Name MattTest
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MattTest:String) [Start-VM], VirtualizationInvalidArgumentException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.StartVMCommand
Im not sure what's causing this? is it something to do with the module, because I have checked and the Hyper-V cmdlet IS running (considering I can manually type these in and they will be fine)
Also sidequestion: These set of instructions will get up to the "Install Windows XXXX" Screen. Is there any way to Automate THAT process? Or not really (Like make it click next, select a hard drive, install, etc...
Just to make sure, the prompt (e.g 'PS C:\Users\mrsmith\Desktop>') is not a part of the script, right? If so remove it.
As it appears, it is a part of the script because PS is an alias for Get-Process and it tries to pass 'C:\Users\mrsmith\Desktop' as a process name.