Question about: Use PowerShell to Toggle the Archive Bit on Files

Hi Scripting Guys,
thanks for you favorite scripts. but
one question: the script abovementioned
running. But I have to enter a -value
for each file. If the script is not
written so that each file checked for the archive
and then changed? Apparently it
does not work right with me.
Here is the script again
and also a screenshot. Over a short help I
would be delighted.
Stephan
$path = "C:\fso"
$files = Get-ChildItem -Path $path -Recurse
$attribute = [io.fileattributes]::archive
Foreach($file in $files)
 If((Get-ItemProperty -Path $file.fullname).attributes -band $attribute)
   "$file.fullname has the $attribute bit set, removing the bit."
   Set-ItemProperty -Path $file.fullname -Name attributes
   -value ((Get-ItemProperty $file.fullname).attributes -BXOR $attribute)
   "New value of $file.Fullname attributes"
   (Get-ItemProperty -Path $file.fullname).attributes
 ELSE
    Write-host -ForegroundColor blue
    "$file.fullname does not have the $attribute bit set, setting the bit."
    Set-ItemProperty -Path $file.fullname -Name attributes
      -value ((Get-ItemProperty $file.fullname).attributes -BXOR $attribute)
    "New value of $file.Fullname attributes"
   (Get-ItemProperty -Path $file.fullname).attributes
} #end Foreach

