IT Consultant Everyday Notes

Just some problems/solutions storage

Category Archives: PowerShell

Azure: Migrate an Azure VM v2 (ARM-based) between two storage accounts

One of my Customers asked me to move some VMs from expensive Premium storage account to a cheaper Standard tier.

The infrastructure was built using Resource Mode and luckily we do not need to convert VHDs to OS disks (as it is required for Classic VMs).

1. I shutdown/deprovision VM (you do not need to delete it)

2. Copy VHD OS disk and data disk to the new storage account

3. Recreate VM at the new place using the following script:

select-azurermsubscription -SubscriptionName “My Subscription”


# to check subnet index use:   Get-AzureRmVirtualNetwork -Name msps –ResourceGroupName $rgName | Select Subnets

$vnet=Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgName

$vm=New-AzureRmVMConfig -VMName $name -VMSize Standard_D4
$vm | Set-AzureRmVMOSDisk -VhdUri https://*******.vhd –Name $name -CreateOption attach -Windows -Caching ReadWrite

$vm | Add-AzureRMVMDataDisk -Name “XXXX-data” -VhdUri https://*****-data01.vhd -LUN 0 -Caching ReadWrite -CreateOption Attach -DiskSizeinGB 1023

$nicName= $name + “_nic”
$pipName= $name + “_pip”
$domName= $name
$pip=New-AzureRmPublicIpAddress -Name $pipName –ResourceGroupName $rgName-DomainNameLabel $domName -Location $locName -AllocationMethod Dynamic
$nic=New-AzureRmNetworkInterface -Name $nicName –ResourceGroupName $rgName-Location $locName -SubnetId $vnet.Subnets[$subnetIndex].Id -PublicIpAddressId $pip.Id -PrivateIpAddress $privIP
$vm=Add-AzureRmVMNetworkInterface -VM $vm  -Id $nic.Id

New-AzureRMVM -ResourceGroupName Sharepoint -Location “East US” -VM $vm –Verbose

The machine is recreated and started

here are some useful links I used:

if you have a lot of numbered disks:

Microsoft doc:

PowerShell: PowerShell ISE stopped to work

Issue: PowerShell ISE stopped to work. Pop ups the following error:

The application cannot start because it could not access the user settings file: ‘C:\Users\USERNAME\AppData\Local\Microsoft_Corporation\powershell_ise.exe_StrongName_lw2v2vm3wmtzzpebq33gybmeoxukb04w\\user.config’

Resolution: I renamed the file on the path indicated in the error and ISE recreated one on the next start


Original solution was found here

SCCM 2012: Automatic installation script(s)

Raphael, one of MVPs is developing a PowerShell script suite for SCCM installation automation.

Project is here: How-to is here:

SCCM 2012 Powershell: You must use 32-bit!

Rafael has a nice post about using PowerShell in SCCM 2012 SP1 (beta). You must actually use 32-bit PowerShell to import module!

More here

PowerShell 3: Install PowerShell Web Access

1. Install feature (here and after all commands in PowerShell console started “As Administrator”!):

Install-WindowsFeature –Name WindowsPowerShellWebAccess –ComputerName <computer_name> IncludeManagementTools –Restart


2. Enable PS remoting (if it is not enabled)

Enable-PSRemoting –force


3. Configure PSWA using:

Install-PswaWebApplication –UseTestCertificate.


4. Add Authorization rule:


5. Verify PSWA using access to /pswa">/pswa">https://<server_name>/pswa from Internet Explorer.


6. Use PSWA


detailed instruction: at Technet site