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

7

u/markekraus Community Blogger Jun 16 '17

Why is this should be five lines?

You think that is complicated.... you should watch all the underlying API calls to make that happen. You are already getting a very abstract view of a very concrete process.

It's "complicated" because it is flexible. It has more use-cases in mind than your particular use-case and supports more features than you likely care to use.

Can't it be simple? For example:

Absolutely! If you are doing this 100's or 1000's of times with several static options and a few variable ones, you can create your own wrapper functions to make an even more abstract view.