Chinaunix首页 | 论坛 | 博客
  • 博客访问: 75622
  • 博文数量: 18
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-20 17:43
个人简介

生活的本质不是索取而是奋斗

文章分类

全部博文(18)

文章存档

2017年(4)

2016年(14)

我的朋友

分类: 云计算

2016-11-24 13:46:22



以管理员运行ise
PS C:\Users\Administrator> Get-ExecutionPolicy
Restricted
PS C:\Users\Administrator> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned


1
2 使用与您的 Windows Azure 帐户关联的凭据登录


或者
Get-AzurePublishSettingsFile -Environment AzureChinaCloud  制作证书
Import-AzurePublishSettingsFile .\051717.publishsettings   导入证书
Get-AzureSubscription  查看订阅
创建存储帐户
New-AzureStorageAccount -StorageAccountName 'nan'   -Location 'China North'
执行以下命令以便设置您的订阅的当前存储帐户。
Set-AzureSubscription -SubscriptionName '[YOUR-SUBSCRIPTION-NAME]' -CurrentStorageAccount '[YOUR-STORAGE-ACCOUNT]'
记录订阅名称和存储帐户名称
Get-AzureSubscription | select SubscriptionName
Get-AzureStorageAccount | select StorageAccountName


Set-AzureSubscription -SubscriptionName "免费试用" -CurrentStorageAccountName "nan"
解决无法访问storage的问题


查看虚拟image
Get-AzureVMImage | ?{$_.Category -eq "User"} | select ImageName


$dclocation = 'China East'
$cloudSvcName = 'psvm201232'
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
$adminUserName = 'wn'
$adminPassword = 'qwer~1234'
$vmname = 'win012'
$linuxuser = 'redhat'
New-AzureQuickVM -AdminUserName $adminUserName -Windows -ServiceName $cloudSvcName -Name $vmname -ImageName $image -Password $adminPassword -Location $dclocation








1creat vm
$dclocation = 'China North'
$cloudSvcName = 'psvm2008'
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
$adminUserName = 'wn'
$adminPassword = 'qwer~1234'
$vmname = 'win012'


New-AzureQuickVM -AdminUserName $adminUserName -Windows -ServiceName $cloudSvcName -Name
 $vmname -ImageName $image -Password $adminPassword -Location $dclocation










2 新建vm设置硬盘50G,端口80
$vmname2 = 'mytestvm2'
$dclocation = 'China North'
$cloudSvcName = 'psvm2008'
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
$adminUserName = 'wn'
$adminPassword = 'qwer~1234'
$vmname = 'win012'
$vm2 = New-AzureVMConfig -Name $vmname2 -InstanceSize ExtraSmall -ImageName $image |
          Add-AzureProvisioningConfig -Windows -AdminUserName $adminUserName -Password $adminPassword |
          Add-AzureDataDisk -CreateNew -DiskSizeInGB 50 -DiskLabel 'datadisk1' -LUN 0 |
          Add-AzureEndpoint -Protocol tcp -LocalPort 80 -PublicPort 80 -Name 'lbweb' `
             -LBSetName 'lbweb' -ProbePort 80 -ProbeProtocol http -ProbePath '/' 






3 将数据磁盘和端点热添加到现有虚拟机.ps1


$dclocation = 'China North'
$cloudSvcName = 'psvm2008'
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
$adminUserName = 'wn'
$adminPassword = 'qwer~1234‘




$vmname = 'win012'
Get-AzureVM -Name $vmname -ServiceName $cloudSvcName |
    Add-AzureDataDisk -CreateNew -DiskSizeInGB 50 -DiskLabel 'datadisk1' -LUN 2 |
    Add-AzureEndpoint -Protocol tcp -LocalPort 1433 -PublicPort 2000 -Name 'sql' |
    Update-AzureVM






4将 RDP 文件保存到文件系统.ps1


$dclocation = 'China North'
$cloudSvcName = 'psvm2008'
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"
$adminUserName = 'wn'
$adminPassword = 'qwer~1234'
$vmname = 'win012'
Get-AzureVM -ServiceName $cloudSvcName -Name $vmname | Get-AzureEndpoint


 Get-AzureRemoteDesktopFile -ServiceName $cloudSvcName -Name $vmname -LocalPath d:\qq.rdp






5删除特定虚拟机及其磁盘
$vmname = 'mytestvm2' 
$vmDisks = Get-AzureDisk | Where { $_.AttachedTo.RoleName -eq $vmname }


Remove-AzureVM -ServiceName $cloudSvcName -Name $vmname


$vmDisks | foreach {
    Remove-AzureDisk -DiskName $_.DiskName -DeleteVHD
}








6 重设密码
Get-AzureVM –ServiceName "vmVm1" –Name "vmVm1" | Set-AzureVMAccessExtension –UserName "wn" –Password "1234Aking"
 |Update-AzureVM
servicename是cloud service的名字,azure vm的话一般和name是一样的,注意passowrd一定要符合匹配规则。
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201403.01-zh.cn-127GB.vhd"


新的image
$image = "55bc2b193643443bb879a78bda516fc8__Win2K8R2SP1-Datacenter-201409.01-zh.cn-127GB.vhd"




阅读(1160) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~