Get data of ouf a list to put in sql

I have a script that checks which checkboxes are checked then
adds ticked ones into a list, I now want to get the data out of the
list and put it into a sql select something like select * from
table where title in(list), my problem is not only getting the data
out of the list but also getting it so it is the correct format
(single quotes with a comma between items)
Attached is the part of the code where i am creating the list
i have also included the sql part to make more sense, can anybody
help me or tell me what i need to do to split the list into
something like: 'item1', 'item2', etc

I have one quick question instead of starting a new thread
ill ask here, i want to be able to use the result of the sql
statement on another frame will i need a global string? and then
need a way to get rid of everything in the err string that the sql
returns? for example in the err its
err = [#rowschanged: 0, #columns: ["Title", "Takings"],
#columntype: [<Void>, "float"], #rows: [["live and let",
126400000], ["the man with", 97600000]], #errorMsg: 0]
Then will i need something like you did above to get rid of
everything but the title and takings?
Thanks again!

Similar Messages

  • How to validate data is in specific list while loading from SQL*Loader

    I have a sample data file like below
    1,name1,05/02/2012 10:00:00,blue
    2,name2,06/02/2012 10:00:00,red
    3,name3,07/02/2012 10:00:00,yellow
    4,name4,08/02/2012 10:00:00,white
    I would like to validate 4Th column to be a valid color (ie) All color should be in a specific list, if it is not in the lis then the record should do to bad/discard file
    How can do that while loading Data From SQL*Loader?

    user8860934 wrote:
    I have a sample data file like below
    1,name1,05/02/2012 10:00:00,blue
    2,name2,06/02/2012 10:00:00,red
    3,name3,07/02/2012 10:00:00,yellow
    4,name4,08/02/2012 10:00:00,white
    I would like to validate 4Th column to be a valid color (ie) All color should be in a specific list, if it is not in the lis then the record should do to bad/discard file
    How can do that while loading Data From SQL*Loader?Probably a lot easier with an EXTERNAL TABLE (they're much more flexible).
    Is SQL Loader a mandatory requirement for some reason?

  • Create a visual web part which get data from excel sheet and import it into sql server database in sharepoint 2010 (development)

    Hi,
    I want to create a visual webpart which will read data from excel sheet and import it in to sql server database.(using sharepoint development)
    I want to do it using visual webpart.
    Please help to solve the issue.
    Thanks in advance!
    Regards
    Rajni

    Hi  Rajni,
    Microsoft.Office.Interop.Excel assembly provides class to read excel file data, in your web part solution, reference the assembly, and following blog contains samples about how to read the excel file data,
    and import it to SQL  database.
    1.Create a Visual Web Part Project:Create
    Visual Web Parts in SharePoint 2010
    2.Read the excel workbook by using SPFile class:
    http://alancejacob.blogspot.in/2012/06/read-data-from-excel-file-and-insert-in.html
    http://stackoverflow.com/questions/14496608/read-excel-file-stored-in-sharepoint-document-library
    3.Export the excel workbook to SQL Server:
    http://www.c-sharpcorner.com/UploadFile/99bb20/import-excel-data-to-sql-server-in-Asp-Net/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Getting data of two records in one line using SQL

    Hi,
    We have a COMPANY_RESEARCH table that maps companies to the Research Universes that do research on them. This table has:
    COMPANY_ID VARCHAR2(100), foreign key to COMPANY table.
    RESEARCH_UNIT_ID CHAR(1)
    Valid values for RESEARCH_UNIT_ID are 1(US Equity), 2(Canadian Equity) and 3(Debt security).
    Within my COMPANY_RESEARCH_ID table, I have:
    COMPANY_ID RESEARCH_UNIT_ID
    aaaa 2
    aaaa 3
    How can I write a SQL query that gives me the output?
    Company Id Equity Debt
    aaaa Canada Yes
    My attempt was as below:
    select
         FILTERED_COMPANIES.COMPANY_ID as Company,
         DECODE(FILTERED_COMPANIES.RESEARCH_UNIT_ID,'1','US','2','Canada','3','N/A') As Equity,
         DECODE(FILTERED_COMPANIES_1.RESEARCH_UNIT_ID,'1','N/A','2','N/A','3','Yes') as Debt
    FROM
              select distinct
              company_id, research_unit_id
              from company_research_relation
         )FILTERED_COMPANIES,
              select distinct
              company_id, research_unit_id
              from company_research_relation
         )FILTERED_COMPANIES_1
    WHERE
         FILTERED_COMPANIES.COMPANY_ID = FILTERED_COMPANIES_1.COMPANY_ID
         AND FILTERED_COMPANIES.RESEARCH_UNIT_ID = FILTERED_COMPANIES_1.RESEARCH_UNIT_ID
    but that produces output as below:
    Company Id Equity Debt
    aaaa Canada N/A
    aaaa N/A Yes
    Thanks in advance..

    Hi,
    how about this one?
    SELECT select_equity.company_id, enquity, dept, select_equity.research_unit_id, SELECT_dept.research_unit_id
    FROM
    (SELECT company_id, research_unit_id, DECODE(RESEARCH_UNIT_ID,'1','US','2','Canada','3','N/A') enquity FROM company_research) select_equity,
    (select company_id, research_unit_id, DECODE(RESEARCH_UNIT_ID,'1','N/A','2','N/A','3','Yes') Dept FROM company_research) SELECT_dept
    WHERE select_equity.company_id = SELECT_dept.company_id
    AND enquity != 'N/A'
    AND dept != 'N/A';
    Regards,
    Gerd

  • How can i get data from another database SQL Server use database link from

    I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?

    hi,
    u should see following documentation:
    Oracle9i Heterogeneous Connectivity Administrator's Guide
    Release 1 (9.0.1)
    Part Number A88789_01
    in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
    regards
    umar

  • Issue Putting Data from ArrayCollection into List

    I'm having trouble getting data that has been pulled from a textArea and put into an ArrayCollection to be displayed in a List.  The data is being saved and then read as a file from local storage.  When I run the application, nothing appears in the created list even though I get no compile-time errors.
    Here is my List code:
    <fx:Script>
    <![CDATA[
    import dh.DataHandling;
    import mx.collections.ArrayCollection;
    import mx.collections.ArrayList;
    import mx.events.FlexEvent;
    import spark.effects.SlideViewTransition;
    [Bindable]
    private var dataR:DataHandling = new DataHandling();
    protected function button1_clickHandler(event:MouseEvent):void  // pushed home button
    var svt:SlideViewTransition = new SlideViewTransition(300, SlideViewTransition.SLIDE_RIGHT);
    navigator.pushView(views.HomePage, event.relatedObject, svt);
    ]]>
    </fx:Script>
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:actionContent>
    <s:Button label="Delete"/>
    <s:Button label="Home" click="button1_clickHandler(event)" skinClass="skins.homeButtonSkin"/>
    </s:actionContent>
    <s:Image x="0" y="-80" height="603" source="mainapp1.jpg"/>
    <s:List  id="myCardsList" x="10" y="10" width="1004" height="500" top="0" bottom="0" left="0" right="0"
      dataProvider="{dataR.cards as ArrayCollection}">
    <s:itemRenderer>
    <fx:Component>
    <s:MobileIconItemRenderer label="{data.textTitle}"/>
    </fx:Component>
    </s:itemRenderer>
    </s:List>
    Here's the "saving/reading the file" class used in creating the ArrayCollection:  ( DataHandling.as )
    package dh
    public class DataHandling
    import flash.events.IOErrorEvent;
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    import mx.collections.ArrayCollection;
    [Bindable]
    public var cards:ArrayCollection = new ArrayCollection();
    public var file:File;
    public var fileStream:FileStream;
    public var fileName:String = "Initial String";
    public var directory:String = "SimpleSaveFromAIR";
    public var textTitle:String;
    public function DataHandling()
    public function add():void
    // new object
    var card:Object = new Object();
    card.tcard = textTitle;
    //card.mtext1 = mtext1.text;
    ///card.mtext2 = mtext2.text;
    cards.addItem(card);
    public function save():void
    // create file object (resolve user's directory, add own directory)
    file = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
    // FileStream for writing the file
    fileStream = new FileStream();
    // open the file in write mode
    fileStream.open(file, FileMode.WRITE);
    // Write the ArrayCollection object of cards to the file
    fileStream.writeObject(cards);
    // close stream
    fileStream.close();
    public function read():void
    // get correct path
    file = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
    // read if exists
    if(file.exists)
    // FileStream for reading the file
    fileStream = new FileStream();
    // open the file in read mode
    fileStream.open(file, FileMode.READ);
    // Read the ArrayCollection object of cards from the file
    cards = fileStream.readObject() as ArrayCollection;
    //close Stream
    fileStream.close();
    else
    // some sample data + save if file does not exist
    cards = new ArrayCollection();
    var card:Object = new Object();
    card.tcard = "Sample Title";
    card.mtext1 = "Sample Text";
    cards.addItem(card);
    save();

    Off topic: I noticed you are binding the label value of the renderer to the data.  It's recommended that you use the labelField property on the List instead for better performance on mobile, for example:
    <s:List  id="myCardsList" labelField="textTitle" ...>
      <s:itemRenderer>
        <fx:Component>
          <s:MobileIconItemRenderer />
        </fx:Component>
      </s:itemRenderer>
    </s:List>

  • How to get Date value from database and display them in a drop down list?

    Hello.
    In my Customers table, I have a column with Date data type. I want to create a form in JSP, where visitors can filter Customers list by year and month.
    All I know is this piece of SQL that is convert the date to the dd-mm-yyyy format:
    SELECT TO_CHAR(reg_date,'dd-mm-yyyy') from CustomersAny ideas of how this filtering possible? In my effort not to sound like a newbie wanting to be spoonfed, you can provide me link to external notes and resources, I'll really appreciate it.
    Thanks,
    Rightbrainer.

    Hi
    What part is your biggest problem?? I am not experienced in getting data out of a database, but the way to get a variable amount of data to show in a drop down menu, i have just messed around with for some time and heres how i solved it... In my app, what i needed was, a initial empty drop down list, and then using input from a text-field, users could add elements to a Vector that was passed to a JComboBox. Heres how.
    package jcombobox;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.*;
    public class Main extends JApplet implements ActionListener {
        private Vector<SomeClass> list = new Vector<SomeClass>();
        private JComboBox dropDownList = new JComboBox(list);
        private JButton addButton = new JButton("add");
        private JButton remove = new JButton("remove");
        private JTextField input = new JTextField(10);
        private JPanel buttons = new JPanel();
        public Main() {
            addButton.addActionListener(this);
            remove.addActionListener(this);
            input.addActionListener(this);
            buttons.setLayout(new FlowLayout());
            buttons.add(addButton);
            buttons.add(remove);
            add(dropDownList, "North");
            add(input, "Center");
            add(buttons, "South");
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == addButton) {
                list.addElement(new SomeClass(input.getText()));
                input.setText("");
            } else if (e.getSource() == remove) {
                int selected = dropDownList.getSelectedIndex();
                dropDownList.removeItemAt(selected);
        public void init(String[] args) {
            setSize(400,300);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(new Main());
    }And that "SomeClass" is show here
    package jcombobox;
    public class SomeClass {
        private String text;
        public SomeClass(String input) {
            text = input;
        public String toString() {
            return text;
    }One of the things i struggled a lot with was to get the dropdown menu to show some usefull result. If the list just contains class references it will show the memory code that points to that class. Thats where the toString cones in handy. But it took me some time to figure that one out, a laugh here is welcome as it should have been obvious :-)
    When the app is as simple as this one, using a <String> vector would have been easier, but this is just to demonstrate how to place classes in a vector and get some usefull info out of it, hope this answered some of your question :-)
    The layout might have been easier to write, than using the toppanel created by the JApplet and then the two additional JPanels, but it was just a small app brewed together in 15 minutes. Please comments on my faults, so that i can learn of it.
    If you need any of the code specified more, please let me know. Ill be glad to,

  • How to get data from subsites list of SharePoint 2010 in ssrs

    Hi,
    Can someone help me on this issue.
    I want to create a report using ssrs, I have some of the data in SQL and some of the data in sharepoint list.
    First I need to go to SQL and get the data from the table which contains URL for the subsite in sharepoint.
    after that I need to go to all the subsites and go to perticulat list in the subsites and get data from that list.
    for example, their is a top level site "abc"
    it contains sub site "123", "456","567", etc.. All this sub sites contain a list by name "Sample List", Now I need to go to that sub site list(Sample List) and get list-item column say "created By" which
    is created on particular date. 
    in my report, I need to print the sub site "url/Title" which comes from SQL database and list-item column  "Created By" of that sub site list "Sample List".
    I tried using subreport inside a report by using "Microsoft SharePoint List" as a datasource, but when it comes to real time we don't know how many subsites will be created, so we can't create a datasource for each subsite site.
    I guess we need to be using XML as a datasource, but how can we go to particular subsite in query while using XML, since all subsites have list with the same name ?
    I appreciate your help.
    Thank you,
    Kishore 

    Hi Kishore,
    SQL Server Reporting Services(SSRS) supports expression-based connection strings. This will help us to achieve the goal you mentioned in this case:
    Create a new report
    Create a Data Source in the report with the connection string like this:
    http://server/_vti_bin/lists.asmx (We use static connection string instead of expression-based connection string now, as it is not supported to get fields based on expression-based connection string in design time. We will change it to be expression-based
    connection string later)
    Create the data set(as you have done using XML query language). Please use list name instead of GUID in the listName parameter.
    Design the report(e.g. Add controls to the report)
    Now, let's change the connection string to be expression-based. First, please add a parameter to the report, move this parameter to top. This parameter is used to store the sub site name.
    Open the Data Source editor, set the connection string to be: ="http://server/" & Parameters!parameterCreatedInStep5.value & "_vti_bin/lists.asmx"
    In the main report, pass the sub site name to the report we created above via the parameter created in step5
    That is all.
    Anyway, this is actually a SQL Server Reporting Service(SSRS) question. You can get better support on this question from:
    http://social.technet.microsoft.com/Forums/en/sqlreportingservices/threads
    For more information about Expression-Based connection string, please see:
    http://msdn.microsoft.com/en-us/library/ms156450.aspx#Expressions
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jinchun Chen
    Jin Chen - MSFT

  • Fastest way to get data from Multiple lists across multiple site collections

    HI
    I need to get data from multiple lists which spread across 20 site collections and need to show it as list view.
    I have searched on internet about this and got some info like options would be to use search core APIs or BCS . I can't use search because I want real time data. Not sure of any other ways.
    if anybody can provide ideas it would be help.

    Might LINQ be an option for you?  Using
    LINQPad and the
    SharePoint Connector, you should be able to write a query that'll retrieve this data, from which you can tabulate it.  I'm not sure how you'd be able to automate this any further so that it's then imported in as list.
    For something more specific, I used a third party tool called the
    Lightning Tools Lightning Conductor, which is essence a powerful content roll-up tool.  In one of my solutions, I created a calculated column that gave an order / ranking on each item, so that when lists were combined, they'd still have some form of
    order.  The web part is also fairly customisable and has always proven a useful tool.
    Hope that helps.
    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles:
    CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

  • How can we get date period in out put screen as a header (PLS Urgent)

    Hi frdz,
    In ad hoc reports client want to get date field in out put screen as per selection screen date priod.
    Kindly let me know how can we get the same.
    EX: My report selection peiod is 01.01.2006 to 31.12.2006
    The same above date I want to get in out field screen header.
    Thanks,
    $ Lakshmi
    Message was edited by:
            Lakshmi

    see if this link helps http://support.apple.com/kb/ht1212
    you will probably have to restore the iphone as new.

  • Get data source schema - List tables has failed

    Hi, I am trying to expose tables from a SQL Azure Database to OData feed on power bi's data source setting and I got the following alert:
    Get data source schema - List tables and views has failed.  Please check Windows Event Log for Gateway Instance (InstanceName1) errors.
    Thanks in advance.

    Hi,
    Thank you for your question.
    I am trying to involve someone familiar with this topic to further look at this issue.
    In the meantime please have a check on the below link and check if it helps.
    http://whitepages.unlimitedviz.com/2013/09/power-bi-working-with-the-data-management-gateway/
    https://support.office.com/en-us/article/Create-a-Data-Source-and-Enable-OData-Feed-in-Power-BI-Admin-Center-9dbd3091-8961-4564-adf6-2a3aeff0b2b4?ui=en-US&rs=en-US&ad=US
    Regards,
    Mekh.

  • GET DATA tag list ?

    I'm looking for an online reference for all valid GET DATA command paramters for P1 and P2, these specify the data objects to retrieve by their tag number.
    I am working with a JCOP10 card, if there are any implementation specific tags that too would also be appreciated.
    Thanks

    I managed to solve my request.
    Goto OpenPlatform.com website there are downloadable files to document visa.openplatform.* APIs this also has the Java source of the CardManager application on the card in it.
    In the source is a list of valid P1/P2 codes and some description of what they return.
    card-tech-201 is the correct file for on for JCOP10 since its v2.0.1.
    Hope this helps someone else.
    Regards,

  • Unable to capture data from drop down list in custom added field in migo tcode at item level

    Hi guys,
    need bit help in resolving query related to custom added field in Tcode migo.
    i have added a field in migo at item level ,in this i have used drop down list
    to get data but unable to capture data from drop down list.gown through
    many blogs in scn but unable to resolve.
    Please help me out in this.
    Thanks,
    Umakant.

    Hi,
    U can use following code to fill the list box
    write this code in PBO
    In layout editor please select listbox in dropdown attribute of input field and put some fctcode attribute
    TYPE-POOLS vrm.
      DATA values TYPE vrm_values WITH HEADER LINE.
      TABLES: <ur custom Database table>.
      clear values, values[].
      SELECT * FROM <ur custom Database table>.
        values-text = <TABLE FIELD TO DISPLAY IN DROPDOWN> .
        values-key = <TABLE KEY FIELD TO DISPLAY IN DROPDOWN>.
        APPEND values.
      ENDSELECT.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = '<SCREEN INPUT FIELD NAME>'
          values          = values[]
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    Also please define the following before accessing the listbox value
    data: <listbox input field name> type <table field name>,
            <inputfield name where text to display> type string  in top include
    In PAI, select the text from the table into <inputfield name where text to display>  depending on value selected which will be called when enter key is pressed or any vale is selected

  • DropDrown unable to get data in ALV

    Hi,
    I'm trying to put an dropdown by key (or index) into an ALV but I'm unable to get data in the dropdown. Can someone please help me with this?
    I was watching this threads on topics at the forum, but I can not solve this problem.
    Copy my code.
      DATA: lr_col                            TYPE REF TO cl_salv_wd_column,
                 lr_dropdown                  TYPE REF TO cl_salv_wd_uie_dropdown_by_key,
                 l_cmp_usage                TYPE REF TO if_wd_component_usage,
                 l_alv_model                   TYPE REF TO cl_salv_wd_config_table,
                 l_ref_interfacecontroller  TYPE REF TO iwci_salv_wd_table.
      l_cmp_usage = wd_this->wd_cpuse_doc_measure( ).
      IF l_cmp_usage->has_active_component( ) IS INITIAL.
        l_cmp_usage->create_component( ).
      ENDIF.
      l_ref_interfacecontroller = wd_this->wd_cpifc_doc_measure( ).
      l_alv_model = l_ref_interfacecontroller->get_model( ).
      l_alv_model = l_ref_interfacecontroller->get_model( ).
      l_alv_model->if_salv_wd_table_settings~set_read_only( abap_false ).
      lr_col = l_alv_model->if_salv_wd_column_settings~get_column(
        id = 'VALEUR_DIFF' ).
      CREATE OBJECT lr_dropdown
        EXPORTING
          selected_key_fieldname = 'VALEUR_DIFF '.
      lr_col->set_cell_editor( lr_dropdown ).
      DATA:
      lo_nd_ctx_tab TYPE REF TO if_wd_context_node,
      lo_ndinfo_ctx_tab TYPE REF TO if_wd_context_node_info,
      lt_value_set TYPE TABLE OF wdr_context_attr_value,
      ls_value_set TYPE wdr_context_attr_value.
      ls_value_set-value = '01'.
      ls_value_set-text = 'One'.
      APPEND ls_value_set TO lt_value_set.
      ls_value_set-value = '02'.
      ls_value_set-text = 'Two'.
      APPEND ls_value_set TO lt_value_set.
      lo_nd_ctx_tab = wd_context->get_child_node( 'DOC_MEASURE' ).
      lo_ndinfo_ctx_tab = lo_nd_ctx_tab->get_node_info( ).
      lo_ndinfo_ctx_tab->set_attribute_value_set(
        name = 'VALEUR_DIFF' value_set = lt_value_set ).
      DATA: lt_valueset TYPE TABLE OF wdr_context_attr_value,
                ls_valueset TYPE wdr_context_attr_value,
                lr_node TYPE REF TO if_wd_context_node,
                lr_nodeinfo TYPE REF TO if_wd_context_node_info.
      lr_node = wd_context->get_child_node( 'DOC_MEASURE' ).
      lr_nodeinfo = lr_node->get_node_info( ).
      lr_nodeinfo->set_attribute_value_set(
      EXPORTING
        name = 'VALEUR_DIFF'
        value_set = lt_valueset
    Thanks.
    Matías.

    Hi,
    In your code, you are trying to do set_attribute_value_set twice. If you read your code carefully, you are setting the values once using lt_value_set where you have correctly filled the values. But after this, you are again trying using lt_valueset without filling any values. This is why your previous value-list gets overwritten and you see nothing in the dropdown. Remove the following lines in your code and it will work fine.
    DATA: lt_valueset TYPE TABLE OF wdr_context_attr_value,
    ls_valueset TYPE wdr_context_attr_value,
    lr_node TYPE REF TO if_wd_context_node,
    lr_nodeinfo TYPE REF TO if_wd_context_node_info.
    lr_node = wd_context->get_child_node( 'DOC_MEASURE' ).
    lr_nodeinfo = lr_node->get_node_info( ).
    lr_nodeinfo->set_attribute_value_set(
    EXPORTING
    name = 'VALEUR_DIFF'
    value_set = lt_valueset
    Please get back if you are facing any more issues.
    Regards,
    Nithya

  • Get-Date not calculating as expected

    I am trying to retrieve all the users in a specific OU of recently terminated users (who are temporarily being stored in a quarantine OU to abide by legal department's requirements to keep the mailboxes for 30 days).  Once I retrieve all the users I
    want to filter them into 3 buckets: 1) users with termination dates greater than 30 days, 2) users with term dates that are 30 days or less, 3) users with no term date listed.  Termination dates are populated into the "ExtentionAttribute7" field
    in the AD user object.  For some reason the output to a report does not correctly find the users greater than 30 and puts them all in the users less than 30 (we already corrected so that no users have empty fields).  Script is below:
    #Mail Server Variables
    $FromAddress = "[email protected]"
    $RelayMailServer = "relay.company.corp"
    $ITSupportEmailAddress = "[email protected]"
    $AdminNotifyAddress = "[email protected]"
    #Connect to Office 365
    $password = ConvertTo-SecureString "password" -AsPlainText -Force
    $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList [email protected],$password
    $s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
    $importresults = Import-PSSession $s
    $today = Get-Date -Format d
    # Define font and font size
    # ` or \ is an escape character in powershell
    $font = "<font size=`"3`" face=`"Calibri`">"
    #Headings used in the ITSupport Report
    $Title="<h1><u>Quarantined Users - Termination Ranges</h1></u><h4>Generated on " + $today + "</h4>"
    $Title_TermGreaterThan30="<h3><u>Users Have Termination Date that is 30 days or Older</h3></u>"
    $Title_TermLessThan30="<h3><u>Users Have Termination Date Less than 30 days</h3></u>"
    $Title_NoTermDate="<h3><u>Users Have No Termination Date Listed</h3></u>"
    $UsersList_TermGreaterThan30 = @()
    $UserList_TermLessThan30 = @()
    $UserList_NoTermDate = @()
    $usersUPNTermGreater30 = @()
    $usersUPNTermGreat30AD = @()
    $termDate = @()
    Get-ADUser -filter * -properties * -SearchBase 'ou=employees quarantine,dc=company,dc=corp' |
    ForEach {
    $termDate += Get-date $_.ExtensionAttribute7 -Format yyyy-MM-dd
    IF ($_.ExtensionAttribute7 -eq $null){
    #Add to User List
    $UserList_NoTermDate += $_.userprincipalname + "<br>"
    if (($_.extensionattribute7 -ne $null) -and ($termDate -lt (Get-Date).AddDays(-30)))
    #Add to UserLists
    $usersUPNTermGreater30 += $_.userprincipalname
    $usersUPNTermGreat30AD += $_.samaccountname
    $UsersList_TermGreaterThan30 += $_.userprincipalname + " " + "TermDate: " + $_.ExtensionAttribute7 + "</font> <br>"
    elseif ($_.extensionattribute7 -ne $null)
    #Add it to UserList
    $UserList_TermLessThan30 += $_.userprincipalname + " " + "TermDate: " + $_.extensionAttribute7 + "<br>"
    if (!$UsersList_TermGreaterThan30) {$UsersList_TermGreaterThan30 = "No Users to Report"}
    if (!$UserList_TermLessThan30) {$UserList_TermLessThan30 = "No Users to Report"}
    if (!$UserList_NoTermDate){$UserList_NoTermDate = "No Users to Report"}
    #Email Report to Admin
    $Subject="Quarantined Users Report for " + $today + "."
    $AdminReport = $font + $Title + $Title_TermGreaterThan30 + $UsersList_TermGreaterThan30 + $Title_TermLessThan30 + $UserList_TermLessThan30 + $Title_NoTermDate + $UserList_NoTermDate + "</font>"
    #Send-MailMessage -smtpServer $RelayMailServer -from $FromAddress -to $AdminEmailAddress -subject $Subject -BodyAsHtml -body $AdminReport
    #Send-MailMessage -smtpServer $RelayMailServer -from $FromAddress -to '[email protected]' -subject $Subject -BodyAsHtml -body $AdminReport
    Send-MailMessage -smtpServer $RelayMailServer -from $FromAddress -to '[email protected]' -subject $Subject -BodyAsHtml -body $AdminReport
    $results = @()
    ForEach ($user in $usersUPNTermGreater30){
    $results+=get-mailbox -identity $user -resultsize unlimited |`
    select UserPrincipalName }
    #Disable Litigation Hold
    Set-Mailbox -identity $user -LitigationHoldEnabled $false
    #Remove Archive Mailbox
    Disable-Mailbox -identity $user -Archive -confirm $false
    ForEach ($ADuser in $usersUPNTermGreat30AD){
    Get-ADUser $aDuser | Move-ADObject -TargetPath "OU=Employees Terminated,DC=company,DC=corp"
    If (!$usersUPNTermGreater30) { Write-Host "variable is null" }
    If ($usersUPNTermGreater30){$file = "c:\Office365\QuarantineLHDisable1.csv"}
    If ($usersUPNTermGreater30){$usersUPNTermGreater30 | Export-csv $file -NoTypeInformation}
    If($usersUPNTermGreater30){
    $msg = new-object Net.Mail.MailMessage
    $att = new-object Net.Mail.Attachment($file)
    $smtp = new-object Net.Mail.SmtpClient($RelayMailServer)
    $msg.From = "[email protected]"
    $msg.To.Add("[email protected]")
    #$msg.To.Add("[email protected]")
    $msg.Subject = "Quarantined Users Over 30 days - LH Disabled"
    $msg.Body = "Attached is the list of users who have been in the 'Employees Quarantine' OU for 30 days, where Litigation Hold and Archiving were disabled, as well as, users being moved to the Terminated OU."
    $msg.Attachments.Add($att)
    $msg.IsBodyHTML = $true
    $smtp.Send($msg)
    $att.Dispose()}
    Remove-PSSession $s
    #Clear all variables
    Clear-Variable user* -scope global
    Clear-variable term* -scope global

    I don't think that's the issue at least not all of it.  With that format switch on there...this is the $termdate output (and all the users go into the "less than 30 days" variable regardless of term date):
    PS C:\Windows\system32> $termDate
    2014-01-25
    2014-08-26
    2014-09-15
    2014-09-08
    2014-09-12
    2014-09-06
    2014-09-05
    2014-09-08
    2014-08-29
    2014-09-19
    2014-08-28
    2014-08-29
    2014-09-19
    2014-09-23
    2014-09-14
    2014-06-23
    2014-09-19
    2014-09-19
    2014-08-29
    2014-09-04
    2014-08-29
    2014-09-09
    2014-09-07
    2014-09-02
    2014-08-26
    2014-09-07
    2014-09-11
    2014-08-27
    When I take the format switch off...this is the output (and all the users go into the "greater
    than 30 days" variable regardless of term date): for $termdate:
    PS C:\Windows\system32> $termDate
    Saturday, January 25, 2014 12:00:00 AM
    Tuesday, August 26, 2014 12:00:00 AM
    Monday, September 15, 2014 12:00:00 AM
    Monday, September 08, 2014 12:00:00 AM
    Friday, September 12, 2014 12:00:00 AM
    Saturday, September 06, 2014 12:00:00 AM
    Monday, September 08, 2014 12:00:00 AM
    Friday, September 05, 2014 12:00:00 AM
    Friday, August 29, 2014 12:00:00 AM
    Friday, September 19, 2014 12:00:00 AM
    Thursday, August 28, 2014 12:00:00 AM
    Friday, August 29, 2014 12:00:00 AM
    Friday, September 19, 2014 12:00:00 AM
    Tuesday, September 23, 2014 12:00:00 AM
    Sunday, September 14, 2014 12:00:00 AM
    Monday, June 23, 2014 12:00:00 AM
    Friday, September 19, 2014 12:00:00 AM
    Friday, September 19, 2014 12:00:00 AM
    Friday, August 29, 2014 12:00:00 AM
    Thursday, September 04, 2014 12:00:00 AM
    Friday, August 29, 2014 12:00:00 AM
    Tuesday, September 09, 2014 12:00:00 AM
    Sunday, September 07, 2014 12:00:00 AM
    Tuesday, September 02, 2014 12:00:00 AM
    Tuesday, August 26, 2014 12:00:00 AM
    Sunday, September 07, 2014 12:00:00 AM
    Thursday, September 11, 2014 12:00:00 AM
    Wednesday, August 27, 2014 12:00:00 AM

Maybe you are looking for

  • Updated iTunes and QuickTime, now neither will launch

    I installed iTunes 7.1 and QT 7.1.5 tonight. Immediately after restarting, I was unable to launch Firefox 2.0.0.2 or reinstall it. In researching that problem, I've discovered I cannot launch iTunes or QT Player. With each app, the triangle appears n

  • Find tables in Stored Procedures

    Hi... Is there a way I can find the names of stored procedures where a certain table is referenced without having to look through all of them? I tried using dba_dependencies, but it did not return any rows even when I knew the table was referenced in

  • Calendar region.

    Hi, I am new to APEX. I have a requirement. I have a table for events. This has the date and event name. I would like to show a calendar and would like to show these events in cells where ever necessary. For example Thanksgiving is a holiday. I would

  • Sound from speakers sound like it's coming from a tin can

    I just bought a Toshiba Satellite L505-S5971 and the sound from the speakers sound like it's coming from a tin can.  The volume never really reaches a very loud volume even at 100%.  I've checked all of the settings for the Realteck HD Audio control

  • Only GTK apps can print, any other app (including lp) appears "held"

    The jobs are "held", have 0k size, and when I release them, they disappear. I'm using cups-usblp (as otherwise my Epson printer isn't detected) and gutenprint drivers. The relevant log lines (log level warn, and I just looked for anything suspicious)