Powershell script assistance - adding another property to existing script

This is not my script but was written by Richard L. Mueller. It works perfectly for us but I would like to know if the account is enabled or disabled when the output is created. Basically it would output the name, lastlogon and then either enabled or disabled.
I've attempted to add a new property by adding another " $Searcher.PropertiesToLoad.Add" and "$Result.Properties.Item ".
It works fine if I add something like "givenName" but I can't find the property name to show if the account is enabled or disabled.
The entire script is shown below:
# PSLastLogon.ps1
# PowerShell script to determine when each user in the domain last
# logged on.
# Copyright (c) 2011 Richard L. Mueller
# Hilltop Lab web site - http://www.rlmueller.net
# Version 1.0 - March 16, 2011
# This program queries every Domain Controller in the domain to find the
# largest (latest) value of the lastLogon attribute for each user. The
# last logon dates for each user are converted into local time. The
# times are adjusted for daylight savings time, as presently configured.
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the copyright owner above has no warranty, obligations,
# or liability for such use.
Trap {"Error: $_"; Break;}
$D = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$Domain = [ADSI]"LDAP://$D"
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.PageSize = 200
$Searcher.SearchScope = "subtree"
$Searcher.Filter = "(&(objectCategory=person)(objectClass=user))"
$Searcher.PropertiesToLoad.Add("distinguishedName") > $Null
$Searcher.PropertiesToLoad.Add("lastLogon") > $Null
# Create hash table of users and their last logon dates.
$arrUsers = @{}
# Enumerate all Domain Controllers.
ForEach ($DC In $D.DomainControllers)
$Server = $DC.Name
$Searcher.SearchRoot = "LDAP://$Server/" + $Domain.distinguishedName
$Results = $Searcher.FindAll()
ForEach ($Result In $Results)
$DN = $Result.Properties.Item("distinguishedName")
$LL = $Result.Properties.Item("lastLogon")
If ($LL.Count -eq 0)
$Last = [DateTime]0
Else
$Last = [DateTime]$LL.Item(0)
If ($Last -eq 0)
$LastLogon = $Last.AddYears(1600)
Else
$LastLogon = $Last.AddYears(1600).ToLocalTime()
If ($arrUsers.ContainsKey("$DN"))
If ($LastLogon -gt $arrUsers["$DN"])
$arrUsers["$DN"] = $LastLogon
Else
$arrUsers.Add("$DN", $LastLogon)
# Output latest last logon date for each user.
$Users = $arrUsers.Keys
ForEach ($DN In $Users)
$Date = $arrUsers["$DN"]
"$DN;$Date"

It is part of the userAccountControl attribute. Retrieve that attribute for each user and test if the ADS_UF_ACCOUNTDISABLE bit (2) is set.
-- Bill Stewart [Bill_Stewart]

