[PS] PSDrive name length limit?

Discussion in 'Scripting' started by Alex K. Angelopoulos [MVP], May 14, 2006.

  1. Is there a maximum possible length for the name of a PSDrive when creating a
    drive from script? I did some experimenting and noticed that we don't hit a
    hard PS-based limit when using New-Drive interactively - I slammed into a
    problem with console buffer limits, but that's not a PS issue. I'm guessing
    that there's no hard-wired restriction. Is that true?
     
    Alex K. Angelopoulos [MVP], May 14, 2006
    #1
    1. Advertisements

  2. If there is a limitation, i don't think we'll hit it in real use...

    new-psdrive ('a'*1m) filesystem c:\
    (get-psdrive aaaa*).name.length
    1048576
     
    Jouko Kynsijärvi, May 14, 2006
    #2
    1. Advertisements

  3. It looks like it depends on available memory. Notice that 12m works in one
    case, then doesn't later - after my PowerShell session got up to about 460
    MiB. :)


    PS> new-psdrive ('a'*12m) filesystem c:\

    Name Provider Root
    CurrentLocation
    ---- -------- ---- ---------------
    aaaaaaa... FileSystem C:\

    PS> new-psdrive ('a'*13m) filesystem c:\
    New-PSDrive : Exception of type 'System.OutOfMemoryException' was thrown.
    At line:1 char:12
    + new-psdrive <<<< ('a'*13m) filesystem c:\
    PS> new-psdrive ('b'*12m) filesystem c:\temp
    New-PSDrive : Exception of type 'System.OutOfMemoryException' was thrown.
    At line:1 char:12
    + new-psdrive <<<< ('b'*12m) filesystem c:\temp
     
    Alex K. Angelopoulos [MVP], May 14, 2006
    #3
  4. nice test !

    13M seems to by my limit (2 GIG memory),
    but I'm only on a commit Charge of 658 / 3938M
    after the command but it seems to peek high when running

    and making the same drive twice does hand the session for a long time
    and pagefile usage does go up and down by 100 - 200 M.

    can you try this on you system if you can reproduce this effect ?

    MowPS>new-psdrive ('a'*10m) filesystem c:\

    Name Provider Root
    ---- -------- ----
    aaaaaaa... FileSystem C:\


    MowPS>new-psdrive ('a'*10m) filesystem c:\

    Now shell hangs.


    gr /\/\o\/\/


    MowPS>new-psdrive ('a'*13m) filesystem c:\

    Name Provider Root
    CurrentLocation
    ---- -------- ----
    ---------------
    aaaaaaa... FileSystem C:\


    MowPS>[gc]::collect()
    MowPS>[gc]::collect()
    MowPS>new-psdrive ('a'*14m) filesystem c:\
    New-PSDrive : Exception of type 'System.OutOfMemoryException' was thrown.
    At line:1 char:12
    + new-psdrive <<<< ('a'*14m) filesystem c:\
     
    /\\/\\o\\/\\/, May 14, 2006
    #4
  5. <big snip>
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' already exists for the
    provider 'Microsoft.PowerShell.Core\FileSystem'.
    At line:1 char:12
    + new-psdrive <<<< ('a'*10m) filesystem c:\

    took 1/2 hour but here we are...
    no crash.

    this is one of the occasions I would like a more PowerFull Crtl-C
    (ctrl-break will close shell)

    gr /\/\o\/\/

     
    /\\/\\o\\/\\/, May 14, 2006
    #5
  6. Within a couple of seconds I get this error (and memory used jumps from ca.
    27MiB to 130 MiB):
    PS> new-psdrive ('a'*10m) filesystem c:\
    New-PSDrive : Exception of type 'System.OutOfMemoryException' was
    thrown.
    At line:1 char:12
    + new-psdrive <<<< ('a'*10m) filesystem c:\
    PS>

    Note that I get this REPEATEDLY - and then:
    I do Get-PSDrive, followed by the same step - and it WORKS:
    PS> new-psdrive ('a'*10m) filesystem c:\

    Name Provider Root
    CurrentLocation
    ---- -------- ---- ---------------
    aaaaaaa... FileSystem C:\

    I have no clue what's happening here. :)
     
    Alex K. Angelopoulos [MVP], May 14, 2006
    #6
  7. Did you ever manually NGEN your install? Just curious about whether you were
    'optimized' when you did this.
     
    Alex K. Angelopoulos [MVP], May 14, 2006
    #7
  8. If you think allocating 10 a megabyte drive name takes awhile, wait until
    you type it :)

    --
    Lee Holmes [MSFT]
    Windows PowerShell Development
    Microsoft Corporation
    This posting is provided "AS IS" with no warranties, and confers no rights.


     
    Lee Holmes [MSFT], May 15, 2006
    #8
  9. That's ok. Given the command tail length limits on console windows, I would
    suggest that best practice be names under 7900 characters anyway. :)

     
    Alex K. Angelopoulos [MVP], May 16, 2006
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.