Unzipping files in powershell

I have files with varying names that periodically land in C:\tmp. I wont know the name of the files before they land, so I want to unzip any file with a .zip extension.
I would like to know how to unzip these files and move to C:\tmp\unzipped
Thanks in advance for the help.

check out the new 
PowerShell
5.0 cmdlets:
Manage .ZIP files with new cmdlets
Two new cmdlets, Compress-Archive and Expand-Archive, let you compress and expand ZIP files.
Compress-Archive
The Compress-Archive cmdlet creates a new archive file from specified files. An archive file allows multiple files to be packaged and optionally compressed into a single file for easier handling and storage. An archive file can be compressed by using a compression
algorithm specified in the -CompressionLevel parameter.
Compress-Archive -LiteralPath <String[]> [-DestinationPath] <String> [-Update] [-CompressionLevel <Microsoft.PowerShell.Commands.CompressionLevel>]
Compress-Archive [-Path] <String[]> [-DestinationPath] <String> [-Update] [-CompressionLevel <Microsoft.PowerShell.Commands.CompressionLevel>]
Expand-Archive
The Expand-Archive cmdlet extracts files from a specified archive file. An archive file allows multiple files to be packaged and optionally compressed into a single file for easier handling and storage.
Expand-Archive -LiteralPath <String> [-DestinationPath] <String>
Expand-Archive [-Path] <String> [-DestinationPath] <String>
Mike Crowley | MVP
My Blog --
Planet Technologies

