Exporting specific columns from XLS file to a new XLS or XLSX file using powershell

The scenario is that i have a file that our server is constantly dumping data to on a daily basis and out of all the data i only need 2 columns. I need to be a able to automate this because i need to generate a monthly report based on those two columns.
That being said, i need to be able to extract two full columns from datafile1.xls to newdatafile.xlsx. If it would be easier if the original file is CSV i can easily save the data in CSV format instead of XLS. 
Thanks in advance.

I see, im having a hard time executing the script, i keep getting the following error:
'""Microsoft.Jet.OLEDB.4.0"
has not been registered.";' 
and
when i try to run it like this i dont get any errors BUT nothing happens:
C:\Windows\syswow64\rundll32.exe "C:\Program Files\Common Files\System\Ole DB\oledb32.dll",c:\temp\t.ps1
This is the code, which to tell you the truth im not really that familiar with :\
$strFileName = "C:\temp\original\styles.xls"
$strSheetName = 'STYLES$'
$strProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
$strDataSource = "Data Source = $strFileName"
$strExtend = "Extended Properties=Excel 8.0"
$strQuery = "Select STYLE CODE , LAST UPDATE from [$strSheetName]"
$objConn = New-Object System.Data.OleDb.OleDbConnection("$strProvider;$strDataSource;$strExtend")
$sqlCommand = New-Object System.Data.OleDb.OleDbCommand($strQuery)
$sqlCommand.Connection = $objConn
$objConn.open()
$DataReader = $sqlCommand.ExecuteReader()
While($DataReader.read())
$ComputerName = $DataReader[0].Tostring()
"Querying $computerName ..."
Get-WmiObject -Class Win32_Bios -computername $ComputerName
$dataReader.close()
$objConn.close()
For both PowerShell or VBScript you are missing the libraries.  You need to download and install the ACE drivers.
Search for ACE drivers.
¯\_(ツ)_/¯

