Trying to setup a new VM via PowerShell. Works fine when I copy & paste commands step by step to PowerShell ISE but, fails when I try to run them in one rush.
I have removed other parts of the script, it is also failing with only this lines:
$VM_NAME = "VMNAME"
$VM_SIZE = "Small"
$VM_IMAGE = "5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-71-20150605"
$LOCATION = "West Europe"
$STORAGE_ACCOUNT = "disktest"
$CLOUD_SERVICE = "disktest"
$SSH_USER = "azureuser"
$SSH_PASSWORD = "324w##eANC"
$VIRTUAL_NETWORK = "Playground"
$SUBNET = "P"
$BOOTSTRAP_CHEF = $FALSE
$PATH_PUBLIC_CONFIG = "publicconfig.json"
$PATH_PRIVATE_CONFIG = "privateconfig.json"
$DISK_CREATE = $TRUE
$DISK_SIZE = 500
$DISK_COUNT = 2
$DISK_LABEL = "datadisk"
$DISK_LUN = 0
$REMOVE_SSH_ENDPOINT = $FALSE
$HTTP_ENDPOINT = $FALSE
$SHUTDOWN = $FALSE
Select-AzureSubscription -SubscriptionName "SUB" -Current;
if (!(Test-AzureName -Storage $STORAGE_ACCOUNT)) {
New-AzureStorageAccount -StorageAccountName $STORAGE_ACCOUNT -Location $LOCATION
}
if (!(Test-AzureName -Service $CLOUD_SERVICE)) {
New-AzureService -ServiceName $CLOUD_SERVICE -Location $LOCATION
}
Set-AzureSubscription -SubscriptionName "SUB" -CurrentStorageAccountName $STORAGE_ACCOUNT
$existing = Get-AzureVM -ServiceName $CLOUD_SERVICE -Name $VM_NAME
Error message:
In Zeile:36 Zeichen:1
+ $existing = Get-AzureVM -ServiceName $CLOUD_SERVICE -Name $VM_NAME
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ausführbarer Skriptcode wurde im Signaturblock gefunden.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TokenAfterEndOfValidScriptText
If i first set the variables, remove them from script window, and run again it works like a charm.
Issue is "Solved" - after some hours talking to Microsoft: It is a bug in PowerShell 3.0 in combination with Windows 7!
To solve this, install PowerShell 4.0, Re-Install Azure PowerShell and reboot the workstation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.