# Extend LUN automatically

**URL:** <https://forums.powershell.org/t/extend-lun-automatically/1104>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/extend-lun-automatically/1104 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/extend-lun-automatically/1104/1 "2011-12-31T18:30:00Z")

</div>

by kristianc at 2013-03-06 01:16:01

> Hi  
> I am an server administrator and we have a bunch of servers with multiple LUN attached. We can’t forecast our customers disk usage and therefore I get a lot of extra space for differents LUN every week.  
> Normally I have to use diskpart to select the disk, then list volumes and select the volume and the do the extend, for each disk.  
> I know disk operations will be a lot easy’er in Powershell v3 and Server 2012, but my environment is Windows 2008 and Windows 2008 R2.  
> I want to do a script that can run through every disk on a server and see if there is any space to extend. if there is, then it should extend.  
> Diskpart can be used through Powershell I know, but I can’t get my head around how to find the disk and volume number for a volume where there is space to extend to.  
> Anyone who can help me?  
>   
> Regards  
> Kristian

by DonJ at 2013-03-06 03:45:15

> So… terminology-wise, let me make sure I’m on the same page. You want to look for space on a physical device that has not yet been allocated to a logical volume?  
>   
> (You’re right in that it’s easier in 2012; part of what you get by buying that upgrade is the easier manageability)

by kristianc at 2013-03-06 04:36:02

> Hi Don.  
>   
> I think is it Yes to your question. Yes I want to run through all the physical disks attached to a server (SAN LUN’s) and look for unallocated space for each volume. Then extend that volume with the unallocted space.  
>   
> As it is right now I run this command in Diskpart:  
> Rescan  
> Select Disk Y  
> Select Vol x  
> Extend  
> For each volume with unallocated space  
> Then the next disk and volume where new space is allocated.  
> It is that operation I want to automate. So each time the SAN team has allocated more space for my volumes, I can just run my script, and it extend where it is needed 🙂  
> Does it answer your question?  
>   
> Best regards   
> Kristian

by DonJ at 2013-03-06 07:32:47

> It does - but I don have an answer for you, aside from running those in a script and brute-parsing their output.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:02pm UTC](https://forums.powershell.org/t/extend-lun-automatically/1104/2 "2024-05-16T21:02:27Z")

</div>


