Windows 10: Converting Excel Data to Powershell Script

Discus and support Converting Excel Data to Powershell Script in Windows 10 Network and Sharing to solve the problem; How would I go about converting Excel Data to Powershell Script?... Discussion in 'Windows 10 Network and Sharing' started by DetectiveKn1ght, Aug 16, 2019.

  1. Converting Excel Data to Powershell Script


    How would I go about converting Excel Data to Powershell Script?

    :)
     
    DetectiveKn1ght, Aug 16, 2019
    #1
  2. ddelo Win User

    Export All Administrative Events to Excel


    To analyze events, from the Windows Event Viewer, there is a simple way to export all Administrative Events to Excel, with PowerShell.

    Exporting all Administrative Events to Excel is a simple two Step process, as described here:

    Step 1 - Create the Administrative Events View .xml file
    1. Open Eventviewer (%windir%\system32\eventvwr.msc)
    2. Navigate to: Event Viewer (Local) > Custom Views > Administrative Events
    3. In the “Actions” pane select “Filter Current Custom View”.
    4. Select the the XML tab.
    5. Press Ctrl+A to select all the XML code of the Custom View.
    6. Open a notepad, paste the selected code and save the file to your Desktop as AdmEvtView.xml


    Step 2 - Create the csv file with the events
    1. Download the ExportEvtCSV.zip file, which contains the script ExportEvtCSV.ps1 and unzip it, on your Desktop.
      It's not a fancy script, just basic PowerShell commands to create a csv file on the Desktop.
    2. In Windows Search, type “ISE” (without the quotes) to open “Windows PowerShell ISE” and Run as administrator
    3. To allow running the script, change the ExecutionPolicy, for this session. To do that, in the Console pane type:
      Code:
      Code:
      Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -force
    4. In the Windows PowerShell ISE, open and run the script: ExportEvtCSV.ps1
      The script will create a csv file with a name YYYYMMDD.HHMM.csv on the Desktop
    5. When done, open the newly created .csv file, format the columns as needed and optionally save it as .xlsx, if you wish.
    That’s it! You now have all the Administrative Events in Excel for filtering and further analysis. Converting Excel Data to Powershell Script :)

    Now to the more technical hard stuff... *Confused

    There is a reason for running the script from within PowerShell ISE!

    It would be great if everything was also working perfectly, when running the script from an elevated PowerShell too.

    We can run it from an elevated PowerShell, which means that you just follow the Step 1, as above but for the Step 2 instead of the ISE you run the script from an elevated PowerShell.

    The problem is that it will work only for anybody who has en-US format for the dates. Everyone else, who has another format (i.e. en-GB, fr-FR, el-GR etc.), the dates are not translated properly by Excel (although the script uses the –UseCulture switch) and remain as text in the en-US format.

    I'm not sure if this a bug of the "export-csv" cmdlet, but although it runs the way it supposed to from within the ISE, from PowerShell there is a problem with the dates format.
    As I haven’t found a way to overcome this obstacle, any suggestion from the PowerShell gurus of the forum (like my good friend Shawn @Brink, for instance), is welcome.
     
    ddelo, Aug 16, 2019
    #2
  3. Refreshing Excel SpreadSheet by runnig script using Task Scheduler

    Hi,



    Thank you for writing to Microsoft Community Forums.



    I understand that you are unable to run the script to refresh the Excel spreadsheet.



    However, as the issue is related to refreshing the data in Excel spreadsheet using a script, I suggest you to post your query on

    MSDN
    forums, where they provide dedicated support on issues with running scripts for Excel.



    In addition, to run the script using Task Scheduler you can refer the article

    Configure to run a PowerShell Script into Task Scheduler
    .



    Hope it helps.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, Aug 16, 2019
    #3
  4. Converting Excel Data to Powershell Script

    PowerShell scripts not working with Call operator

    Hi,



    Thank you for writing to Microsoft Community Forums.



    I understand that you are facing issues while developing a PowerShell script using the Call operator. I would suggest you to refer the articles

    The Windows PowerShell ISE
    .



    However, as the issue is related to developing PowerShell scripts, I would suggest you to post your query on

    MSDN forums
    , where we have expertise and developers who are well equipped with the knowledge of developing PowerShell scripts in Windows.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, Aug 16, 2019
    #4
Thema:

Converting Excel Data to Powershell Script

Loading...
  1. Converting Excel Data to Powershell Script - Similar Threads - Converting Excel Data

  2. Powershell Script on Shutdown

    in Windows 10 Performance & Maintenance
    Powershell Script on Shutdown: Hi all, I try to run a Powershell Script (*.ps1) when i shut down my PC. I created the script and it is working fine when i run it. However if i want to run it on a regular Shutdown it seems like it does not start or is not finished, before Windows is killing every running...
  3. PowerShell scripts not working with Call operator

    in Windows 10 BSOD Crashes and Debugging
    PowerShell scripts not working with Call operator: Hello I have been developing a Powershell script using Powershell ISE, and for the most part i am very happy about it, however i have encountered what i believe to be a bug in the call operator (&). When i use the call operator followed by a "pure" string everything works...
  4. bug in powershell module Convert*-Json

    in Windows 10 BSOD Crashes and Debugging
    bug in powershell module Convert*-Json: Hi all, The date property goes one day back when I convert it to Json and directly convert it back. Get-Date | Select-Object -Property * DateTime : monday 18 february 2019 09:45:59 Date : 18-2-2019 00:00:00 Get-Date | Select-Object -Property * |...
  5. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  6. Run PowerShell Script As An Administrator

    in Windows 10 Support
    Run PowerShell Script As An Administrator: Hi. So I've been searching online on a way to do this yet I cannot find a way to do it. _______________________________________ I need this in specific: I want to double click a PowerShell script file (which will run as an administrator) from Windows Explorer that has...
  7. Converting data

    in Windows 10 Software and Apps
    Converting data: From an e-mail, is there any way to convert data on a notepad to an Excel spreadsheet? https://answers.microsoft.com/en-us/windows/forum/apps_windows_10-outlook_mail/converting-data/194812ce-c9ba-4d69-98b4-250b718306b0
  8. A Powershell Script for HandBrake

    in Windows 10 Software and Apps
    A Powershell Script for HandBrake: Here's the thing. My system is an age-old i3-530 overclocked to 3.5GHz coupled with GTX 1050 2GB. I have around 1.5TB of tutorial videos that I have to encode due to dearth in HDD space. I want to encode the videos while keeping the folder and subfolder structure intact....
  9. EXCEL 2016 script error when getting external (web) data

    in Microsoft Office and 365
    EXCEL 2016 script error when getting external (web) data: Hi there Trying to download data from web into a spreadsheet I keep getting Script Error. This worked perfectly in EXCEL 2010 (and still does). Get external data -->web The query simply takes the components of the London FTSE 100 (like the Dow jones / S&P) and downloads...
  10. PowerShell Scripting - The Basics

    in Windows 10 Tutorials
    PowerShell Scripting - The Basics: Thanks @Kari for this introduction to PowerShell scripting. I think everybody should read this and try to understand everything. PS plays bigger and bigger role in Windows with each year that goes by. I am not saying that everybody should become a scripting guru, but every...