Similar Messages

  • Unzipping files in powershell throws an error

    I am trying to write an unattended deployment script in powershell 4 on Windows Server.  I have searched the web and obtained a number of responses that recommend the following commands:
    $filelocation = dir C:\tmp\*.zip
    foreach ($file in $filelocation){
    $filename = $file.name.ToString()
    $shell_app=new-object -com shell.application
    $zip_file = $shell_app.namespace("C:\tmp\$filename")
    $destination = $shell_app.namespace("C:\tmp\unzipped test\")
    #unzip the files
    $destination.Copyhere($zip_file.items()) 
    However, when I try to run the script, I get an error message that suggests that $destination is null.  I played around a little and found that the '.namespace' method is returning "shell._comobject'.  If I add the method '.Title', I receive
    the correct folder name but not the full path. I created the full path by extending the return from '.namespace' but then receive an error that states the $zip_file does not have the 'items' method associated with it.
    As this seems to work for everyone else and I am new to Powershell, I know it must be something obvious that I am doing wrong but I just can't seem to work out what it is.  All help is greatly appreciated.

    Hi,
    Shell.Application doesn't usually play well with being scheduled. Since you're using v4, you can use the ZipFile class available in .Net 4.5:
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Temp\file.zip','C:\Extracted')
    http://msdn.microsoft.com/en-us/library/hh485723%28v=vs.110%29.aspx
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Unzip GZ files using Powershell

    I have  Windows 2008 Server with some GZ type files in a folder. I would like to script unzipping them using Powershell, can someone tell me if this is possible and how I would do it?
    The folder is d:\data_files\ and I'd like to uncompress all the .gz files in there
    I've searched around on the Net but can't find much that deals with GZ files specifically. The files are all named data-1.gz, data-2.gz etc
    Hello
    I have  Windows 2008 Server with some GZ type files in a folder. I would like to script unzipping them using Powershell, can someone tell me if this is possible and how I would do it?
    The folder is d:\data_files\ and I'd like to uncompress all the .gz files in there
    I've searched around on the Net but can't find much that deals with GZ files specifically.

    I also found that .Net 2.0 and above has native code for dealing with gzip files.
    Function DeGZip-File{
    Param(
    $infile,
    $outfile = ($infile -replace '\.gz$','')
    $input = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read)
    $output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None)
    $gzipStream = New-Object System.IO.Compression.GzipStream $input, ([IO.Compression.CompressionMode]::Decompress)
    $buffer = New-Object byte[](1024)
    while($true){
    $read = $gzipstream.Read($buffer, 0, 1024)
    if ($read -le 0){break}
    $output.Write($buffer, 0, $read)
    $gzipStream.Close()
    $output.Close()
    $input.Close()
    $infile='C:\Temp\DECfpc1new.csv.gz'
    $outfile='c:\temp\DECfpc1new.csv'
    DeGZip-File $infile $outfile
    You can supply the function with the full path of the file to be unzipped, and the full path of the unzipped file.
    If you don't supply the unzipped file path, the function will unzip the file into the same folder as the source, and remove the .gz extension.
    Inspired by Heineken.

  • Unzip multiple bzip files thru powershell

    Hello there-
    I have 50 directories. Each directory has 10 sub directories in which there are 300 bz2 files. I would like to unzip them thru bzip program. Is it possible to do so with powershell/batch/cmd line script?
    Dir1>Subdir1>*.bz2
          >Subdir2>*.bz2
          >Subdir10>*.bz2
    Dir2>Subdir1>*.bz2
          >Subdir2>*.bz2
          >Subdir10>*.bz2
    Thanks,
    Ben

    Hi,
    To unzip files, I would like suggest you refer below code, those code is to find all current location zip files and unzip them to the current location:
    $shell=new-object -com shell.application
    $CurrentLocation=get-location
    $CurrentPath=$CurrentLocation.path
    $Location=$shell.namespace($CurrentPath)
    $ZipFiles = get-childitem *.zip
    $ZipFiles.count | out-default
    foreach ($ZipFile in $ZipFiles)
    $ZipFile.fullname | out-default
    $ZipFolder =
    $shell.namespace($ZipFile.fullname)
    $Location.Copyhere($ZipFolder.items())
    If you want to unzip many location files, we could use get-childitem to get all of them and saved in a variable.
    For more details, please refer to the below link:
    PowerShell script to unzip many files
    http://www.techiebirdsnest.com/2009/01/powershell-script-to-unzip-many-files.html
    Hope this helps.
    Regards,
    Yan Li
    Yan Li
    TechNet Community Support

  • Unzipping nested files in powershell

    # Initially clear screen
    clear-host
    # Set up initial Paths
    $destination = “C:\Users\paul__000\Documents\Test\unzipped"
    $b = 'C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports'
    # Set up working files - for establishing initial directories and files
    $bb = 'C:\Users\paul__000\Documents\Test\Test00.txt'
    $bc = 'C:\Users\paul__000\Documents\Test\Test01.txt'
    # Setup path - keep track of initial directory - and establish path to allow relative addressing
    $a = Get-Location
    Set-Location $b
    # Establish files for both folders and zip files
    get-childitem | format-table name | out-file $bb
    $c =get-content $bb
    $d = $c.count
    # Disgard surplus info & only keep directory and file name information (Not sure why count initially was 31 !!! : hence the need for -3 in next statement)
    $c = $c[3..($d-3)] | out-file $bb
    $c = Get-Content $bb | out-file $bc
    $c = Get-content $bc
    $d = $c.count
    $c = $c[0..($d-1)] | out-file $bc
    $c = get-content $bc
    $d = $c.count
    # establish folder names - by replacing .zip or .ZIP with \
    $d
    $count = 0
    do {
    $c[$count] = $c[$count].replace(".ZIP","\")
    $c[$count] = $c[$count].replace(".zip","\")
    $count=$count + 1
    until ( $count -gt ($d-1) )
    $c | out-file $bc
    $c = get-content $bc
    # Setup path - keep track of initial directory - and establish path to allow relative addressing
    $xxx = Get-Location
    Set-Location ($destination + "\")
    # set up folders
    $d
    $count = 0
    do {
    $k = $c[$count]
    New-Item -itemtype directory -path $k
    $count =$count +1
    until ( $count -gt ($d-1) )
    Set-Location $xxx
    # Establish a Expand-ZipFile function
    function Expand-ZIPFile($file, $destination)
    $file, $destination
    $file = "$file"
    $destination = "$destination"
    # help help help - it looks like i have send the correct parameters but i get the error:
    # You cannot call a method on a null-valued expression.
    # At C:\Users\paul__000\Documents\Powershell rj\Untitled26.ps1:70 char:19
    $shell = new-object -com shell.application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    $shell.Namespace($destination).copyhere($item)
    # Establish both - files to unzip and folders to store them in - parameters are passed to 'function Expand-ZIPFile'
    # This is where error occurs
    $c = get-content $bc
    $e = get-content $bb
    $f = $e.count
    $c , $e , $f
    $count=0
    do {
    $e[$count] = $b + '\' + $e[$count]
    $c[$count] = $destination + '\' + $c[$count]
    Expand-ZIPFile –File $e[$count] –Destination $c[$count]
    $count = $count + 1}
    until ($count -gt ($f-1))
    # end of main code
    ## This is standalone code which works successfully
    function Expand-ZIPFile($file, $destination)
    $shell = new-object -com shell.application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    $shell.Namespace($destination).copyhere($item)
    $mmm =“C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP ”
    $nnn =“C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\"
    Expand-ZIPFile –File $mmm –Destination $nnn
    The main concern is the use of a function called Expand-ZIPFILE which is used for unzipping nested zip files. 2 parameters are supplied, the file to be unzipped and the folder for showing the unzipped files. As it is a nested zip files these are zip files which also need to be unzipped. The code has not been written for this yet. I have placed a stand alone function at the bottom of my code which works perfectly. However when I try and run in the main body of code and pass parameters to the function it fails at line 70. Error message : You can not call a method on a null valued expression. I hope you can assist on this matter.Looking forward to your expert assistance.Roger
    

    Thanks for the code.
    I used it but changed the file and folder locations.
    It appeared to work, however in the 2 successive runs of the code, 2 different errors were announced at the PS Console. The errors are shown as follows:
    Second Run Error Message followed by First Run Error Message
    clear-host
    #File used 'C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP' instead of 'c:\scripts\scripts.zip'
    #Directory used 'C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\' instead of 'c:\temp\'
    # load support classes\
    $zipfile='C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP'
    [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression")
    #openand archive
    $archive = New-Object System.IO.Compression.ZipArchive(New-Object System.IO.FileStream($zipfile,'Open'))
    # list contents
    # $archive
    $archive.Entries|select name,length,fullname
    # extract a file
    $entry=$archive.GetEntry('scripts/config.ini')
    # $entry
    $target='C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\'
    # $target
    [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $target+$entry.Name, $true)
    $archive.Dispose();
    # Extract a zipfile
    [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
    [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP','C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\')
    write-host "Results"
    get-childitem 'C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\'
    # create a zip archive
    #[System.IO.Compression.ZipFile]::CreateFromDirectory('c:\scripts','c:\temp\scripts.zip')

  • Powershell to unzip file having passowrd

    hi, i am using the following script to unzip files it works fine with files not having password
    $shell=new-object -com shell.application
    $CurrentLocation=get-location
    $CurrentPath=$CurrentLocation.path
    $Location=$shell.namespace($CurrentPath)
    $ZipFiles = get-childitem *.zip
    $ZipFiles.count | out-default
    foreach ($ZipFile in $ZipFiles)
    $ZipFile.fullname | out-default
    $ZipFolder = $shell.namespace($ZipFile.fullname)
    $Location.Copyhere($ZipFolder.items())
    # for password protected file it pops up a windows saying password needed, how can i enter the password in script
    #what changes i need to make if i have to extract password protected files.
    student

    AFAIK, you can't do passwords directly with WScript.  You may be able to code up a method to imitate key strokes though.
    My suggestion would be to call another command-line utility zip/unzip program like 7-zip:
    http://www.7-zip.org/download.html

  • Unzipping Files in the wrong folder

    Hi
    I am trying to unzip files. It works fine except that it unzips the files at the root. So i have tried specifying the path for making the directory (in which the unzipped files are stored). But that doesnt seem to work. Now i am unable to find the unzipped files. CAN ANYONE HELP PLEASE
    public static void unzipFile(String zFile)
            Enumeration entries;
            ZipFile zipFile;
           try {
                zipFile = new ZipFile(zFile);
                File file = new File(zipFile.getName());
                String fname = file.getName();
               String substr1 = fname.substring(0, fname.indexOf("."));
                String filepath = "/data/psawant/temp";
                File dir = new File(filepath, substr1);
                try {
                        dir.mkdir();
                catch (Exception fe)
                      System.err.println("Unhandled exception:");
                        fe.printStackTrace();
                        return;
                entries = zipFile.entries();
                while(entries.hasMoreElements()) {
                    ZipEntry entry = (ZipEntry)entries.nextElement();
                    if(entry.isDirectory())
                         // Assume directories are stored parents first then children.
                        System.err.println("Extracting directory: " + entry.getName());
                                          (new File(entry.getName())).mkdir();
                        continue;
                    } //end of if
                    System.err.println("Extracting file: " + entry.getName());
                    copyInputStream(zipFile.getInputStream(entry),
                        new BufferedOutputStream(new FileOutputStream(entry.getName())));
                 } //end of while
                zipFile.close();
                   } catch (IOException ioe)  {                 }
             } //end of unzip function
    public static final void copyInputStream(InputStream in, OutputStream out)
        throws IOException
            byte[] buffer = new byte[1024];
            int len;
            while((len = in.read(buffer)) >= 0)
            out.write(buffer, 0, len);
            in.close();
            out.close();
    Any help is apprciated
    Thanx

    Sorry I got it this time. I had overlooked the new File. I added that & it works fine but there seems to be some problem
    If the folder has another folder inside . it doesnt show that one. or rather just unzips one folder & no folders inside it. But i guess i can check for that
    Thanx for u r help
    Have a nice day

  • Open, Write and Close the file using Powershell

    Hi All,
    I need to create/open a file and write some data into it and close that file.
    Could anyone please help me with this.
    Thanks.

    You don't need to explicitly create, open, or close a file in Powershell.  Here are some ways to write to a file, in addition to New-Item:
    $text = 'Hello World'
    # Create file:
    $text | Set-Content 'file.txt'
    #or
    $text | Out-File 'file.txt'
    #or
    $text > 'file.txt'
    # Append to file:
    $text | Add-Content 'file.txt'
    #or
    $text | Out-File 'file.txt' -Append
    #or
    $text >> 'file.txt'
    Grant Ward, a.k.a. Bigteddy
    The problem with Out-File is that it works like the console. When text is output, it will be truncated if it is wider than the default. So if you are looking for something where you need to store lots of long strings, then you may want to choose a different
    route, or ensure than you specify a width for your output.
    http://technet.microsoft.com/en-us/library/ee176924.aspx
    For example to get 200 characters of width:
    $text | Out-File
    'myfile.txt' -width 200
    I do not know for certain if there is a limit to how wide it can be. I also assume the default is the standard console width (80 characters I believe.)

  • How to get Document Set property values in a SharePoint library in to a CSV file using Powershell

    Hi,
    How to get Document Set property values in a SharePoint library into a CSV file using Powershell?
    Any help would be greatly appreciated.
    Thank you.
    AA.

    Hi,
    According to your description, my understanding is that you want to you want to get document set property value in a SharePoint library and then export into a CSV file using PowerShell.
    I suggest you can get the document sets properties like the PowerShell Command below:
    [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
    $siteurl="http://sp2013sps/sites/test"
    $listname="Documents"
    $mysite=new-object microsoft.sharepoint.spsite($siteurl)
    $myweb=$mysite.openweb()
    $list=$myweb.lists[$listname]
    foreach($item in $list.items)
    if($item.contenttype.name -eq "Document Set")
    if($item.folder.itemcount -eq 0)
    write-host $item.title
    Then you can use Export-Csv PowerShell Command to export to a CSV file.
    More information:
    Powershell for document sets
    How to export data to CSV in PowerShell?
    Using the Export-Csv Cmdlet
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • UNZIP file from ABAP

    Hi,
    I have a requirement to retrieve a zip file from the FTP Server, unzip it to the SAP Server and process the unzipped files. Retrieving the data from the FTP server should work via FTP commands which can be executed from within an ABAP program. However, the problem is unzipping these files via ABAP and put them on the server as well. 1. How to do this from within an ABAP Program? (unix commands?)
    2. Can I unzip these files with or without using the folder structure? (additional parameter for unix command?)
    Kind regards,
    Micky.

    REPORT ZTESTUNIX line-size 400
                    no standard page heading.
    selection-screen begin of block ucmd with frame title text-001.
    parameters: unixcom like   rlgrap-filename.   " ...SAP Interface file
    selection-screen end of block ucmd.
    data: begin of tabl occurs 500,
            line(400),
          end of tabl.
    data: lines type i.
    start-of-selection.
      refresh tabl.
      call 'SYSTEM' id 'COMMAND' field unixcom
                    id 'TAB'     field tabl[].
      describe table tabl lines lines.
      loop at tabl.
        write:/01 tabl-line.
      endloop.
      skip 2.
      if lines = 0.
        write:/ 'NO Occurances were found'.
      else.
        write:/ 'Command was successfully executed' color col_total.
        write:/ 'Number of entries in Search' color col_total,
                 lines color 6.
      endif.
    end-of-selection.
    while running give the command as
    <b>unzip test.zip  -x dir</b>
    then it will unzip test.zip file to dir called dir.
    you can specify the filepath instead of file...
    regards
    vijay

  • How to Read the "text file and csv file" through powershell Scripts

    Hi All
    i need to add a multiple users in a particular Group through powershell Script how to read the text and CSV files in powershell
    am completly new to Powershell scripts any one pls respond ASAP.with step by step process pls
    Regards:
    Rajeshreddy.k

    Hi Rajeshreddy.k,
    To add multiple users to one group, I wouldn't use a .csv file since the only value you need from a list is the users to be added.
    To start create a list of users that should be added to the group, import this list in a variable called $users, the group distinguishedName in a variable called $Group and simply call the ActiveDirectory cmdlet Add-GroupMember.
    $Users = Get-Content -Path 'C:\ListOfUsernames.txt'
    $Group = 'CN=MyGroup,OU=MyOrg,DC=domain,DC=lcl'
    Add-ADGroupMember -Identity $Group -Members $Users

  • How Do I Edit a Text File in PowerShell??

    How do i edit the text (or paragraphs) in text files using PowerShell?
    Thak You

    Hi,
    That's a pretty broad question, do you have something specific you're trying to accomplish?
    As one example though, this will create an input file (you could just use one you already have, but this is a fully contained example), read it, replace the word 'text' with the word 'fun', and write an output file:
    $exampleFile = @"
    This is some text.
    This is some more text.
    This is even more text.
    $exampleFile | Out-File .\input.txt
    (Get-Content .\input.txt ).Replace('text','fun') | Out-File .\output.txt
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Report the size of all SharePoint Databases in a text file using PowerShell?

    I am new to Powershell. please help me for following question with step by step process.
    How to report the size of all SharePoint Databases in a text file using PowerShell?

    Hi Paul,
    Here is the changed script, which will also include the size for the Config DB.
    Please let me know if it worked:
    #Get SharePoint Content database sizes
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    $date = Get-Date -Format "dd-MM-yyyy"
    #Variables that you can change to fit your environment
    $TXTFile = "D:\Reports\SPContentDatabase_$date.txt"
    $SMTPServer = "yourmailserver"
    $emailFrom = "[email protected]"
    $emailTo = "[email protected]"
    $subject = "Content & Config Database size reports"
    $emailBody = "Daily/Weekly/Monthly report on Content & Config databases"
    $webapps = Get-SPWebApplication
    $configDB = Get-SPDatabase | ?{$_.Name -eq ((Get-SPFarm).Name)}
    $ConfigDBSize = [Math]::Round(($configDB.disksizerequired/1GB),2)
    Add-Content -Path $TXTFile -Value "Config Database size: $($ConfigDBSize)GB"
    Add-Content -Path $TXTFile -Value ""
    foreach($webapp in $webapps)
    $ContentDatabases = $webapp.ContentDatabases
    Add-Content -Path $TXTFile -Value "Content databases for $($webapp.url)"
    foreach($ContentDatabase in $ContentDatabases)
    $ContentDatabaseSize = [Math]::Round(($ContentDatabase.disksizerequired/1GB),2)
    Add-Content -Path $TXTFile -Value "- $($ContentDatabase.Name): $($ContentDatabaseSize)GB"
    if(!($SMTPServer) -OR !($emailFrom) -OR !($emailTo))
    Write-Host "No e-mail being sent, if you do want to send an e-mail, please enter the values for the following variables: $SMTPServer, $emailFrom and $emailTo."
    else
    Send-MailMessage -SmtpServer $SMTPServer -From $emailFrom -To $emailTo -Subject $subject -Body $emailBody -Attachment $TXTFile
    Nico Martens - MCTS, MCITP
    SharePoint 2010 Infrastructure Consultant / Trainer

  • Unable to unzip files , unable to move apps into the app foldercant update

    I cannot unzip files. Also if i try to install a new app by dragging it to the applications folder it says "that files already exists".
    also if i try to update with software update it gives an error. i tried running verify disk permissions and repair disk permissions but this did nothing please help i am scared cuz my last time machine was along time ago.

    Not to worry.
    A few clarification questions first.
    What exactly does the dialog say when you try to drag a new app to the applications folder? Is it something like, "an older version of this already exists in this location, do you want to replace it with the version you are moving?"
    And, what application are you attempting to use to unzip files?

  • How to get DocSet property values in a SharePoint library into a CSV file using Powershell

    Hi,
    How to get DocSet property values in a SharePoint library into a CSV file using Powershell?
    Any help would be greatly appreciated.
    Thank you.
    AA.

    Hi AOK,
    Would you please post your current script and the issue for more effcient support.
    In addition, to manage document set in sharepoint please refer to this script to start:
    ### Load SharePoint SnapIn
    2.if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
    3.{
    4. Add-PSSnapin Microsoft.SharePoint.PowerShell
    5.}
    6.### Load SharePoint Object Model
    7.[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
    8.
    9.### Get web and list
    10.$web = Get-SPWeb http://myweb
    11.$list = $web.Lists["List with Document Sets"]
    12.
    13.### Get Document Set Content Type from list
    14.$cType = $list.ContentTypes["Document Set Content Type Name"]
    15.
    16.### Create Document Set Properties Hashtable
    17.[Hashtable]$docsetProperties = @{"DocumentSetDescription"="A Document Set"}
    18.$docsetProperties = @{"CustomColumn1"="Value 1"}
    19.$docsetProperties = @{"CustomColum2"="Value2"}
    20. ### Add all your Columns for your Document Set
    21.
    22.### Create new Document Set
    23.$newDocumentSet = [Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet]::Create($list.RootFolder,"Document Set Title",$cType.Id,$docsetProperties)
    24.$web.Dispose()
    http://www.letssharepoint.com/2011/06/document-sets-und-powershell.html
    If there is anything else regarding this issue, please feel free to post back.
    Best Regards,
    Anna Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

Maybe you are looking for