Similar Messages

  • SQL* Loader Loading specific column from CSV file to the table

    Dear All,
    Iam Loading specific column from .CSV file to the oracle table.
    Could pls help how i can load only that cols into the table
    Eg: CSV file having id, Frst_name,Last_name, Address,Phone,Insurance etc
    out of this I want to load only Frst_name,Last_name columns to oracle table say fname and lname.
    Thanks in Adv.
    Junu

    Lily,
    I made some changes to your table def but you will get the idea
    -- Table EMPLOYEE
    CREATE TABLE EMPLOYEE
      EMPID        NUMBER                           NOT NULL,
      EMPNICKNAME  VARCHAR2(10 BYTE)                    NULL,
      FNAME        VARCHAR2(20 BYTE)                NOT NULL,
      MI           VARCHAR2(20 BYTE)                    NULL,
      LNAME        VARCHAR2(20 BYTE)                NOT NULL,
      FULLNAME     VARCHAR2(20 BYTE)                NOT NULL,
      HIREDATE     DATE                             DEFAULT SYSDATE               NOT NULL
    --  data file employee.dat
    1,amy,b,amy b
    2,cindy,d,cindy d
    3,eric,f,eric f
    4,gary,h,gary
    -- Control file : Employee.ctl ( you can use truncate, replace or append , see sqlldr for more options)
    load data
    Truncate into table employee
    fields terminated by ","
    optionally enclosed by '"'
    TRAILING NULLCOLS
    empId INTEGER EXTERNAL,
    FName char(20),
    LName char(20),
    FullName char(30)
    now to load use following or you can speicify infile in control fle
    sqlldr username/passowrd control=employee.ctl  data=employee.dat log=employee.log
    {code}
    Hope this help.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Issue in loading specific columns from a file to teradata table using IKM

    Hi,
    Can any one help to resolve the issue in loading specific columns from text file to teradata table.
    i tried using IKM file teradata and columns are getting displaced.
    my requirement suppose i have 5 columns in file and i have to load only 3columns to table using IKM.
    same thing can be achived using LKM file to teradata but i want use IKM.
    please suggest me on this
    Regards
    Vinod

    Hi,
    I believe that the problem you are having is that you have a delimited file, of which you want to pick columns from position 2,3,5. In this case, ODI will pick the first 3 columns of a delimited file regardless of position.
    For example, if you a tab delimited file with c1,c2,c3,c4,c5 columns, and you want only columns c2,c3,c5 - when mapping these in an ODI interface, and executing, you will actually pick up the data from c1,c2,c3 as these are the first three columns in the file (reading from left to right). You can ignore "columns" on the right hand side of a file, but not the left. E.g delimited file with c1,c2,c3,c4,c5. Only pick columns c1,c2 will give you data for the first 2 columns
    Create a temporary table to load all the data from the file, and use you temp table to extract the data you require. Or you could get the file created with the first three columns as the columns you require.
    Cheers
    Bos
    Edited by: Bos on Jan 18, 2011 1:06 PM

  • Is it possible to use certutil to export multiple certificates from a local client machine store, to a .p7b file?

    Is it possible to use certutil to export multiple certificates from a local client machine store, to a .p7b file?
    Scenario: We have a few legacy certificates based on some legacy templates (2012 R2). Some belong to an old SubCA (2008 R2).
    I’ve can manually export them using certmgr mmc on the local machine to a single .p7b e.g.
    cert_backupNEW.p7b. But this is not a practical solution for me and I want to achieve this remotely via certutil or some other util that comes with Windows 7 machines.
    I’ve already worked out how to run a certutil command to add the certs back into the store e.g.
    certutil.exe -addstore -f my cert_backupNEW.p7b
    Is there a way to export multiple certs to a single backup cert, or is what I’m trying to do not possible with multiple certs?
    TC

    Something like this:
    $store = New-Object Security.Cryptography.X509Certificates.X509Store "my","localmachine"
    $store.Open("ReadOnly")
    Set-Content -Path exportedcerts.pfx -Value $store.Certificates.Export("pfx","password")
    $store.Close()
    note that this command will fail, if there are certificates with non-exportable keys. You cannot export certificates with non-exportable keys.
    My weblog: en-us.sysadmins.lv
    PowerShell PKI Module: pspki.codeplex.com
    PowerShell Cmdlet Help Editor pscmdlethelpeditor.codeplex.com
    Check out new: SSL Certificate Verifier
    Check out new:
    PowerShell FCIV tool.

  • Unable to export all columns from sharepoint 2010 survey

    Have a user that cannot export all columns from a sharepoint survey. When exported, he only gets 3 columns. We've tried a number of things, including exporting from the overview view. We've also made sure that readers had full edit rights, etc. Just for
    background, this survey does contain branching logic. Any ideas?

    I have had
    exactly the same problem before.
    There's already a ton of suggestions on these blogs, and I suspect there is a bug somewhere.
    As I'm lucky to have Reporting Services in SharePoint mode, I've been using it to export Survey data, pre-process it, and export it to Excel or PDF.

  • Import / Export Specific tables from DB

    Hi,
    I am trying to export all 'AD_' tables from my database from another database with their constraints.
    I tried a command just for export one table from my cmd :
    "exp adempiere/adempiere@simext15:1521/compiere2 file=emp.dmp tables=(AD_ACCESSLOG)"
    it export fine but when try to import this file from using command
    "imp adempiere/adempiere@simext15:1521/compiere2 file=emp.dmp fromuser=adempiere touser=adempiere tables=(AD_ACCESSLOG)"
    it gives me so many errors:
    Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export file created by EXPORT:V11.01.00 via conventional path
    import done in WE8MSWIN1252 character set and UTF8 NCHAR character set
    . importing ADEMPIERE's objects into ADEMPIERE
    . . importing table "AD_ACCESSLOG" 0 rows imported
    IMP-00015: following statement failed because the object already exists:
    "CREATE UNIQUE INDEX "AD_ACCESSLOG_KEY" ON "AD_ACCESSLOG" ("AD_ACCESSLOG_ID""
    " ) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FR"
    "EELIST GROUPS 1 BUFFER_POOL DEFAULT) LOGGING"
    IMP-00017: following statement failed with ORACLE error 2264:
    "ALTER TABLE "AD_ACCESSLOG" ADD CONSTRAINT "AD_ACCESSLOG_KEY" PRIMARY KEY ("
    ""AD_ACCESSLOG_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(I"
    "NITIAL 65536 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "
    ""USERS" LOGGING ENABLE "
    IMP-00003: ORACLE error 2264 encountered
    ORA-02264: name already used by an existing constraint
    IMP-00017: following statement failed with ORACLE error 2264:
    "ALTER TABLE "AD_ACCESSLOG" ADD CONSTRAINT "ADTABLE_ADACCESLOG" FOREIGN KEY "
    "("AD_TABLE_ID") REFERENCES "AD_TABLE" ("AD_TABLE_ID") ENABLE NOVALIDATE"
    IMP-00003: ORACLE error 2264 encountered
    ORA-02264: name already used by an existing constraint
    IMP-00017: following statement failed with ORACLE error 2264:
    "ALTER TABLE "AD_ACCESSLOG" ADD CONSTRAINT "ADCOLUMN_ADACCESSLOG" FOREIGN KE"
    "Y ("AD_COLUMN_ID") REFERENCES "AD_COLUMN" ("AD_COLUMN_ID") ON DELETE CASCAD"
    "E ENABLE NOVALIDATE"
    IMP-00003: ORACLE error 2264 encountered
    ORA-02264: name already used by an existing constraint
    About to enable constraints...
    IMP-00017: following statement failed with ORACLE error 2430:
    "ALTER TABLE "AD_ACCESSLOG" ENABLE CONSTRAINT "ADTABLE_ADACCESLOG""
    IMP-00017: following statement failed with ORACLE error 2430:
    "ALTER TABLE "AD_ACCESSLOG" ENABLE CONSTRAINT "ADCOLUMN_ADACCESSLOG""
    Import terminated successfully with warnings.
    I tried a lot for this I just want to export and restore all 338 tables related to Application Dictionary from one database to another database with their constraints and data.
    I tried also using datalink but it only copy the structure and data but not the constraints, I want all three should be copy in to another database.
    I know their is dependency on a table to another table but i don't know exactly it..
    tried it onces again i am able to do export and import tables but only primary key related to every table gets restore neither Unique key nor Foreign key , please help me out from this i can export and import with full table with data and its all constraints.
    Please help me out from this problem, waiting for your valuable suggestions.
    Regards,
    Manu

    ORA-02264: name already used by an existing constraint
    The constraint is already exists with the same name. So drop that before issuing the import command.
    And ,
    1. Check if all tables get imported
    2. If all tables get imported then create the constraints manually
    3. If tables do not get imported then import tables manually by specifying their name in imp statement
    Thanks

  • How do I export a video from After Effects CC to an iPhone? I'm using a PC.

    How do I export a video from After Effects CC to an iPhone? I'm using a PC.

    Short answer, there is no simple "export to iPhone", but if you just want to have a movie that you can watch on you iPhone, just send yourself an attachment via email (other than .avi) and save it to your phone.
    You can also use dropbox as an option.
    With an app, you could mount your iPhone as an external drive. (check out iExplorer)
    Also: check AME for h264 variations before you send it to yourself.  There are presets for iPhone compression.

  • Cannot export all columns from ALV

    Hi ,
    I copied a standard report into a custom report and added few columns to it.
    Now my issue is the alv ouput doesnot have any direct export button on it , so we are using the menu option LIST --> Spreadsheet,  to export the report in to excel sheet. now the problem is all the columns from the alv are not getting download to excel ,  i thing it depends upon the layout setting but not sure. i even removed the layout setting and checked but still not all the columns are getting downloaded.
    Please help me on this...
    Thanks
    Fardee

    done

  • HT4527 I recently moved my files from windows xp to a new windows 8.1 pc using PCMover Express. When I open up a file within itunes, the music doesn't start in itunes, it starts in xbox music player. How do I move my itunes file so it opens in itunes?

    I recently moved my files from a windows xp pc to a new widows 8.1 pc using PC Mover Express. When I open up a file within the itunes folder, it opens to the default player xbox 360 media player. How do i transfer my itunes folder so it opens up in my itunes account?

    Hi kozzie17,
    If your music is no longer opeing in iTunes by default on your Windows machine, you may find the following article helpful:
    iTunes for Windows: How to make iTunes the default application for music and audio files in Windows Vista and Windows 7
    http://support.apple.com/kb/HT3202
    Regards,
    - Brenden

  • How to copy referenced photos from dodgy external drive to new drive when whole file will not copy due to error 36.

    My external WD portable passport drive must be dodgy because I can't back it up or clone it or copy 3 of my 22 photo files to a new portable drive. I get error 36 as I attempt all 3 processes. I have copied my iPhoto library, iMovie events and most of my aperture referenced photos to the new drive. But cannot copy 3 files that contain the corrupted files showing just a grey triangle. I cannot delete or move to trash the corrupted raw photos.
    How can I copy to the new drive any photos that aren't corrupted (grey triangle instead of photo or a photo that's just coloured horizontal broken lines) so I can then reconnect the referenced photos after copying them?
    I am on late 2008 MacBook Pro with lion,
    Many thanks
    Bw

    I've worked out how to copy and reconnect individual photos.
    But can see that what's happening is that heavily edited raw photos are taking ages to load. Or not loading at all. And if opened go to the spinning wheel for 5-10 minutes. I am wondering whether to compress these or take them back to the originals or any other ideas would be very welcome.
    Thank you
    BW

  • Any way to export several columns from the Links panel?

    This was originally posted to the InDesign forum, was suggested there might be a script that could achieve this?
    Working on a textbook with hundreds of illustrations. Each Chapter has  up to 100.  Need to get several columns of data (file name and page #  that it appears on) exported from the Links Panel (in sorted order) so  they can be dropped into a spreadsheet. I am using TextWrangler which  will dump out all the filenames in a folder, but it sorts alphabetically  and I really want them sorted by the Page Numbers where they appear.

    This script creates a CSV file on the desktop that you can import in Excel. The file name is the same as the name of active indesign document.
    Kasyan
    var scriptName = "Generate list of links";
    if (app.documents.length == 0) ErrorExit("No documents are open. Please open a document and try again.");
    var page, allGraphics, graphic;
    var text = "File name;Page\r";
    var doc = app.activeDocument;
    for (var i = 0; i < doc.pages.length; i++) {
         page = doc.pages[i];
         allGraphics = page.allGraphics;
         for (var k = 0; k < allGraphics.length; k++) {
              graphic = allGraphics[k];
              if (graphic.itemLink != null) {
                   text += graphic.itemLink.name + ";" + page.name +"\r";
    WriteToFile(text);
    //-------------------------------------- FUNCTIONS ---------------------------------------------
    function WriteToFile(text) {
         var theFile = new File("~/Desktop/" + GetFileNameOnly(doc.name) + ".csv");
         theFile.open("w");
         theFile.write(text);
         theFile.close();
    function ErrorExit(error, icon) {
         alert(error, scriptName, icon);
         exit();
    function GetFileNameOnly(myFileName) {
         var myString = "";
         var myResult = myFileName.lastIndexOf(".");
         if (myResult == -1) {
              myString = myFileName;
         else {
              myString = myFileName.substr(0, myResult);
         return myString;

  • Export 2 specific folders from users A mailbox and transfer them to user B Via Powershell

    Hi 
    i know there is a simpler method for the user to export the folder within outlook as a PST file and send it to the other user to import... but
    Is there a powershell command sequence i can use that will export folders from User A mailbox and import them into User B's mailbox remotely so they don't have to do anything.
    Many Thanks
    Gordon

    i made some progress with the following
    New-MailboxExportRequest -mailbox "User A" -includeFolders "User A\\TransferFolder" -Filepath \\server\serversubfolder\transfer.pst -verbose
    then using
    New-MailboxImportRequest -mailbox "User B" -FilePath \\server\serversubfolder\transfer.pst -TargetRootFolder "Inbox" -includefolder "Transferfolder" -verbose

  • How can I export image column from SQL Server 2000

    Hi everybody,could someone tell me how can I export an entire column( pictures type) to a folder on disk?I've tried the textcopy.exe under the SQL installation's binn folder,it can only export one picture a time,I'm trying to find an automated way to export
    the whole colum's images to a folder,I'm using SQL Server 2000.

    Vishal,thanks for the replay,I've tried the BCP method but it seems does not work on my Sql Server 2000,also the SSIS package method is demonstrated with Sql Server 2008 R2 and my machine does not have the visual application to try it.In the BCP method,I
    got prompt  indicating me that I wrote something wrong in the grammer,and I'm pretty sure that maybe I made something wrong in the below part,the grammer makes me confused
    INSERT
    INTO @sqlStatements
    SELECT 'BCP "SELECT Photograph_Data FROM [ALBSCH_Trial].[dbo].[Photograph] WHERE Photograph_ID = '''
    + CAST(Photograph_ID AS VARCHAR(500)) + '''" queryout ' + @OutputFilePath
    + CAST(Photograph_ID AS VARCHAR(500)) + '.jpg -S localhost\SQLEXPRESS2008 -T -f C:\SQLTest\Images.fmt'
    FROM dbo.Photograph

  • Export specific records from all table? Please help me with my query

    hi
    there are around 200 tables, I want to take a export of all tables of xyz schema.
    My requirement is just a few records of primary key and their relevant records from other tables to be exported by using exp or expdp utility.

    Hi Toni...
    Thanks for your reply.
    Could you please help me understand how to user this expdp query...
    and what exactly should i mention in the parfile. I want all relevant records from all tables of primary key. please help me to write a query accordingly.

  • HT3275 My Time Machine Error persists even after changing from ex HDD to a new 3G Time Cap and using DU: "An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk."

    Thanks for your thoughts on this!

    Thanks for this Pondini!  I swapped back to my original 2TB back up from the new 3TB Time Cap with still no luck. It last succesfully backed up 16th June 2012 but has failed since then.  I'm getting multiple error -36's from the same folder ...Backup/599c... but involving different files eg .../02f... and .../03e... etc.  This is going to be a nightmare to exclude them all one at a time.  Can I just exclude the entire ...Backup/599c... folder?
    Dimitri.
    Aug  3 08:11:08 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/02f517f9d3de 637c63fad6447558fcea3f289734 to (null)
    Aug  3 08:12:08 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/03e718ec4f0e fa74179f2ddf4f690a397c7bfd83 to (null)
    Aug  3 08:12:47 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/0f4105650705 e06d625f3216693c054c7ab1bdba to (null)
    Aug  3 08:13:03 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/0f4f0381dc35 0a7b4911f13939631e8d19c9d3d6 to (null)
    Aug  3 08:13:37 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/114ae1ea6eda e56b90384d0fdb63290c0ca336c7 to (null)
    Aug  3 08:14:43 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/13e1187ef5a4 98ee59bd3a1ec80e0e148cd995fb to (null)
    Aug  3 08:15:17 cathy-hatchs-imac.local com.apple.backupd[23752]: Error: (-36) SrcErr:YES Copying /Users/DIMITRI/Library/Application Support/MobileSync/Backup/599c5ea5c84fd845b43fab22ce6d0dba3246b5df/180a9f76a50f f281515a50a5d89e3de044954ce3 to (null)

Maybe you are looking for

  • Ipod touch4g  is not detected in pc and itunes after software update

    after software update is done. when i connect my ipod touch it is not detected in pc (windows 7) and in itunes please help me anyone.

  • A Self-Contained JRE

    Hi, I am developing an incident response kit in Java. The kit creates new processes for each forensic test using Runtime.getRuntime().exec(cmd). This kit will be part of a larger project to perform remote forensic analysis of vulnerable machines on a

  • SQL Server with JDeveloper

    Hi Jdev Team: Since there no success to create application using JDeveloper3.2 after connecting to SQL Sever 7.0. Just wandering if there are some examples or instructions to demonstrate how to develop an application based on SQL Server or other non-

  • EDIT AGGREGATION RULE IN ANSWER FOR A MEASURE

    Hello Experts, I have a measure in my fact table which is a "price" and I don't want to set up a default aggregation (sum, avg, max, min...etc) in my Business Model (Administrator). I want the user to be able to set an "Aggregation Rule" in Answers t

  • IPod updater killed my iPod mini!

    I purchased an iPod Mini off of my boss last week, as he purchased an iPod Nano and no longer has any need for it. I installed iTunes on my Toshiba Satellite at work, hooked up my iPod, and I while I was removing songs from the unit (which worked jus