r/PowerShell • • Jun 16 '17

Why PowerShell is so complicated?

Ok, this is how do you attache a disk to VM on Azure (according to Azure documentation).

$diskConfig = New-AzureRmDiskConfig -Location EastUS -CreateOption Empty -DiskSizeGB 128 $dataDisk = New-AzureRmDisk -ResourceGroupName myResourceGroup -DiskName myDataDisk -Disk $diskConfig $vm = Get-AzureRmVM -ResourceGroupName myResourceGroup -Name myVM $vm = Add-AzureRmVMDataDisk -VM $vm -Name myDataDisk -CreateOption Attach -ManagedDiskId $dataDisk.Id -Lun 1 Update-AzureRmVM -ResourceGroupName myResourceGroup -VM $vm

Why is this should be five lines? Can't it be simple? For example:

New-AzureRMVMDisk -VM nameofthevm -diskname nameofthedisk -type typeofthedisk etc.

I mean why PowerShell complicates things? After all it is command line tool that should make our life little bit easier.

1 Upvotes

10 comments sorted by

View all comments

18

u/GoodShitLollypop Jun 16 '17

That's not Powershell complicating anything. That's the Azure module for Powershell, and it compartmentalizes components of the command on purpose. Most people would find five 20-character lines easier to parse than one 100-character line.

2

u/hayfever76 Jun 18 '17

Well, that and PowerShell is object based so you have to create and manage all the objects that do things which is where the extra lines come from. If you take a look at the current Azure CLI, it's written in Python and takes like 5 lines to do what PowerShell needs 20 to do.