The attrib command isn't a PowerShell cmdlet:
http://ss64.com/nt/attrib.html
If you're asking which line of your script this should replace, the answer is 'the entire thing'.
Don't retire TechNet! -
(Don't give up yet - 13,225+ strong and growing)

Similar Messages

  • Set the archive bit on files in a folder?

    While viewing files on my Mac from Windows machines on my network, the archive bit seems to be set on the files in soe directories. Setting the archive bit from the Windows machine appears to work, but the bit doesn't really get reset, as a quick refresh of the directory shows.
    Is there a way to (re-)set the archive bit (or any of the read/hidden/system/archive bits) for files on a drive that is neither NTFS nor FAT32? Does OS X allow for the setting of these bits?
    -=b=-

    The attrib command isn't a PowerShell cmdlet:
    http://ss64.com/nt/attrib.html
    If you're asking which line of your script this should replace, the answer is 'the entire thing'.
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Question about using multiple iPods on the same PC

    I've read the FAQs on this subject but I still have a couple of questions about multiple users with separate iPods using the same PC.
    I want to use my family's desktop (A new Gateway with Vista, if it matters) for my new iPod Classic, but my father already has an iTunes account on there for his iPod. I know I can create a new user account on the PC and move iTunes to a shared folder so that we can share music, but will this second account be able to purchase music from the iTunes store or am I going to have to switch between Windows User accounts to make purchases and then move new songs into my separate iTunes account via the shared folder? Will it be its own separate iTunes account (separate user name, separate credit card used, etc.) or will it just be a second library that's dependant on the first?
    I want to be able to have my own iTunes account, make my own purchases in it, and maybe occasionally share tv shows or something with my father.
    If this can't be done, would I be better off just creating new playlists for our two iPods from the same library, or creating a second library on my Father's account?
    Also, if I want to access things I've purchased from iTunes on this desktop in iTunes on my notebook, will I be able to?
    I hope that made sense.
    Sorry if these seem like silly questions. This will be my first iPod as I'm really excited about the 160gig and want to know if these things are possible.
    Thanks in advance for any help

    Hi, Wes.
    Congratulations on your new iPod Classic and Welcome to the Apple Discussions.
    For no particular reason, let's answer your last question first ...
    ... if I want to access things I've purchased from iTunes on this desktop in iTunes on my notebook, will I be able to?
    The iTunes Store operates on a one download per purchase policy so you will have to copy the purchases from one computer to the other and make sure that you authorize the laptop to play the songs.
    As to your first question ...
    ... will this second account be able to purchase music from the iTunes store or am I going to have to switch between Windows User accounts to make purchases ...
    Whatever XP User Account you are logged in to doesn't really matter. What's important is which Apple Account you sign in to ... yours or your Dad's or - if you had my Apple ID and password - The Mimico Kid's for that matter. You can sign in to any Apple Account on any XP User Account. Or any computer for that matter.
    Where the XP User Account comes into play is that it will determine where on your computer the purchases are downloaded. Files will be sent to the iTunes Music folder as specified in the iTunes Edit menu > Preferences > Advanced tab > General sub-tab. Default settings will have a different location for each User Account - C:\Documents and Settings\ user name \My Documents\My Music\iTunes - but if you've read this article in the Apple Knowledge Base, you will know you can change the location of the iTunes Music folder in each XP Account to a common location such as C:\Documents and Settings\All Users\Documents\My Music\iTunes.
    Post back if all this hasn't been as clear as mud and you need anything clarified.

  • Question about using MAX to get the lastest date.

    My question is I need to get the latest erstate.DATE_CREATED.
    I thought that I could just do the following max(erstate.DATE_CREATED) but get
    this error message (ora-00937: not a single-group group function). Can some explain to me what I am supposed to do. Thanks
    select     eractivity.er_case_id,
         erstate.description as latest_status,
         erstate.DATE_CREATED
    from      dpss_gdats.er_activity eractivity,
         dpss_gdats.er_state erstate
    where      eractivity.ER_STATE_ID = erstate.er_state_id
    and      eractivity.er_case_id = :p_case

    Yes max(erstate.DATE_CREATED) will get you the latest erstate.DATE_CREATED. Looking at your query I'm not really sure if you want the latest date for every case_id, description or you want the latest date_created period.
    If you want the former:
    select eractivity.er_case_id, erstate.description as latest_status,
    max(erstate.DATE_CREATED)
    from dpss_gdats.er_activity eractivity,
    dpss_gdats.er_state erstate
    where eractivity.ER_STATE_ID = erstate.er_state_id
    and eractivity.er_case_id = :p_case
    group by eractivity.er_case_id, erstate.description
    for the latter :
    select max(erstate.DATE_CREATED)
    from dpss_gdats.er_activity eractivity,
    dpss_gdats.er_state erstate
    where eractivity.ER_STATE_ID = erstate.er_state_id
    and eractivity.er_case_id = :p_case

  • Question about using PowerShell to detect web page availability and then perform alternate action.

    I have a specific Windows 7 machine that needs to always display a specific Intranet page.  (it shows an internal status page in kiosk mode).
    If this machine every loses connectivity to the web server, unfortunately, the browser shows the typical "web page could not be retrieved" error message and it never recovers.  I need to manually reload the page when the connection is restored.
    I'm thinking if it would be possible to write a PowerShell script that checks the connectivity/availability of the Intranet page and if it detects an error, it would launch a browser that points to a local file html file which would say something more professional
    and graceful like "site temporarily down for maintenance."  Also, if the PowerShell script could run on a regular interval, when the Intranet page becomes available again, it would close the browser that is showing the maintenance page and start
    showing the page with the original Intranet site.
    For the Intranet site checking, I was looking at the invoke-webrequest: as the mechanism.
    Any guidance would be appreciated as I am new to PowerShell.

    With these lines you get the static content of the web page:
    $page = new-object net.webclient
    $page.UseDefaultCredentials = $True
    $Page.DownloadString(“http://www.intranet.local.com/”)
    You could first check whether the web server is pingable, then use the lines above to see whether there is a HTML response.
    If the web server doesnt respond you could kill the browser process and then open a HTML page stored locally on the Win 7 client:
    Invoke-Item .\ErrorPage.html
    If the web server responds, kill the browser and restart it showing the Intranet page.
    All this run from a scheduled task.

  • Question about using DVD covers for the movies I import

    Question for all you mac genii - When I import a dvd that I own into my itunes library and sync to my  tv, how can I get the DVD cover art to appear so it looks like the stuff I have purchased from the itunes library? It there a way to edit the cover art for movies? Thanks in advance...

    You add it just like you would for music - the catch is that if you are doing syncing, you need to re-sync the whole file (so the embedded artwork will transfer). Add the artwork, un-check the movie/tv show to be synced, do a sync (it should be removed from the ATV), and then check it to synced again and do a sync (it should push it back out to the ATV again).
    Kind of a pain - so it is best to tag your files (MetaX is awesome) before you do any syncing of files.

  • Simple Question About Using "Group by" Inside the Oracle XE Query Builder

    Hi,
    I am a new user of Oracle 10g XE and I have built and populated some tables. I am trying to create a view (make a query) via using the Query Builder. I have chosen two attributes, say course_section_ID and trainer_ID in the same table. I choose the "COUNT" function for course_section_no and I check the box for "Group By" with trainer_ID. (I would like to count the number course sections each trainer is teaching). Then I "run" the query and the same error message appears:
    fail to parse SQL query:
    ORA-00904: "COURSE_SECTION"."TRAINER_ID": invalid identifier
    Both attribute names should be valid (as shown above).
    If I only choose course_section_ID and do a COUNT on it, it gives the same error message on course_section_no.
    I did try to do the same thing with the demo HR database. There were no problems with counting a field nor with grouping on a field with HR.
    PLEASE HELP!
    Thanks.

    I have got it. When all the attribute names are in the uppercase, then I can do aggregate functions and "group by" with the GUI.

  • I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher

    I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher #1 iPad to its AppleTV without effecting/projecting onto the adjacent teachers #2 classroom AppleTV?

    Not as such.
    Give the AppleTV units unique names and also enable Airplay password in settings with unique passwords for each teacher.
    AC

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Hello , I want to ask some question about ipads \  How powerful is the iPad?  How useful is it for reading books, newspaper or magazines or for surfing the web? Can you identify any shortcomings of the device?   please help me :(

    Hello ,
    I want to ask some question about ipads \
    How powerful is the iPad? 
    How useful is it for reading books, newspaper or magazines or for surfing the web?
    Can you identify any shortcomings of the device?  
    please help me

    it's less powerful than your average computer. THink of it like a netbook but with a better processor.
    It'll do fine for surfing (although if you browse a lot of flash based sites you will need to get a third party browser since safari doesn't accommodate it)
    You may do OK on reading books, papers or magazines, especially if they have apps, but the ipad's screen is backlit, so it doesn't work well outdoors and you may need to fiddle with the brightness so that you don't get eye strain (it's just like doing too much reading from a computer screen)
    I would say the biggest short comings are data transfer. Apple's preferred work flow is that everything is done via iTunes or the internet....well people dont' always have 100% reliable always on internet access so you can find yourself in a situation where you can't get things on/off the iPad.
    By and large, it's a good device for day to day stuff, but is not a computer replacement.

  • Where Would be the best category to ask a question about using dashboard?

    Where Would be the best category to ask a question about using dashboard?

    However, don't ask it in this topic. Create a new topic for the question with a title describing that you are looking for Dashboard help.

  • Question about using new battery in old Powerbook

    I have a pre-intel Powerbook G4, and the battery is pretty much toast (lasts about 15 minutes now). I have ordered a new battery for it, and I have this question about using it:
    Am I smarter to keep the new strong battery out of the PB most days (as I usually work with it plugged in at home) and just pop it in when I know I will be out surfing on batteries? Or is it just as good living in my laptop 24/7 and only occasionally being called upon to do its job?
    Current bad Battery Information below:
    Battery Installed: Yes
    First low level warning: No
    Full Charge Capacity (mAh): 1144
    Remaining Capacity (mAh): 1115
    Amperage (mA): 0
    Voltage (mV): 12387
    Cycle Count: 281
    thanks folks, Shereen

    Hi, Shereen. Every Powerbook battery wants to be used — drained and then recharged — at least every couple of weeks. If you've always used your Powerbook on AC power nearly all the time, and not followed that pattern of discharging and recharging the battery every week or two, it's possible that your use habits have shortened the lifespan and prematurely diminished the capacity of your old battery. Of course it's also possible that your battery is merely old, as a battery's capacity also diminishes with age regardless of how it's used. You didn't say how old the battery is in years, so this may or may not be an issue. I mention it only because it can be an issue.
    For general information on handling a battery for the longest possible lifespan, see this article. My advice on the basis of that article and long experience reading these forums is that it would be OK to do as you propose, but I doubt that you'd derive any significant benefit from it. You would still want to be sure of putting the new battery through a charge/discharge cycle every week or two, even if you didn't have a reason to use the Powerbook away from home or your desk, because sitting unused outside the computer is just as bad for a battery as sitting unused inside it. And you should never remove the battery from your computer when it's completely or almost completely discharged and let it sit that way any longer than a day or two.
    Message was edited by: eww

  • Question about using TVARV in an ABAP program

    Hello gurus, Im sorry about the silly question.
    I have a question about using TVARV in an ABAP program.
    A program is presenting a problem and I think that in this code:
    SELECT SIGN OPTI LOW HIGH
      FROM TVARV
      INTO TABLE R_1_163431035_VELOCIDADE
      WHERE  NAME = '1_163431035_VELOCIDADE'
      AND    TYPE = 'S'.
      IF ZMM001-VELOCIDADE_B   IN R_1_163431035_VELOCIDADE AND
          ZOPERADORAS-OPERADORA = 'ABCD' AND
          ZMM001-MATERIAL       IN R_1_163431035_PRODUTO.
      ELSE.
      ENDIF.
    What happens is that the value "ZMM001-SPEED" B not exist in "R1_163431035_VELOCIDADE" but the program executes commands under the IF and not under the ELSE, as I imagine it would work. Is this correct ?
    I am new to ABAP programming, but I have a lot of XP in other programming languages ​​and this makes no sense to me.
    Anyone know where I can find some documentation of the use of "TVARV" in ABAP programs?
    I search the Internet if other programmers use TVARV this way, but found nothing, which leads me to think that was a quick and dirty solution that used here.
    If this is a bad way to program, what would be the best way?
    Regards
    Ronaldo.

    Hi Ronaldo,
    But in this case, the range is not empty, there are 17 records, in this way.:
    For the column "SING" all values ​​are "E"
    It means that the result is false if ZMM001-VELOCIDADE_B has the same value as one of the 17 records (E = exclude).
    For instance, if it has value 'C' and one of 17 records matches C, then the result is false.
    The "IF" with "IN" using "TVARV" as used in the program of the post above has the same behavior of a selection screen?
    Yes, the same behavior as the selection criterion to be exact. You can press the help key in the complex selection dialog for more info.
    I know it's a silly and very basic question, but other language that I used, only the SQL has the "IN" operator, but I think they work in different ways, so I would like to understand how it works in ABAP.
    Not silly ;-). Yes they work differently.
    More info here:
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba74635c111d1829f0000e829fbfe/frameset.htm
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/frameset.htm
    BR
    Sandra

  • Question about using Macbook in Vietnam.

    I have a question about using Macbook in Vietnam. I bought my mac here in the US, and I'm going to visit Vietnam, but I'm wondering if I can plug in the power directly into the wall or I have to need any convert power modem for my mac. The only thing I know that Vietnam use 220V so, can anyone help me?

    You may need a plug adaptor, but you don't need a power converter.
    (43828)

  • I have a question about using adobe CS files in CS6 edition

    I am a graphic artist . I have a question about using adobe CS files in CS6 edition. when I am gonna open thse adobe CS created files in CS6 Edition i get a color variation than i made with the CS version.Please give me an idea about this issue as soon as possible.If you need i can upload my problem as a screenshot to clearity

    donrulz,
    Are your Edit>Color Settings the same?
    Are you using spot colours, such as Pantone (there have been some changes in CMYK values with new colour books)?

Maybe you are looking for

  • Itunes and itunes library not matching

    I have imported music into itunes and these discs are not showing up in mu itunes library. Any suggestions would be appreciated. Thanks!

  • Can't Download Itunes into Windows XP

    I had an older version of Itunes on my computer which would not update. Message " server not found". Uninstalled Itunes, updated windows, cleaned registry, optimized disk, turned off firewall. Downloaded Itunes 7.7.???, now Itunes fails on the boot u

  • User Name and Password for reinstallation

    Well, I have had no luck trying to gain this information from Oracle. We did not purchase support as it is not needed by our company with 1 user only 15 people in the whole company. The user has forgotten the password and we were told to uninstall th

  • How to make Business place mandatory

    Hi, SAP Gurus, How to make business place mandatory in "MIRO ". As i know there are two ways 1) Through Screen Variant T/code: SHD0 2) Validation But here  i Never worked on sreen variant level and validation, I need step by step to make business pla

  • Lightroom 3.6 crashes upon start up!

    Please help!  I just waiting 2 /12 hours to get support in the chat room only to be told they only work with lightroom 5.  I have deleted the preferences file.  I have deleted the .lock files.  I have uninstalled and reinstalled.  Nothing works This