Please assist with modifying this script to read in a list of servers and output results to excel

Hello,
I have an excellent script written by Brian Wilhite to gather the last logged in user using Powershell.
http://gallery.technet.microsoft.com/scriptcenter/Get-LastLogon-Determining-283f98ae/view/Discussions#content
My Powershell Fu is stumbling to modify this script to the following requirements:
Currently the script must be loaded first into Powershell, then it can be executed.  I would rather edit the script in my Powershell ISE, add the .txt file to the script itself that gives a list of the servers I need to scan.  Then when I
press Run Script in my ISE it executes.
I would also like to output the results of the file to excel (.xls or .csv will do).  Currently the results look as follows:
Computer : SVR01
User : WILHITE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
I would prefer it shows up like so:
Computer User SID Time Currently LoggedOn
SVR01 WILHITE\BRIAN S-1xxx 9/20/2012 1:07:58 PM FalseSRV02 WILHITE\BRIAN S-2xxx 9/26/2014 10:00:00 AM True
Any help you can provide would be greatly appreciated.  I'll add the full script to the end of this post.
Thank you.
Function Get-LastLogon
<#
.SYNOPSIS
This function will list the last user logged on or logged in.
.DESCRIPTION
This function will list the last user logged on or logged in. It will detect if the user is currently logged on
via WMI or the Registry, depending on what version of Windows is running on the target. There is some "guess" work
to determine what Domain the user truly belongs to if run against Vista NON SP1 and below, since the function
is using the profile name initially to detect the user name. It then compares the profile name and the Security
Entries (ACE-SDDL) to see if they are equal to determine Domain and if the profile is loaded via the Registry.
.PARAMETER ComputerName
A single Computer or an array of computer names. The default is localhost ($env:COMPUTERNAME).
.PARAMETER FilterSID
Filters a single SID from the results. For use if there is a service account commonly used.
.PARAMETER WQLFilter
Default WQLFilter defined for the Win32_UserProfile query, it is best to leave this alone, unless you know what
you are doing.
Default Value = "NOT SID = 'S-1-5-18' AND NOT SID = 'S-1-5-19' AND NOT SID = 'S-1-5-20'"
.EXAMPLE
$Servers = Get-Content "C:\ServerList.txt"
Get-LastLogon -ComputerName $Servers
This example will return the last logon information from all the servers in the C:\ServerList.txt file.
Computer : SVR01
User : WILHITE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
Computer : SVR02
User : WILIHTE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 12:46:48 PM
CurrentlyLoggedOn : True
.EXAMPLE
Get-LastLogon -ComputerName svr01, svr02 -FilterSID S-1-5-21-012345678-0123456789-012345678-012345
This example will return the last logon information from all the servers in the C:\ServerList.txt file.
Computer : SVR01
User : WILHITE\ADMIN
SID : S-1-5-21-012345678-0123456789-012345678-543210
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
Computer : SVR02
User : WILIHTE\ADMIN
SID : S-1-5-21-012345678-0123456789-012345678-543210
Time : 9/20/2012 12:46:48 PM
CurrentlyLoggedOn : True
.LINK
http://msdn.microsoft.com/en-us/library/windows/desktop/ee886409(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/system.security.principal.securityidentifier.aspx
.NOTES
Author: Brian C. Wilhite
Email: [email protected]
Date: "09/20/2012"
Updates: Added FilterSID Parameter
Cleaned Up Code, defined fewer variables when creating PSObjects
ToDo: Clean up the UserSID Translation, to continue even if the SID is local
#>
[CmdletBinding()]
param(
[Parameter(Position=0,ValueFromPipeline=$true)]
[Alias("CN","Computer")]
[String[]]$ComputerName="$env:COMPUTERNAME",
[String]$FilterSID,
[String]$WQLFilter="NOT SID = 'S-1-5-18' AND NOT SID = 'S-1-5-19' AND NOT SID = 'S-1-5-20'"
Begin
#Adjusting ErrorActionPreference to stop on all errors
$TempErrAct = $ErrorActionPreference
$ErrorActionPreference = "Stop"
#Exclude Local System, Local Service & Network Service
}#End Begin Script Block
Process
Foreach ($Computer in $ComputerName)
$Computer = $Computer.ToUpper().Trim()
Try
#Querying Windows version to determine how to proceed.
$Win32OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer
$Build = $Win32OS.BuildNumber
#Win32_UserProfile exist on Windows Vista and above
If ($Build -ge 6001)
If ($FilterSID)
$WQLFilter = $WQLFilter + " AND NOT SID = `'$FilterSID`'"
}#End If ($FilterSID)
$Win32User = Get-WmiObject -Class Win32_UserProfile -Filter $WQLFilter -ComputerName $Computer
$LastUser = $Win32User | Sort-Object -Property LastUseTime -Descending | Select-Object -First 1
$Loaded = $LastUser.Loaded
$Script:Time = ([WMI]'').ConvertToDateTime($LastUser.LastUseTime)
#Convert SID to Account for friendly display
$Script:UserSID = New-Object System.Security.Principal.SecurityIdentifier($LastUser.SID)
$User = $Script:UserSID.Translate([System.Security.Principal.NTAccount])
}#End If ($Build -ge 6001)
If ($Build -le 6000)
If ($Build -eq 2195)
$SysDrv = $Win32OS.SystemDirectory.ToCharArray()[0] + ":"
}#End If ($Build -eq 2195)
Else
$SysDrv = $Win32OS.SystemDrive
}#End Else
$SysDrv = $SysDrv.Replace(":","$")
$Script:ProfLoc = "\\$Computer\$SysDrv\Documents and Settings"
$Profiles = Get-ChildItem -Path $Script:ProfLoc
$Script:NTUserDatLog = $Profiles | ForEach-Object -Process {$_.GetFiles("ntuser.dat.LOG")}
#Function to grab last profile data, used for allowing -FilterSID to function properly.
function GetLastProfData ($InstanceNumber)
$Script:LastProf = ($Script:NTUserDatLog | Sort-Object -Property LastWriteTime -Descending)[$InstanceNumber]
$Script:UserName = $Script:LastProf.DirectoryName.Replace("$Script:ProfLoc","").Trim("\").ToUpper()
$Script:Time = $Script:LastProf.LastAccessTime
#Getting the SID of the user from the file ACE to compare
$Script:Sddl = $Script:LastProf.GetAccessControl().Sddl
$Script:Sddl = $Script:Sddl.split("(") | Select-String -Pattern "[0-9]\)$" | Select-Object -First 1
#Formatting SID, assuming the 6th entry will be the users SID.
$Script:Sddl = $Script:Sddl.ToString().Split(";")[5].Trim(")")
#Convert Account to SID to detect if profile is loaded via the remote registry
$Script:TranSID = New-Object System.Security.Principal.NTAccount($Script:UserName)
$Script:UserSID = $Script:TranSID.Translate([System.Security.Principal.SecurityIdentifier])
}#End function GetLastProfData
GetLastProfData -InstanceNumber 0
#If the FilterSID equals the UserSID, rerun GetLastProfData and select the next instance
If ($Script:UserSID -eq $FilterSID)
GetLastProfData -InstanceNumber 1
}#End If ($Script:UserSID -eq $FilterSID)
#If the detected SID via Sddl matches the UserSID, then connect to the registry to detect currently loggedon.
If ($Script:Sddl -eq $Script:UserSID)
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"Users",$Computer)
$Loaded = $Reg.GetSubKeyNames() -contains $Script:UserSID.Value
#Convert SID to Account for friendly display
$Script:UserSID = New-Object System.Security.Principal.SecurityIdentifier($Script:UserSID)
$User = $Script:UserSID.Translate([System.Security.Principal.NTAccount])
}#End If ($Script:Sddl -eq $Script:UserSID)
Else
$User = $Script:UserName
$Loaded = "Unknown"
}#End Else
}#End If ($Build -le 6000)
#Creating Custom PSObject For Output
New-Object -TypeName PSObject -Property @{
Computer=$Computer
User=$User
SID=$Script:UserSID
Time=$Script:Time
CurrentlyLoggedOn=$Loaded
} | Select-Object Computer, User, SID, Time, CurrentlyLoggedOn
}#End Try
Catch
If ($_.Exception.Message -Like "*Some or all identity references could not be translated*")
Write-Warning "Unable to Translate $Script:UserSID, try filtering the SID `nby using the -FilterSID parameter."
Write-Warning "It may be that $Script:UserSID is local to $Computer, Unable to translate remote SID"
Else
Write-Warning $_
}#End Catch
}#End Foreach ($Computer in $ComputerName)
}#End Process
End
#Resetting ErrorActionPref
$ErrorActionPreference = $TempErrAct
}#End End
}# End Function Get-LastLogon

 This should work:
