• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

Is there any limit to the length of a .PS1 file

I want to run some very lengthy Powershell scripts as part of migrating email boxes from Exchange 2003 to 2010. Is there an upper limit to the number of lines a .ps1 file can contain?
0
dreadman2k
Asked:
dreadman2k
  • 2
2 Solutions
 
MegaNuk3Commented:
Not that I am aware of. Are you experiencing any issues with lengthy scripts?

There might be a 16384 line limit, but I haven't confirmed that or seen any powershell scripts that long...
0
 
dreadman2kAuthor Commented:
No issues as yet. There will be scripts of several thound lines as part of the migration & I am trying to anticipate any issues before we get there.
0
 
GusGallowsCommented:
I am not sure if there is a limit, but I am running scripts over 3000 lines long with no ill side effects. As the scripts are read in sequentially, I wouldn't imagine there was a physical limit. Where you may run into issues is with variable that persist throughout the script. If you have a lot of them, and if they are large like a large array, it can eat at your memory. But again, I have not hit a limit yet.
0
 
dreadman2kAuthor Commented:
Thanks for that, GusGallows.

Knowing that 3000 lines works, I can break my scripts to around that. I have no variables at all - I'm just going to use excell to generate move commands for 6000 mailboxes and some tidyup jobs. That gives me enough info to tick this possible issue off.
Thanks to both of you
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now