Similar Messages

  • Added another subscriber to existing publication. Snapshot delivered but ket re-initializing if Distribution agent is restarted

    Hi,
    Here is the situation. We have existing replication with sql 2008 r2 publisher and a subscriber on same edition. The database is quite big so snapshot generally takes about 4 hours or more. There are additional tables on subscriber so a backup / restore
    mode of initialization is not suitable.
    This replication is working just fine, now there is a need to add a sql 2014 subscriber to this publisher and same tables as in current publication, so we decided to simply add another push subscription for this new sql 2014 subscriber. During the process
    the Initial snapshot is generated and applied to new 2014 subscribe, keep in mind we have not made any change to publication to avoid affecting the existing subscriber. So when snapshot is delivered and appeared in replication monitor it started creating primary
    keys on subscriber database. We have few big tables where we are not sending clustered and non clustered indexes across so that replication snapshot goes fast (although it is over 4 hours). These indexes and primary keys get created with manual scripts after
    snapshot is generated. During this time log reader agent has been actively sending transactions to existing subscriber that is telling me that as soon as distribution agent done with the snapshot it will start sending transactions to new subscriber (which
    is quite normal). Now the problem, after snapshot is done I need to run manual scripts to create PK and indexes on new subscriber, to do that I have to stop distribution agent so that indexes and PKs don't get blocked. After I stopped distrib
    agent temporarily, the Scripts got completed successfully within 20 minutes and when I re-started distribution agent , to my surprise it started initializing the new subscriber again and sending same snapshot that was already applied. It make me puzzled
    what caused the distribution agent to reinitialize although it already delivered snapshot and I have indexes created and ready to go. I tried this process again with more careful approach and gave about one hour after snapshot delivered message received. but
    it did the same thing.  Only explanation I can think of that publisher database is actively sending transactions when I was applying snapshot and as soon as it is delivered, the distribution agent started delivering transaction, I could see Undistributed
    Commands kept on growing high telling me that there are lots of transactions for new subscriber to catch up but without indexes and some missing primary keys it would not even catch up and so I always stop the distrib agent and run my scripts on subscriber
    and run into this situation. During all these times the existing subscriber never had any issue.
    Do I need to make sure no ort minimal transactions happening on publisher when I initialize the new subscriber.
    Or should I create new separate publication on the same publisher and use that.
    Any other suggestions are welcome
    Thanks!
    dba60

    Snapshot was set of initialize immediately.  No errors in repl_errors table.  Distribution agent was using default profile.
    Do you think that I should be running missing PK and indexing scripts as part of replication, replication provides an option run scripts before or after snapshot was applied. Also, I am wondering if creating some missing PKs is triggering the snapshot to
    be reapplied. Also, Why the primary key for some tables not coming along during snapshot delivery? 
    Do you think having lots of transactions on publisher database while snapshot being applied would be affecting it too?
    Also, is it possible to use a different distributors for each publication from same publisher?
    My plan now is to create new publication for same publisher and database, this way I will have more control over changing article properties.
    Thanks!
    dba60

  • Adding another Cluster into existing CSS LB

    Hi,
    Im in the process of adding a new cluster into the existing LB. I understand the concept of configuring a new LB but adding a new network to it is a question.
    I have preconfigured the LB with a new service called SPWeb 1-4 and an assign this to the content owner Central_Platform using VLAN 144 and 145.
    I have one physical connection to the PIX and all port on the PIX is taken. Do I have to setup another physical connection for the new server SPWeb to the PIX?
    Both owners Servcorp and Central_Platform are using separate public IP Subnets.
    Also, please advise if I miss anything and if you have any suggestions.
    Thansks
    !************************* INTERFACE *************************
    interface 1/1
    bridge vlan 200
    interface 2/1
    phy 100Mbits-FD
    description "To PIX"
    bridge vlan 300
    interface 2/2
    phy 100Mbits-FD
    description "To LB switches"
    bridge vlan 301
    interface 2/3
    phy 100Mbits-FD
    bridge vlan 303
    description "Management"
    interface 2/4
    phy 100Mbits-FD
    bridge vlan 144
    description "SPWeb1/2"
    interface 2/5
    phy 100Mbits-FD
    bridge vlan 145
    description "SPWeb3/4"
    !************************** CIRCUIT **************************
    circuit VLAN1
    ip address 192.168.10.1 255.255.255.0
    circuit VLAN300
    ip address (Network 1) 255.255.255.0
    circuit VLAN301
    ip address (Network 1) 255.255.255.0
    circuit VLAN303
    ip address (Network 1) 255.255.255.0
    circuit VLAN144
    ip address (Network 2) 255.255.255.0
    circuit VLAN145
    ip address (Network 2) 255.255.255.0
    !************************** SERVICE **************************
    service TS1
    ip address 172.16.250.1
    active
    service TS2
    ip address 172.16.250.2
    active
    service Spweb1
    ip address 172.16.144.51
    keepalive type HTTP
    active
    service Spweb2
    ip address 172.16.144.52
    keepalive type HTTP
    active
    service Spweb3
    ip address 172.16.145.53
    keepalive type HTTP
    active
    service Spweb4
    ip address 172.16.145.54
    keepalive type HTTP
    active
    !*************************** OWNER ***************************
    owner Servcorp
    content hottdesk.au
    add service TS1
    add service TS2
    protocol tcp
    port 3389
    vip address (Network 1)
    active
    content hottdesk_FTP
    add service TS1
    add service TS2
    port 20
    protocol tcp
    vip address (Network 1)
    active
    content hottdesk_FTP2
    add service TS1
    protocol tcp
    port 21
    application ftp-control
    add service TS2
    vip address (Network 1)
    active
    owner Central_Platform
    content WebServers_1
    add service Spweb1
    add service Spweb2
    protocol tcp
    port 90
    vip address (Network 2)
    active
    content WebServers_2
    add service Spweb3
    add service Spweb4
    protocol tcp
    port 81
    vip address (Network 2)
    active
    content WebServers_3
    add service Spweb3
    add service Spweb4
    protocol tcp
    port 83
    vip address (Network 2)
    active
    !*************************** GROUP ***************************
    group TS-WebAccess
    add service TS2
    add service TS1
    vip address (Network 1)
    active

    It would help if you could attach a picture of the network. I really can't understand why you have 2 VLANs on the same network ? Or am I missing the ide ?
    Generally I would just do VLAN tag towards the PIX and have several networks that way. If speed isn't a issue I see no problems with that.

  • Adding Extended Property to existing appointment with EWS

    Hi,
    Is it possible to update an existing appointment in Exchange which doesn't have an extended property assigned to it?
    This is my code currently:
    Dim def As New ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "AppointmentID", MapiPropertyType.String)
    Dim updatedAppointment As Appointment = Appointment.Bind(service, a.Id, New PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, def))
    Dim oldSubject As String = updatedAppointment.Subject
    If UpdateExchAppt Then
    updatedAppointment.SetExtendedProperty(def, appt.Appointment_ID.ToString())
    updatedAppointment.Update(ConflictResolutionMode.AlwaysOverwrite)
    Else
    updatedAppointment.SetExtendedProperty(def, appt.Appointment_ID.ToString())
    updatedAppointment.Save(SendInvitationsMode.SendToNone)
    End If
    Thanks!

    Yes your code should work okay if it isn't what is the issue your having ? Eg that code would only update the property on the Calendar your running the code. To updates all attendees you should need to send an update to all the Attendees of the meeting
    Cheers
    Glen

  • Need assistance adding another search engine

    I have an iMAC.
    I am satisfied with Safari, but want the flexibility to use an additional search engine at the same time.
    How can I set up my computer so I have the ability to surf with another  internet service provider (ex. explorer, google chrome) while I am using Safari?
    Thanks,
    Steve

    Dear  Rudegar,
    Thank you for prompt reply, and I apologize for not asking a technically correct question.  
    I am currently streaming music through the Internet using Safari.
    I want to steam another recording (at the same time), and was told I need to access another browser  in order to perform this function.
    Judging by your reply, I think the  answer is "Maybe - but I need to check out https://extensions.apple.com" to see if this is feasible.
    Did I ask the question more clearly?  Did I understand your response?
    Thanks,

  • Is it possible Adding another 2 harddrive sas 2.5' hot plug on existing raid 1 ????

    Dear All,
    I have HP ML370 G6 with 2 harddrives sas 2.5' 300GB hotplug on raid 1.
    And it is almost runout space. I have plan to adding another 2 harddrive with same type.
    Is is possible to add another harddrive on raid 1 without change or re-install the operating system installed ??
    My operating system is Redhat  Enterprise Linux 4 (RHEL 4) and oracle database inside.
    Please I need your suggest and advise, what should I do to add more space on existing raid 1.
    Thank You,
    breakthelimit

    There is no BIOS in OS X. There is only the EFI stored in ROM that is not user modifiable. OS X is probably checking Bay 0 for the boot drive since that is where it should be. It won't check the Tempo drive since it is treated like an external drive. I suggest you open Startup Disk preferences to see if the Tempo device is selected as the boot device. If it isn't, then select it. That will probably shave off a few seconds in the startup time.

  • Modifying existing script - modifying how data is written out to csv

    I have an existing script written in Powershell 3.0 that gathers data from my virtual machines.  It's working to give me the data, but I'd like to modify how it writes it out.  Currently the data looks as follows:
    I would prefer the output to be all one one line as follows:
    Here is my script.  How would I modify this to give me the .csv file with all data for each server on one line?
    #param (
    $inputFile = "C:\Apps\Powershell\IP_Mac\testlist.txt"
    $csvFile = "C:\Apps\Powershell\IP_Mac\results.csv"
    $report = @()
    foreach($Computer in (gc -Path $inputFile)){
    get-wmiobject -computer $Computer win32_logicaldisk -filter "drivetype=3" | ForEach-Object {
    $device = $_.deviceid
    $freespce = ($_.freespace/1GB).tostring("0.00")+"GB"
    $Totalspce = ($_.size/1GB).tostring("0.00")+"GB"
    if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
    foreach ($Network in $Networks) {
    $IPAddress = $Network.IpAddress[0]
    $SubnetMask = $Network.IPSubnet[0]
    $DefaultGateway = $Network.DefaultIPGateway
    $DNSServers = $Network.DNSServerSearchOrder
    $MACAddress = $Network.MACAddress
    $OutputObj = New-Object -Type PSObject
    $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
    $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
    $OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value ($DefaultGateway -join “,”)
    $OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value ($DNSServers -join ",")
    $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name device -Value $device
    $OutputObj | Add-Member -MemberType NoteProperty -Name Totalspce -Value $Totalspce
    $OutputObj | Add-Member -MemberType NoteProperty -Name freespce -Value $freespce
    #$OutputObj
    $report += $OutputObj
    Write-Output $report
    $report | Select-Object -Property $properties | Export-Csv -Path $csvFile -NoTypeInformation
    Thank you.

    Try it like this:
    #param (
    $inputFile = "C:\Apps\Powershell\IP_Mac\testlist.txt"
    $csvFile = "C:\Apps\Powershell\IP_Mac\results.csv"
    $report = foreach($Computer in (gc -Path $inputFile)){
    $devices = get-wmiobject -computer $Computer win32_logicaldisk -filter "drivetype=3" | ForEach-Object {
    $device = $_.deviceid
    $freespce = ($_.freespace/1GB).tostring("0.00")+"GB"
    $Totalspce = ($_.size/1GB).tostring("0.00")+"GB"
    New-Object PSObject -property @{device=$device;freespce=$freespce;Totalspce=$Totalspce}
    if(Test-Connection -ComputerName $Computer -Count 1 -ea 0) {
    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | ? {$_.IPEnabled}
    foreach ($Network in $Networks) {
    $IPAddress = $Network.IpAddress[0]
    $SubnetMask = $Network.IPSubnet[0]
    $DefaultGateway = $Network.DefaultIPGateway
    $DNSServers = $Network.DNSServerSearchOrder
    $MACAddress = $Network.MACAddress
    $OutputObj = New-Object -Type PSObject
    $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
    $OutputObj | Add-Member -MemberType NoteProperty -Name IPAddress -Value $IPAddress
    $OutputObj | Add-Member -MemberType NoteProperty -Name SubnetMask -Value $SubnetMask
    $OutputObj | Add-Member -MemberType NoteProperty -Name Gateway -Value ($DefaultGateway -join “,”)
    $OutputObj | Add-Member -MemberType NoteProperty -Name DNSServers -Value ($DNSServers -join ",")
    $OutputObj | Add-Member -MemberType NoteProperty -Name MACAddress -Value $MACAddress
    $i = 0
    Foreach ($dev in $devices) {
    $OutputObj | Add-Member -MemberType NoteProperty -Name device$i -Value $dev.device
    $OutputObj | Add-Member -MemberType NoteProperty -Name Totalspce$i -Value $dev.Totalspce
    $OutputObj | Add-Member -MemberType NoteProperty -Name freespce$i -Value $dev.freespce
    $i ++
    $OutputObj
    Write-Output $report
    $report | Select-Object -Property $properties | Export-Csv -Path $csvFile -NoTypeInformation
    You were writing a row for each drive, I basically just wrote the drive information to an array and looped through that array when adding members.  I tested this and it worked for me.  Note that you can't have the same value names when you add-member
    so I appended a numeral to differentiate them.
    I hope this post has helped!

  • Adding another Verizon router....

    I currently have FIOS installed at my home.  I have my wireless router installed on the main level in my home.  The wireless signal is great on the main level and upstairs, but the signal in the basement varies from good to low.  I am looking for a solution that will allow for either better signal strength or adding another router in the basement that connects to my existing FIOS line.  This would also require adding a phone line in the basement as well...unfortunately the previous owner of my home did not have lines put in the basement.
    At any rate, can someone assist with this solution.  Thanks in advance

    If running an Ethernet aconenction from the Current Router to the Baement is not an option you can get another FIOS Router and connect it to the COAX Cabling in your house.  It has to be configured properly and information can be found here:
    http://www.dslreports.com/faq/verizonfios/3.0_Networking#15984
    Keep the SSID the same and put the 2nd router on a diffent channel from the 1st.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it.
    If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • Problem with existing script, can't get text of item

    I'm taking an earlier script and condensing it so that it will only work from one SELECTED folder. I thought it would be simple but i seam to be running into a few issues
    This is the error I get
    Result:
    error "Can’t get last text item of alias \"Images:2012-2013:WK21:Freedom:Freedom_WK21_PSD:\"." number -1728 from last text item of alias "Images:2012-2013:WK21:Freedom:Freedom_WK21_PSD:"
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Below is what I removed
    --set dtF to paragraphs of (do shell script "ls -F ~/Desktop | grep '/' | cut -d'/' -f1")
    --set tc to (count dtF)
    --repeat with i from 1 to tc
    --          set folderName to item i of dtF --<:  is the folder name, no need to use text item delimiters -->":"
    --          if folderName does not start with "2_" and folderName does not start with "Hot" and folderName does not start with "Press" and folderName does --not start with "Design" and folderName does not start with "Keywords" and folderName does not start with "Season" and folderName does not
    --start with "Sue" and folderName does not start with "Design" then
    --Setup list of folders and process details of folders
    tell application "Finder" to set folderName to (choose folder with prompt "Select Folder")
    set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
    set FolderEndName to last text item of folderName
    set brandName to first text item of folderName
    set my text item delimiters to "_PSD"
    set weekNumber to first text item of FolderEndName
    set my text item delimiters to oldTID
    set theFolder to ("Hal 9000:Users:matthew:Desktop:" & folderName)
    --set up names to destination folders and create locally based on brand name and week number
    set this_local_folder to "Images:2012-2013"
    set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
    set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
    set localBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", localBrandFolder)
    set localBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", localBrandFolder)
    set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
    set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
    set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
    set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
    set website_images to "DCKGEN:Website_Images:"
    --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
    set this_ftp_folder to "Impulse:"
    set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
    set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
    set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
    set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
    --taking the folder identify which process it must follow.  F R E E D O M   W I T H  P N G
    if brandName is equal to "Freedom" then
              try
                        tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
              on error
                        set o's theseNames to {} -- no psd files or "8BPS"
              end try
              set numOfNames to (count o's theseNames)
              repeat with j from 1 to numOfNames
                        set thefile to theFolder & ":" & (item j of o's theseNames)
      --    F R E E D O M     Folder Photoshop Process W I T H  P N G
                        set thisName to (item j of o's theseNames)
                        tell application "Finder"
                                  set t_ext to name extension of file thefile
                                  if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                  set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                        end tell
                        if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                  tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                            set ruler units of settings to pixel units
                                            try
      open (alias thefile) showing dialogs never
                                                      set origName to name of current document
                                                      set myOptions to {class:JPEG save options, quality:12}
                                                      set myPNGOptions to {class:PNG save options, interlaced:false}
                                                      set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                      tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                if (quick mask mode) then delete channel ¬
                                                                          "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                if (exists layer "Original Layer") then ¬
                                                                          tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                set current history state to history state 3
      delete current layer
      merge visible layers
                                                                resize image width 1020
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as PNG with options myPNGOptions without copying
      flatten
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                set newFile to file path
                                                                set newFile2 to newFile as string -- for testing end of name
                                                                if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                          my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                else
                                                                          save in (website_images & name) as JPEG with options myOptions without copying
                                                                end if
      close saving no
                                                      end tell
                                            on error
                                                      set noError to false
                                                      my myLogs(thefile) -- write path to log file in Desktop
                                                      try
      close saving no --if exists, close current document
                                                      end try
                                            end try
                                  end tell
                        end if
              end repeat
      --End F R E E D O M  W I T H  P N G
    end if
    if not noError then do shell script "/usr/bin/open  ~/Desktop/LogPhotoshopError.txt'"
    on myLogs(t)
              try
                        do shell script "echo " & (quoted form of t) & ">> ~/Desktop/LogPhotoshopError.txt'"
              end try
    end myLogs
    on duplicateFile(tFile, foldersPath) -- tFile is an alias, foldersPath is a list of folder
              tell application "Finder" to repeat with folderPath in foldersPath
                        with timeout of 200 seconds -- adjust it,  error if the copy  is longer that 200 seconds
      duplicate tFile to folder folderPath with replacing
                        end timeout
              end repeat
    end duplicateFile
    on getFolderPath(tName, folderPath)
              tell application "Finder" to tell folder folderPath
                        if not (exists folder tName) then
                                  return (make new folder at it with properties {name:tName}) as string
                        else
                                  return (folder tName) as string
                        end if
              end tell
    end getFolderPath
    tell application "Finder"
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell

    I'm getting close or at least I hope this is how it looks now, but appears not pick up the files in the folder?
    The result
              exists folder "Freedom_WK20_HR" of folder "impulse:Week20:Freedom:"
              get folder "Freedom_WK20_HR" of folder "impulse:Week20:Freedom:"
              get name of every file of alias (alias "Images:2012-2013:WK20:Freedom:Freedom_WK20_PSD:") whose {"8BPS"} contains file type or {"psd"} contains name extension
              open "Hal 9000:Users:matthew:Desktop:LogPhotoshopError.txt"
    end tell
    --------------------MAIN SCRIPT BELOW__------------------
    property type_list : {"8BPS"}
    property extension_list : {"psd"}
    script o
              property theseNames : {}
    end script
    -- empty log file
    do shell script "echo  'Files not processed in Photoshop :'  > ~/Desktop/LogPhotoshopError.txt"
    set noError to true
    --at the beginning of the script, ask whether to replace or skip existing files? to apply to all?
    --use the result for the if file exists?
    display dialog "Should I replace or skip exisiting files?" buttons {"Replace", "Skip (Faster)"} default button 2 with icon 1
    set skipFiles to (button returned of the result) is "Skip (Faster)"
    --Setup list of folders and process details of folders
    tell application "Finder"
              set theFolder to (choose folder with prompt "Select Folder")
              set folderName to name of theFolder
              set {oldTID, my text item delimiters} to {my text item delimiters, "_WK"}
              set FolderEndName to last text item of folderName
              set brandName to first text item of folderName
              set my text item delimiters to "_PSD"
              set weekNumber to first text item of FolderEndName
              set my text item delimiters to oldTID
      --set up names to destination folders and create locally based on brand name and week number
              set this_local_folder to "Images:2012-2013"
              set localWeekFolder to my getFolderPath("WK" & weekNumber, this_local_folder)
              set localBrandFolder to my getFolderPath(brandName, localWeekFolder)
              set localBrandFolder_PSD to my getFolderPath(brandName & "_WK" & weekNumber & "_PSD", localBrandFolder)
              set this_Network_folder to "DCKGEN:Brands:Zoom:Brand - Zoom:Upload Photos:2013:"
              set networkWeekFolder to my getFolderPath("Week" & weekNumber, this_Network_folder)
              set networkBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", networkWeekFolder)
              set website_images to "DCKGEN:Website_Images:"
      --set up names to destination folders and create over Netwrok for FTP collection (based on a mounted drive)
              set this_ftp_folder to "Impulse:"
              set ftpWeekFolder to my getFolderPath("Week" & weekNumber, this_ftp_folder)
              set ftpBrandFolder to my getFolderPath(brandName, ftpWeekFolder)
              set ftpBrandFolder_Low_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_LR", ftpBrandFolder)
              set ftpBrandFolder_High_Res to my getFolderPath(brandName & "_WK" & weekNumber & "_HR", ftpBrandFolder)
      --taking the folder identify which process it must follow.
              if brandName is equal to "BHS" then
                        try
                                  tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                        on error
                                  set o's theseNames to {} -- no psd files or "8BPS"
                        end try
                        set numOfNames to (count o's theseNames)
                        repeat with j from 1 to numOfNames
                                  set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B H S    Folder Photoshop Process
                                  set thisName to (item j of o's theseNames)
                                  tell application "Finder"
                                            set t_ext to name extension of file thefile
                                            if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                            set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                                  end tell
                                  if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1348
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to false
                                                                my myLogs(thefile) -- write path to log file in Desktop
                                                                try
      close saving no --if exists, close current document
                                                                end try
                                                      end try
                                            end tell
                                  end if
                        end repeat
      --End BHS
      --taking the folder identify which process it must follow. B U R T O N
              else if brandName is equal to "Burton" then
                        try
                                  tell application "Finder" to set o's theseNames to (name of files of alias theFolder whose file type is in the type_list or name extension is in the extension_list)
                        on error
                                  set o's theseNames to {} -- no psd files or "8BPS"
                        end try
                        set numOfNames to (count o's theseNames)
                        repeat with j from 1 to numOfNames
                                  set thefile to theFolder & ":" & (item j of o's theseNames)
      --    B U R T O N    Folder Photoshop Process
                                  set thisName to (item j of o's theseNames)
                                  tell application "Finder"
                                            set t_ext to name extension of file thefile
                                            if t_ext is not "" then set thisName to text 1 thru -((count t_ext) + 2) of thisName
                                            set b to exists file (localBrandFolder_PSD & thisName & ".psd")
                                  end tell
                                  if not b or (b and not skipFiles) then -- not exists file or file exists and "replace" (continue the rest of the script).
                                            tell application "Adobe Photoshop CS5.1"
      -- I remove the command activate, Photoshop stay in background
                                                      set ruler units of settings to pixel units
                                                      try
      open (alias thefile) showing dialogs never
                                                                set origName to name of current document
                                                                set myOptions to {class:JPEG save options, quality:12}
                                                                set myPSDOptions to {class:Photoshop save options, embed color profile:true, save layers:true}
                                                                tell current document
      --If the quick mask mode has been left on then delete the channel Quick Mask
                                                                          if (quick mask mode) then delete channel ¬
                                                                                    "Quick Mask"
      --If the Layer is incorrectly labeled with Original Layer it needs renaming to original Image
                                                                          if (exists layer "Original Layer") then ¬
                                                                                    tell layer "Original Layer" to set name to "Original Image"
      save in (localBrandFolder_PSD & origName) as Photoshop format with options myPSDOptions without copying
                                                                          (delete layer "Original Image") flatten
      resize image resolution 300 resample method none
      --sharpen image
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      save in (ftpBrandFolder_High_Res & name) as JPEG with options myOptions without copying
      --Prepare for Low RES by resetting image history
                                                                          set current history state to history state 3
                                                                          flatten
                                                                          resize image width 1020
      resize image resolution 300 resample method none
      filter current layer using unsharp mask with options {amount:80, radius:3.2, threshold:0}
      --add save to lowResFolder with same options
      save in (networkBrandFolder_Low_Res & name) as JPEG with options myOptions without copying
                                                                          set newFile to file path
                                                                          set newFile2 to newFile as string -- for testing end of name
                                                                          if newFile2 ends with "_2.jpg" or newFile2 ends with "_3.jpg" or newFile2 ends with "_4.jpg" or newFile2 ends with "_5.jpg" or newFile2 ends with "_6.jpg" or newFile2 ends with "_7.jpg" or newFile2 ends with "_8.jpg" or newFile2 ends with "_9.jpg" or newFile2 ends with "_10.jpg" or newFile2 ends with "11.jpg" then -- exclude website_images
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res})
                                                                          else
                                                                                    my duplicateFile(newFile, {ftpBrandFolder_Low_Res, website_images})
                                                                          end if
      close saving no
                                                                end tell
                                                      on error
                                                                set noError to

  • Another site already exists at . Delete this site before attempting to create a new site with the same URL

    Hi Everyone,
    It would be great if you can help me with the below.
    Few days ago one of our content db went into suspect mode.  Our DB team had resolved the issue. But one of the sites that was created probably around the same time is no more available. When I try to create a site on the same URL, I get the following
    error.
    Another site already exists at <URL>. Delete this site before attempting to create a new site with the same URL
    When I try to delete the site or if I try to view the details of the site using Central Administration, I can find the site, but it doesn't display any details like Title, DB Name etc.
    If I use stsad -o enumsites command to list ll the site, for the given site I get the following error:
    <nativehr>0x80070002</nativehr><nativestack></nativestack>There is no Web named <URL>.
    I am not even able to delete it using Powershell.
    Please suggest.
    Thanks,
    Uttkarsh

    You might be dealing with orphaned site. Go through the following blog post and see if it helps you delete the orphaned sites.
    http://www.cjvandyk.com/blog/Lists/Posts/Post.aspx?ID=299
    Amit

  • Adding another  dimension on BI Admin layer.......

    hi,
    i already have a cube with few dimensions and its running fine on dashboard. Now i added another dimension in oracle warehouse builder cube (same running cube) now i want to upgrade this cube and its data on BI Admin layer so that i can see results accordingly on BI Answers and dashboard.
    How to add this dimension in BI Admin layer as i don't want to import all the dimensions and cube again on physical layer, then make hierarchies for each dimension on business model and mapping layer and changes on presentation layer (just to avoid rework).
    If i import a single dimension it behave like a fact table (cube) with a yellow color.
    thanks in advance
    Mimran

    Hi,
    As I understood from your query you are importing a new dimension table to the physical layer of your RPD. Once you import the dimension table it will be a stand alone table. So join this table to the existing Fact table with the proper key. Then Drag and drop the same table to the BMM layer. In the BMM layer open the Business model diagram and join it to the fact table and then drag it to the presentation layer. This should solve your purpose.

  • Adding switch into an existing stack

                       Hi all,
        I have an existing stack which comprises of 6 switches, please help with the following questions :
    1/ adding another switch into this stack will cause all switches in stack to reboot ? anything that I should be aware of such as different versions ?
    2/ maximum switches in one stack should be ?
      Thanks for all help.

    Hi Duc,
    If you are stacking 3750 switches you can have a max of 9 switches in one stack. The only thing you have to make sure before adding the new switch is that its IOS version should be exactly same as the IOS version of rest of the stack.
    You dont have to worry about any reload of existing stack. Connect the stack cables to the new switch, power it up and it will be added to the existing stack.
    http://www.cisco.com/en/US/products/hw/switches/ps5023/products_configuration_example09186a00807811ad.shtml
    Thanks
    Ankur
    "Please rate the post if found useful"

  • Adding DC to an existing domain and forest

    Hi, I have an existing forest and domain. Its roles are: Domain Services and DNS. We have a branch office and setup a new server. In this new server, we set this as well to be the DC of that remote site and added a third role which is DHCP for their own
    network. We added another server as backup of this branch office. In the process of adding the role, I accidentally checked both domain controller and global catalog. I remember that both of this cannot be GC or is it ok for both to be GC besides DC?
    Thanks
    Jeff

    Hello,
    there is no problem having ALL DCs to be GC also.
    Don't forget to configure AD sites and services with the new subnets and also the sites containing the correct DCs.
    https://technet.microsoft.com/en-us/library/cc730868.aspx?f=255&MSPPError=-2147217396
    http://blogs.technet.com/b/askds/archive/2011/04/29/sites-sites-everywhere.aspx
    Best regards
    Meinolf Weber
    MVP, MCP, MCTS
    Microsoft MVP - Directory Services
    My Blog: http://blogs.msmvps.com/MWeber
    Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    Twitter:  

  • Adding replication to an existing database.

    I am looking at adding replication to an existing database. This database has lots of existing containers many of them are 1G in size. How will this be handled when the master and client initially start? Will the master just start sending to the client? Is there another option?

    Yes. This, and the alternatives, are described in the Ref Guide, on the page entitled "Initializing a new site".
    Alan Bram
    Oracle

  • Adding another Airport Extreme – I'm having problems-

    …please help.
    I am a total novice when it comes to networking so please explain clearly. I had one AE connected to some speakers in the kitchen so I could stream music there. I got another AE today to connect to my router to hopefully provide a quicker and more reliable wireless connection.
    I'm having problems adding the 2 AE to the same network. Tried lots of different ways but nothings worked. I can't my mac to find them both at the same time? When I try to add the other one it asks me to switch networks. When I switch networks i can't see the previous one so I can't add it.
    is there any step by step guide to getting 2 AE up and running i.e. adding another AE to an existing network?
    Cheers in advance.

    kroc_kroc, Welcome to the discussion area!
    Even though the title of your thread says "Extreme" I thing you really mean "Express".
    If you are trying to connect the 2nd AirPort Express (AX) wirelessly...
    (1) Make sure that the 2nd AX is in an area with a good wireless signal from your current wireless network.
    (2) Configure the 2nd AX to join a wireless network and select your current wireless network.

Maybe you are looking for

  • Need to default a PO number in MIRO

    Hello, I've created a proram to call transaction MIRO. It defaults the company code based on the company code of the PO entered. See the code below:   data: gt_fields type standard table of sval with header line,         g_returncode,         g_ebeln

  • Printing the History in Safari

    I need to print out my history but I don't kow how. When I view my history by day and try to print it, it just reverts to the current web page I'm on. Any ideas?

  • Automatic incidents in Solution manager

    Hello all, At first, I am not SolMan consultant...so maybe my issue is not so difficult for you. Customer use FM AI_CRM_IM_INCIDENT_CREATE to automatically create incidents in some cases. They added some customer fields to the incident (message type

  • Icons Strangely Bouncing in Dock?

    Recently I've had a lot of hickups thorughout the graphic of my system. I am running 10.8.3 on a three week old non-retina macbook pro. Today I launched safari and it bounced above the dock like normal, but continued falling below the dock and screen

  • Difference Between Business Area & Business Place

    Hi there What is the difference between <i>Business Area and Business Place</i>. I know that <b>Business place</b> is used in Tax. But again, how it is used. What is the purpose of <b>Business place</b> in tax KM Naidu (Kali)