Get-LastLogon -Computername (Get-content .\Servers.txt) | Export-CSV .\Output.csv -NoTypeInformation
I just tested it on my test domain and it did the trick.

Similar Messages

  • Please assist with installation (Adobe Reader); currently receiving installation error messages

    Please assist with Adobe Reader installation.  Currently receiving installation error messages 1) #1311 "source file not found" and 2) #13050 "raise without handler".

    Last idea I have: try using the MSI installer http://ardownload.adobe.com/pub/adobe/reader/win/11.x/11.0.00/en_US/AdbeRdr11000_en_US.msi

  • How can I modify this script to return only certain rows of my mySQL table?

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

    Hi there,
    I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
    My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
    I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
    I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
    $subscriberID = $_POST['subscriberID'];
    Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
    Any help is appreciated.
    <?php
    require_once(dirname(__FILE__) . "/2257safeDBconn.php");
    require_once(dirname(__FILE__) . "/functions.inc.php");
    require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
    * This is the main PHP file that process the HTTP parameters,
    * performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
    * and then serialize the response in an XML format.
    * XmlSerializer uses a PEAR xml parser to generate an xml response.
    * this takes a php array and generates an xml according to the following rules:
    * - the root tag name is called "response"
    * - if the current value is a hash, generate a tagname with the key value, recurse inside
    * - if the current value is an array, generated tags with the default value "row"
    * for example, we have the following array:
    * $arr = array(
    *      "data" => array(
    *           array("id_pol" => 1, "name_pol" => "name 1"),
    *           array("id_pol" => 2, "name_pol" => "name 2")
    *      "metadata" => array(
    *           "pageNum" => 1,
    *           "totalRows" => 345
    * we will get an xml of the following form
    * <?xml version="1.0" encoding="ISO-8859-1"?>
    * <response>
    *   <data>
    *     <row>
    *       <id_pol>1</id_pol>
    *       <name_pol>name 1</name_pol>
    *     </row>
    *     <row>
    *       <id_pol>2</id_pol>
    *       <name_pol>name 2</name_pol>
    *     </row>
    *   </data>
    *   <metadata>
    *     <totalRows>345</totalRows>
    *     <pageNum>1</pageNum>
    *   </metadata>
    * </response>
    * Please notice that the generated server side code does not have any
    * specific authentication mechanism in place.
    * The filter field. This is the only field that we will do filtering after.
    $filter_field = "subscriber_id";
    * we need to escape the value, so we need to know what it is
    * possible values: text, long, int, double, date, defined
    $filter_type = "text";
    * constructs and executes a sql select query against the selected database
    * can take the following parameters:
    * $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
    * $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
    * $_REQUEST["filter"] - the filter value
    * $_REQUEST["pageNum"] - the page index
    * $_REQUEST["pageSize"] - the page size (number of rows to return)
    * if neither pageNum and pageSize appear, we do a full select, no limit
    * returns : an array of the form
    * array (
    *           data => array(
    *                array('field1' => "value1", "field2" => "value2")
    *           metadata => array(
    *                "pageNum" => page_index,
    *                "totalRows" => number_of_rows
    function findAll() {
         global $conn, $filter_field, $filter_type;
          * the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
         $fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         $order = "";
         if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
              $order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //get the page number, and the page size
         $pageNum = (int)@$_REQUEST["pageNum"];
         $pageSize = (int)@$_REQUEST["pageSize"];
         //calculate the start row for the limit clause
         $start = $pageNum * $pageSize;
         //construct the query, using the where and order condition
         $query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
         //if we use pagination, add the limit clause
         if ($pageNum >= 0 && $pageSize > 0) {     
              $query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
         $recordset = mysql_query($query_recordset, $conn);
         //if we have rows in the table, loop through them and fill the array
         $toret = array();
         while ($row_recordset = mysql_fetch_assoc($recordset)) {
              array_push($toret, $row_recordset);
         //create the standard response structure
         $toret = array(
              "data" => $toret,
              "metadata" => array (
                   "totalRows" => $totalrows,
                   "pageNum" => $pageNum
         return $toret;
    * constructs and executes a sql count query against the selected database
    * can take the following parameters:
    * $_REQUEST["filter"] - the filter value
    * returns : an array of the form
    * array (
    *           data => number_of_rows,
    *           metadata => array()
    function rowCount() {
         global $conn, $filter_field, $filter_type;
         $where = "";
         if (@$_REQUEST['filter'] != "") {
              $where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);     
         //calculate the number of rows in this table
         $rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
         $row_rscount = mysql_fetch_assoc($rscount);
         $totalrows = (int) $row_rscount["cnt"];
         //create the standard response structure
         $toret = array(
              "data" => $totalrows,
              "metadata" => array()
         return $toret;

  • Can someone please assist me. I was given an iPod 3G as a gift and I tried to download various apps and it told me that my iPod needs to be iOS 7 or more but I checked and my iPod is at its latest upgrade which is 6.1.6, how can I get those app?

    Can someone please assist me. I was given an iPod 3G as a gift and I tried to download various apps and it told me that my iPod needs to be iOS 7 or more but I checked and my iPod is at its latest upgrade which is 6.1.6, how can I get those app?

    See a a version compable with your iPod is available:
    Starting when iOS 7 was released, Apple now allows downloading the last compatible version of some apps (iOS 4.2.1 and later only)
    App Store: Downloading Older Versions of Apps on iOS - Apple Club
    App Store: Install the latest compatible version of an app
    You first have to download the non-compatible version on your computer. Then when you try to purchase the version on your iPod you will be offered a compatible version if one exists.
    Also, if you have iOS 6.1.6 yo have a 4G (has cameras). A 3G does not have cameras and can only go to 5.1.1

  • I have 2 laptops both with iTunes installed but on one my source list includes 'Movies' and the other 'films' does anyone know why this would be?

    i have 2 laptops both with iTunes installed but on one my source list includes 'Movies' and the other 'films' does anyone know why this would be?

    sorry all - disregard I've identified the issue in the language settings with one set to 'English - United States' and one to 'English - United Kingdom' - now fixed.
    Cheers

  • Script needed to generate a list of paragraph and character styles from the Book Level

    Hello,
    I am using FrameMaker 11 in the Adobe Technical Communication Suite 4 and I need to find a script that will generate a list
    of paragraph and character styles from the book level.
    I am working with unstructured FrameMaker books, but will soon be looking at getting a conversion table developed
    that will allow me to migrate all my data over to Dita (1.1 for now).
    Any thoughts, ideas on this is very much appreciated.
    Regards,
    Jim

    Hi Jim,
    I think the problem you are having with getting a response is that you are asking someone to write a script for you. Normally, you would have to pay someone for this, as it is something that folks do for a living.
    Nonetheless, I had a few minutes to spare, so I worked up the following script that I believe does the job. It is very slow, clunky, and totally non-elegant, but I think it works. It leverages the book error log mechanism which is built in and accessible by scripts, but is spendidly unattractive. I hope this gives you a starting point. It could be made much more beautiful, of course, but such would take lots more time.
    Russ
    ListAllFormatsInBook()
    function ListAllFormatsInBook()
        var doc, path, fmt;
        var book = app.ActiveBook;
        if(!book.ObjectValid()) book = app.FirstOpenBook;
        if(!book.ObjectValid())
            alert("No book window is active. Cannot continue.");
            return;
        CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
        CallErrorLog(book, 0, 0, "** Book format report for:");
        CallErrorLog(book, 0, 0, book.Name);
        var comp = book.FirstComponentInBook;
        while(comp.ObjectValid())
            path = comp.Name;
            doc = SimpleOpen (path, false);
            if(doc.ObjectValid())
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, doc, 0, "");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "Paragraph formats:");
                fmt = doc.FirstPgfFmtInDoc;
                while(fmt.ObjectValid())
                    CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                    fmt = fmt.NextPgfFmtInDoc;
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "Character formats:");
                fmt = doc.FirstCharFmtInDoc;
                while(fmt.ObjectValid())
                    CallErrorLog(book, 0, 0, "  - " + fmt.Name);
                    fmt = fmt.NextCharFmtInDoc;
            else
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
                CallErrorLog(book, 0, 0, "!!!  Could not open: " + comp.Name + " !!!");
                CallErrorLog(book, 0, 0, "-----------------------------------------------------------");
            comp = comp.NextComponentInBook;
    function CallErrorLog(book, doc, object, text)
        var arg;
        arg = "log ";
        if(book == null || book == 0 || !book.ObjectValid())
            arg += "-b=0 ";
        else arg += "-b=" + book.id + " ";
        if(doc == null || doc == 0 || !doc.ObjectValid())
            arg += "-d=0 ";
        else arg += "-d=" + doc.id + " ";
        if(object == null || object == 0 || !object.ObjectValid())
            arg += "-O=0 ";
        else arg += "-O=" + object.id + " ";
        arg += "--" + text;
        CallClient("BookErrorLog", arg);

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • Is it possible to modify this script to include subfolders?

    I have tried to do this with no luck. This script works great, but how to I make it apply to all sub-folders? Thanks for any suggestions.
    #target bridge  
    if( BridgeTalk.appName == "bridge" ) { 
    descToTitle = MenuElement.create("command", "Keys to Title", "at the end of Tools");
    descToTitle.onSelect = function () {
    if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
    var thumb = app.document.selections;
        for(var s in thumb){
    if(thumb[s].hasMetadata){
            var selectedFile = thumb[s].spec;
      var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
      var myXmp = myXmpFile.getXMP();
             var Description =  getArrayItems(XMPConst.NS_DC, "keywords");
            myXmp.deleteProperty(XMPConst.NS_DC, "title");
            myXmp.appendArrayItem(XMPConst.NS_DC, "title", Description, 0, XMPConst.ALIAS_TO_ALT_TEXT);
            myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
    function getArrayItems(ns, prop){
    var arrItem=[];
    try{
    var items = myXmp.countArrayItems(ns, prop);
    for(var i = 1;i <= items;i++){
    arrItem.push(myXmp.getArrayItem(ns, prop, i));
    return arrItem;
    }catch(e){alert(e +" Line: "+ e.line);}
            if (myXmpFile.canPutXMP(myXmp)) {
            myXmpFile.putXMP(myXmp);
            myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
             } else {
      xmpFile.closeFile();

    I have done that, but for some reason that feature is not working in my copy of Bridge.
    Not to mention, I need to do this on thousands of images. That is why the subfolder feature would be helpful.
    However, I also thought about creating a collection with all of the images in it.

  • Modify this script for Time, not Date?

    I'm a complete newbie to scripting.  And I thought HTML was tough to pick up!
    I have this script-- apparently the only one I could find that comes close to what I need.
    // get new Date object
    var d = new Date();
    // format to mm/dd/yyyy
    var sDate = util.printd("mm/dd/yyyy", d);
    // insert date into form field
    this.getField("todaysDate").value = sDate;
    I need a script to perform this exact same operation but with the current system time (or MDT, that's fine).  I tried swapping out 'Date' for 'Time' but no go.  Anybody can help? 
    Much appreciated...
    -carrie

    Are you creating your form in Acrobat or LiveCycle Designer.
    For Acrobat forms:
    You can get a lot of different information from the date object by changing the format string for the 'util.printd' method. See the reference George Johnson links to for the format string values that can change the displayed value.
    // get new Date object
    var d = new Date();
    // format to h:MM tt
    var sDate = util.printd("h:MM tt", d);
    // insert date into form field
    this.getField("todaysDate").value = sDate;
    h - hours without leading zero
    MM - minutes with leading zero if necessary
    tt - am or pm designator
    For LiveCycle Designer you can select the 'Custom' form tab and then the 'Current Date' field. Now change the script to:
    $.rawValue
    = num2Time(time(), TimeFmt(1))
    More information about the time format is the 'Scripting Reference' under LiveCycle Designer's 'Help' menu option.

  • I got Iphone 5 on Nov 3rd, but sadly my text massage is not working, I can't send and recieve any text. Would you please assist me in this matter.

    My Iphone 5 is not sending nor recieving any text massage, Please help me in this problem.

    call your carrier.

  • Shell scripts to read data from a text file and to load it into a table

    Hi All,
    I have a text file consisting of rows and columns as follows,
    GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001
    GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001
    GEF001 000093625 MKL005675 000001 000000 000000 000000 000000 000000 000001 My requirement is that, i should read the first 3 columns of this file using a shell script and then i have to insert the data into a table consisting of 3 rows in oracle .
    the whole application is deployed in unix and that text file comes from mainframe. am working in the unix side of the application and i cant access the data directly from the mainframe. so am required to write a script which reads the data from text file which is placed in certain location and i have to load it to oracle database.
    so I can't use SQL * loader.
    Please help me something with this...
    Thanks in advance.

    1. Create a dictionary object in Oracle and assign it to the folder where your file resides
    2. Write a little procedure which opens the file in the newly created directory object using ULT_FILE and inside the FOR LOOP and do INSERTs to table you want
    3. Create a shell script and call that procedure
    You can use the post in my Blog for such issues
    [Using Oracle UTL_FILE, UTL_SMTP packages and Linux Shell Scripting and Cron utility together|http://kamranagayev.wordpress.com/2009/02/23/using-oracle-utl_file-utl_smtp-packages-and-linux-shell-scripting-and-cron-utility-together-2/]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com

  • Need helpcreating a script to read the name of a folder and adding that name into the permissions of that folder

    Need help creating a script to read the name of a folder (which is the AD Username) and adding that name into the permissions of that folder.
    I have over 100 folders which I need to add the AD user to read and write to their own folder
    Hope you guys understand what I mean

    Just to add, Mac in intergrated into AD and all I need is help in creating the script
    Thanks

  • How to call a SP with dynamic columns and output results into a .csv file via SSIS

    hi Folks, I have a challenging question here. I've created a SP called dbo.ResultsWithDynamicColumns and take one parameter of CONVERT(DATE,GETDATE()), the uniqueness of this SP is that the result does not have fixed columns as it's based on sales from previous
    days. For example, Previous day, customers have purchased 20 products but today , 30 products have been purchased.
    Right now, on SSMS, I am able to execute this SP when supplying  a parameter.  What I want to achieve here is to automate this process and send the result as a .csv file and SFTP to a server. 
    SFTP part is kinda easy as I can call WinSCP with proper script to handle it.  How to export the result of a dynamic SP to a .CSV file? 
    I've tried
    EXEC xp_cmdshell ' BCP " EXEC xxxx.[dbo].[ResultsWithDynamicColumns ]  @dateFrom = ''2014-01-21''"   queryout  "c:\path\xxxx.dat" -T -c'
    SSMS gives the following error as Error = [Microsoft][SQL Server Native Client 10.0]BCP host-files must contain at least one column
    any ideas?
    thanks
    Hui
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

    Hey Jakub, thanks and I did see the #temp table issue in our 2008R2.  I finally figured it out in a different way... I manage to modify this dynamic SP to output results into
    a physical table. This table will be dropped and recreated everytime when SP gets executed... After that, I used a SSIS pkg to output this table
    to a file destination which is .csv.  
     The downside is that if this table structure ever gets changed, this SSIS pkg will fail or not fully reflecting the whole table. However, this won't happen often
    and I can live with that at this moment. 
    Thanks
    --Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

  • How to i write a script that makes multiple selections in a pdf and exports them to excel?

    I have a large number of PDFs
    Not all the PDFs contain information we need. We want to be able to automate a script that extracts certain info from the PDFs and opens them in a certain format in excel.
    Acrobat allows me to make a single selection and export as excel.
    How do i export multiple parts to excel from the pdfs and ensure that the resulting excel is in a format that i can use without much fixing needed (e.g. merged cells)?

    This type of process can't really be done using JavaScript. You would need to read the contents of the file, word by word, decide (based on some logic) what data to extract, and then collect it and at the end export to a plain-text file. Not a simple process...

  • Please help me with modifying this code

    I am using the attached code to acauire and save data to a text file, using 'write measurement file' express VI.
    WHat I want to do is to replace 'write to measurement VI' with low-level file I/O VIs. I tried to convert the express VI, but the obtained code is too complicated.
    Anyone can give me hints for using file I/O Vis to implement same function without using the express VI? Thanks a lot.
    Message Edited by Dejun on 08-27-2007 11:26 AM
    Attachments:
    4.png ‏14 KB
    code.vi ‏121 KB

    Above code is in a case of an event structure, i.e., each time I click a buttom, such as 'RUN', data acquisition begins and write data into a file.
    What I want is, each time this event case is executed, a file is open, write data to it, and finally close this file. The next time when I run this case, maybe another file is open for writting data.
    The problem of using 'write measure file' express VI is: if a file is open in one execution of the case, it will continuously be in 'open' after this case execution is finished, i.e., there is no explicit close file function with the express VI, which in some cases may be a problem. What I need is closing the file at the end of each execution of a event case. With low-level file I/O VIs, maybe I can directly put a close file VI there.
    The data file should be in text format so that data analysis software, such as MS-powerpoint, can directly reads it.
    Message Edited by Dejun on 08-27-2007 01:55 PM
    Message Edited by Dejun on 08-27-2007 01:56 PM

Maybe you are looking for

  • PDF problems in Acrobat 9 Pro

    PDF problems in Acrobat 9 Pro I'm using windows 7, 64 bit version What can be the cause of dots, where underground otherwise white appearance with small black dots. They do not come with the pressure. but is rather confusing. Mox PDF problems in Acro

  • Load multiple images from directory?

    What is the best way to use CF to load multiple images from a server directory please? I have CF calling a stored procedure that returns an array of file names. I am using a Flex front end, and wonder if I should just pass the file name array to Flex

  • Is there a free Remote JFileChooser?

    Hello, Does anybody know if there is code for a free Remote JFileChooser? (that would be of great help and save the effort of reinventing the wheel) thanks, Anil

  • Need help modifying Applescript to copy "Spotlight Comments" into file

    Hello all, I have a very large batch of images of Leonardo da Vinci's notebooks. I used the "Spotlight Comments" field of each file to save information about the notebook page depicted in each image: Well, I had to modify each image in Photoshop and

  • UDDI sample clinet not setting the wsdl location

    Hi I am using the uddi PublishService2UDDI.java of dev2dev and am trying to register a deployed service with a name and a wsdl url location. The program runs successfully and registers the service but the "overview url" where the wsdl url is supposed